[ovs-git] [openvswitch/ovs] d34a1c: Python3 compatibility: Convert print statements

GitHub noreply at github.com
Thu Jul 6 21:06:18 UTC 2017


  Branch: refs/heads/master
  Home:   https://github.com/openvswitch/ovs
  Commit: d34a1cc02536f9a812517a71accec3fbd3c6c98b
      https://github.com/openvswitch/ovs/commit/d34a1cc02536f9a812517a71accec3fbd3c6c98b
  Author: Jason Wessel <jason.wessel at windriver.com>
  Date:   2017-07-06 (Thu, 06 Jul 2017)

  Changed paths:
    M build-aux/check-structs
    M build-aux/extract-ofp-actions
    M build-aux/extract-ofp-errors
    M build-aux/extract-ofp-fields
    M build-aux/extract-ofp-msgs
    M ovsdb/ovsdb-doc
    M ovsdb/ovsdb-idlc.in

  Log Message:
  -----------
  Python3 compatibility: Convert print statements

This patch fixes up all the print statements to work with python3 or
python2.

Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>


  Commit: 52e4a477f0b3c0a0ece7adeede6e06e07814f8b9
      https://github.com/openvswitch/ovs/commit/52e4a477f0b3c0a0ece7adeede6e06e07814f8b9
  Author: Jason Wessel <jason.wessel at windriver.com>
  Date:   2017-07-06 (Thu, 06 Jul 2017)

  Changed paths:
    M build-aux/extract-ofp-fields
    M ovsdb/ovsdb-doc
    M ovsdb/ovsdb-idlc.in

  Log Message:
  -----------
  Python3 compatibility: exception cleanup

The exception syntax which is compatible with python2 and python3 is
to use the "as" form for "except:".

Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>


  Commit: a4d10a7ca937d73873f6f98619d88682e69f5dbe
      https://github.com/openvswitch/ovs/commit/a4d10a7ca937d73873f6f98619d88682e69f5dbe
  Author: Jason Wessel <jason.wessel at windriver.com>
  Date:   2017-07-06 (Thu, 06 Jul 2017)

  Changed paths:
    M ovsdb/ovsdb-idlc.in

  Log Message:
  -----------
  Python3 compatibility: execfile to exec

Allow compability with python3 and python2 by changing execfile() to
exec().

Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>


  Commit: 4ab665623cbb4c6506e48b82e0c9fe8585f42e13
      https://github.com/openvswitch/ovs/commit/4ab665623cbb4c6506e48b82e0c9fe8585f42e13
  Author: Jason Wessel <jason.wessel at windriver.com>
  Date:   2017-07-06 (Thu, 06 Jul 2017)

  Changed paths:
    M build-aux/extract-ofp-actions
    M build-aux/extract-ofp-errors
    M build-aux/extract-ofp-fields
    M ovsdb/ovsdb-idlc.in

  Log Message:
  -----------
  Python3 compatibility: iteritems to items

Allow compability with python3 and python2 by changing iteritems() to
items().

Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>


  Commit: fa145f1a53943243f94a32ce98525db8494b0052
      https://github.com/openvswitch/ovs/commit/fa145f1a53943243f94a32ce98525db8494b0052
  Author: Jason Wessel <jason.wessel at windriver.com>
  Date:   2017-07-06 (Thu, 06 Jul 2017)

  Changed paths:
    M ovsdb/ovsdb-idlc.in
    M python/build/nroff.py

  Log Message:
  -----------
  Python3 compatibility: fix integer problems

In python3 maxint is not defined, but maxsize is defined in both
python2 and python3.

The put_text() will not automatically use a value which came in as
float due to a pior math function and python3 will throw an exception.
The simple answer is to convert it with int() and move on.

Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>


  Commit: 3fa5aa4294377e0f35267936d0c5caea3e61db48
      https://github.com/openvswitch/ovs/commit/3fa5aa4294377e0f35267936d0c5caea3e61db48
  Author: Jason Wessel <jason.wessel at windriver.com>
  Date:   2017-07-06 (Thu, 06 Jul 2017)

  Changed paths:
    M build-aux/extract-ofp-actions

  Log Message:
  -----------
  Python3 compatibility: math error compatibility

The way math is handled with typing is completely different in python3.

% python2<<EOF
x=10
y=8
print((x + (y - 1)) / y * y)
EOF
16

python3<<EOF
x=10
y=8
print((x + (y - 1)) / y * y)
EOF
17.0

So we need to force an integer for the round function as follows and
maintain compatibility with python2.

python3<<EOF
x=10
y=8
print(int((x + (y - 1)) / y) * y)
EOF
16

Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>


  Commit: 7430959d4ad17db89b8387c3aef58c8b230cad10
      https://github.com/openvswitch/ovs/commit/7430959d4ad17db89b8387c3aef58c8b230cad10
  Author: Jason Wessel <jason.wessel at windriver.com>
  Date:   2017-07-06 (Thu, 06 Jul 2017)

  Changed paths:
    M ovsdb/ovsdb-doc

  Log Message:
  -----------
  Python3 compatibility: unicode to str

When transitioning from python2 to python3 the following type class
changes occured:

python2 -> python3
unicode -> str
str -> bytes

That means we have to check the python version and do the right type
check python3 will throw an error when it tries to use the unicode
type because it doesn't exist.

Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>


  Commit: a91c4cfaf863718bc94fb9c88939bd0b0385a6fe
      https://github.com/openvswitch/ovs/commit/a91c4cfaf863718bc94fb9c88939bd0b0385a6fe
  Author: Ben Pfaff <blp at ovn.org>
  Date:   2017-07-06 (Thu, 06 Jul 2017)

  Changed paths:
    M AUTHORS.rst

  Log Message:
  -----------
  AUTHORS: Add Jason Wessel.

Signed-off-by: Ben Pfaff <blp at ovn.org>


Compare: https://github.com/openvswitch/ovs/compare/fb16fec66498...a91c4cfaf863


More information about the git mailing list