diff options
author | Russell Bryant <russell@ovn.org> | 2016-04-14 09:23:27 -0400 |
---|---|---|
committer | Russell Bryant <russell@ovn.org> | 2016-04-15 16:52:50 -0400 |
commit | 28b4f69ba26d2178247563288c9397ca9f9766d8 (patch) | |
tree | efcc0c4de24b8a20510a6672e5626aada72c6c3c /python/ovs | |
parent | 96f46bfc3d7e26246228754905a4a52f4ec6021d (diff) | |
download | openvswitch-28b4f69ba26d2178247563288c9397ca9f9766d8.tar.gz |
python: Update Python version checks.
Instead of checking the raw version, use the six.PY2 and six.PY3 helpers
to determine if Python 2 or Python 3 are in use.
In one case, the check was to determine if the Python version was >=
2.6. We now only support >= 2.7, so this check would always be true.
Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Acked-by: Miguel Angel Ajo <majopela@redhat.com>
Diffstat (limited to 'python/ovs')
-rw-r--r-- | python/ovs/socket_util.py | 8 | ||||
-rw-r--r-- | python/ovs/stream.py | 4 |
2 files changed, 3 insertions, 9 deletions
diff --git a/python/ovs/socket_util.py b/python/ovs/socket_util.py index 9f46a55e3..b358b05aa 100644 --- a/python/ovs/socket_util.py +++ b/python/ovs/socket_util.py @@ -17,7 +17,6 @@ import os import os.path import random import socket -import sys import six from six.moves import range @@ -85,10 +84,7 @@ def make_unix_socket(style, nonblock, bind_path, connect_path, short=False): sock.bind(bind_path) try: - if sys.hexversion >= 0x02060000: - os.fchmod(sock.fileno(), 0o700) - else: - os.chmod("/dev/fd/%d" % sock.fileno(), 0o700) + os.fchmod(sock.fileno(), 0o700) except OSError as e: pass if connect_path is not None: @@ -276,7 +272,7 @@ def write_fully(fd, buf): bytes_written = 0 if len(buf) == 0: return 0, 0 - if sys.version_info[0] >= 3 and not isinstance(buf, six.binary_type): + if six.PY3 and not isinstance(buf, six.binary_type): buf = six.binary_type(buf, 'utf-8') while True: try: diff --git a/python/ovs/stream.py b/python/ovs/stream.py index bc14836a8..64d954453 100644 --- a/python/ovs/stream.py +++ b/python/ovs/stream.py @@ -15,7 +15,6 @@ import errno import os import socket -import sys import six @@ -226,8 +225,7 @@ class Stream(object): try: # Python 3 has separate types for strings and bytes. We must have # bytes here. - if (sys.version_info[0] >= 3 - and not isinstance(buf, six.binary_type)): + if six.PY3 and not isinstance(buf, six.binary_type): buf = six.binary_type(buf, 'utf-8') return self.socket.send(buf) except socket.error as e: |