[ovs-git] [openvswitch/ovs] 8f8088: python: Drop usage of long type.
GitHub
noreply at github.com
Tue Feb 2 22:03:49 UTC 2016
Branch: refs/heads/master
Home: https://github.com/openvswitch/ovs
Commit: 8f808842a0c3f6b63d027c05db77ff945c29d67c
https://github.com/openvswitch/ovs/commit/8f808842a0c3f6b63d027c05db77ff945c29d67c
Author: Russell Bryant <russell at ovn.org>
Date: 2016-02-02 (Tue, 02 Feb 2016)
Changed paths:
M python/ovs/db/data.py
M python/ovs/db/idl.py
M python/ovs/db/parser.py
M python/ovs/db/types.py
M python/ovs/json.py
M python/ovstest/args.py
M python/ovstest/tests.py
Log Message:
-----------
python: Drop usage of long type.
Python 2 has both long and int types. Python 3 only has int, which
behaves like long.
In the case of needing a set of integer types, we can use
six.integer_types which includes int and long for Python 2 and just int
for Python 3.
We can convert all cases of long(value) to int(value), because as of
Python 2.4, when the result of an operation would be too big for an int,
the type is automatically converted to a long.
There were several places in this patch doing type comparisons. The
preferred way to do this is using the isinstance() or issubclass()
built-in functions, so I converted the similar checks nearby while I was
at it.
Signed-off-by: Russell Bryant <russell at ovn.org>
Acked-by: Ben Pfaff <blp at ovn.org>
Commit: 25f599fbd3452a0b1dbb0f22c2f54b2cc0f93bc9
https://github.com/openvswitch/ovs/commit/25f599fbd3452a0b1dbb0f22c2f54b2cc0f93bc9
Author: Russell Bryant <russell at ovn.org>
Date: 2016-02-02 (Tue, 02 Feb 2016)
Changed paths:
M python/ovs/db/data.py
M python/ovs/db/parser.py
M python/ovs/db/schema.py
M python/ovs/db/types.py
M python/ovs/json.py
M python/ovs/jsonrpc.py
M python/ovs/ovsuuid.py
M python/ovs/unixctl/server.py
M tests/test-json.py
M tests/test-ovsdb.py
Log Message:
-----------
python: Drop unicode type.
Python 2 had str and unicode. Python 3 only has str, which is always a
unicode string. Drop use of unicode with the help of six.text_type
(unicode in py2 and str in py3) and six.string_types ([str, unicode] in
py2 and [str] in py3).
Signed-off-by: Russell Bryant <russell at ovn.org>
Acked-by: Ben Pfaff <blp at ovn.org>
Commit: 1ccbf95c6eaccb371227dd58455163840d6cc2d0
https://github.com/openvswitch/ovs/commit/1ccbf95c6eaccb371227dd58455163840d6cc2d0
Author: Russell Bryant <russell at ovn.org>
Date: 2016-02-02 (Tue, 02 Feb 2016)
Changed paths:
M python/ovs/unixctl/__init__.py
M python/ovs/unixctl/client.py
M python/ovs/unixctl/server.py
Log Message:
-----------
python: Drop use of types.StringTypes.
types.StringTypes does not exist in Python 3. We can use
six.string_types, instead.
Signed-off-by: Russell Bryant <russell at ovn.org>
Acked-by: Ben Pfaff <blp at ovn.org>
Commit: 58de9fc30e45118a7a3b2018ced44adaefb6c3b9
https://github.com/openvswitch/ovs/commit/58de9fc30e45118a7a3b2018ced44adaefb6c3b9
Author: Russell Bryant <russell at ovn.org>
Date: 2016-02-02 (Tue, 02 Feb 2016)
Changed paths:
M python/ovs/unixctl/__init__.py
Log Message:
-----------
python: Drop use of types.FunctionType.
This code asserted that the callback argument was of type
types.FunctionType. It's more pythonic to just check that the argument
is callable, and not specifically that it's a function. There are other
ways to implement a callback than types.FunctionType.
Signed-off-by: Russell Bryant <russell at ovn.org>
Acked-by: Ben Pfaff <blp at ovn.org>
Commit: 981e9560cef1cc9d9f4de2e01298434bc13aa7ea
https://github.com/openvswitch/ovs/commit/981e9560cef1cc9d9f4de2e01298434bc13aa7ea
Author: Russell Bryant <russell at ovn.org>
Date: 2016-02-02 (Tue, 02 Feb 2016)
Changed paths:
M python/ovs/json.py
Log Message:
-----------
python: Don't use StringIO directly.
StringIO.StringIO in Python 2 became io.StringIO in Python 3. Use
six.StringIO which is an alias for the two cases.
Signed-off-by: Russell Bryant <russell at ovn.org>
Acked-by: Ben Pfaff <blp at ovn.org>
Commit: d36bbd37f6da56f7999f4978d9c471a49b6a2b02
https://github.com/openvswitch/ovs/commit/d36bbd37f6da56f7999f4978d9c471a49b6a2b02
Author: Russell Bryant <russell at ovn.org>
Date: 2016-02-02 (Tue, 02 Feb 2016)
Changed paths:
M python/ovs/db/schema.py
M python/ovs/db/types.py
M python/ovs/json.py
M python/ovs/vlog.py
Log Message:
-----------
python: Drop use of sys.maxint.
sys.maxint does not exist in Python 3, as an int does not have a max
value anymore (except as limited by implementation details and system
resources).
sys.maxsize works as a reasonable substitute as it's the same as
sys.maxint. The Python 3.0 release notes have this to say:
The sys.maxint constant was removed, since there is no longer a limit
to the value of integers. However, sys.maxsize can be used as an
integer larger than any practical list or string index. It conforms to
the implementation’s “natural” integer size and is typically the same
as sys.maxint in previous releases on the same platform (assuming the
same build options).
sys.maxsize is documented as:
An integer giving the maximum value a variable of type Py_ssize_t can
take. It’s usually 2**31 - 1 on a 32-bit platform and 2**63 - 1 on a
64-bit platform.
Signed-off-by: Russell Bryant <russell at ovn.org>
Acked-by: Ben Pfaff <blp at ovn.org>
Commit: eac25f500ab9e53d2be076c1f5076733e882b927
https://github.com/openvswitch/ovs/commit/eac25f500ab9e53d2be076c1f5076733e882b927
Author: Russell Bryant <russell at ovn.org>
Date: 2016-02-02 (Tue, 02 Feb 2016)
Changed paths:
M python/ovs/json.py
Log Message:
-----------
python: Use six.unichr().
six.unichr() is equivalent to unichr() in Python 2
and chr() in Python 3.
Signed-off-by: Russell Bryant <russell at ovn.org>
Acked-by: Ben Pfaff <blp at ovn.org>
Commit: da2d45c6c6e7379d3097708385121b2b4dbc16fb
https://github.com/openvswitch/ovs/commit/da2d45c6c6e7379d3097708385121b2b4dbc16fb
Author: Russell Bryant <russell at ovn.org>
Date: 2016-02-02 (Tue, 02 Feb 2016)
Changed paths:
M python/ovs/db/data.py
M python/ovs/db/idl.py
M python/ovs/db/parser.py
M python/ovs/db/schema.py
M python/ovs/json.py
M python/ovs/jsonrpc.py
M python/ovs/socket_util.py
Log Message:
-----------
python: Remove reamining direct type comparisons.
I've hit several bugs in this Python 3 work where the fix was some code
needed to be converted to use isinstance(). This has been primarily
around deadling with the changes to unicode handling. Go ahead and
convert the rest of the direct type comparisons to use isinstance(), as
it could avoid a bug I haven't hit yet and it's more Pythonic, anyway.
Signed-off-by: Russell Bryant <russell at ovn.org>
Acked-by: Ben Pfaff <blp at ovn.org>
Commit: c03afda69ae8b1be9d3d94ded0e1c12f6e886dba
https://github.com/openvswitch/ovs/commit/c03afda69ae8b1be9d3d94ded0e1c12f6e886dba
Author: Russell Bryant <russell at ovn.org>
Date: 2016-02-02 (Tue, 02 Feb 2016)
Changed paths:
M python/ovs/reconnect.py
M tests/test-reconnect.py
Log Message:
-----------
python: Don't compare None and int.
Comparing None to an integer worked in Python 2, but fails in Python 3.
Signed-off-by: Russell Bryant <russell at ovn.org>
Acked-by: Ben Pfaff <blp at ovn.org>
Commit: fbafc3c263c489f383a3aa568e1fad46f8bfeec7
https://github.com/openvswitch/ovs/commit/fbafc3c263c489f383a3aa568e1fad46f8bfeec7
Author: Russell Bryant <russell at ovn.org>
Date: 2016-02-02 (Tue, 02 Feb 2016)
Changed paths:
M python/ovs/db/data.py
M python/ovs/db/idl.py
Log Message:
-----------
python: Fix object comparisons in Python 3.
Python 3 no longer supports __cmp__. Instead, we have to implement the
"rich comparison" operators. We implement __eq__ and __lt__ and use
functools.total_ordering to implement the rest.
In one case, no __cmp__ method was provided and instead relied on the
default behavior provided in Python 2. We have to implement the
comparisons explicitly for Python 3.
Signed-off-by: Russell Bryant <russell at ovn.org>
Acked-by: Ben Pfaff <blp at ovn.org>
Commit: 0e7c46c44079d52365767f2cc77f2c56cce3ff2e
https://github.com/openvswitch/ovs/commit/0e7c46c44079d52365767f2cc77f2c56cce3ff2e
Author: Russell Bryant <russell at ovn.org>
Date: 2016-02-02 (Tue, 02 Feb 2016)
Changed paths:
M python/ovs/jsonrpc.py
M python/ovs/socket_util.py
M python/ovs/stream.py
Log Message:
-----------
python: Deal with str and byte differences.
Python 3 has separate types for strings and bytes. Python 2 used the
same type for both. We need to convert strings to bytes before writing
them out to a socket. We also need to convert data read from the socket
to a string.
Signed-off-by: Russell Bryant <russell at ovn.org>
Acked-by: Ben Pfaff <blp at ovn.org>
Compare: https://github.com/openvswitch/ovs/compare/490bafe8d805...0e7c46c44079
More information about the git
mailing list