2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-29 15:28:56 +00:00

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@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Russell Bryant
2015-12-14 16:32:00 -05:00
parent 490bafe8d8
commit 8f808842a0
7 changed files with 52 additions and 34 deletions

View File

@@ -161,7 +161,7 @@ def bandwidth(string):
raise argparse.ArgumentTypeError("Not a valid target bandwidth")
bwidth = string.replace("M", "000000")
bwidth = bwidth.replace("K", "000")
return long(bwidth) / 8 # Convert from bits to bytes
return int(bwidth) / 8 # Convert from bits to bytes
def tunnel_types(string):

View File

@@ -96,8 +96,8 @@ def do_tcp_tests(receiver, sender, duration):
time.sleep(duration + 1)
rcv_bytes = long(server1.get_tcp_listener_results(listen_handle))
snt_bytes = long(server2.get_tcp_sender_results(send_handle))
rcv_bytes = int(server1.get_tcp_listener_results(listen_handle))
snt_bytes = int(server2.get_tcp_sender_results(send_handle))
bwidth = rcv_bytes / duration