diff options
Diffstat (limited to 'OpenSSL/SSL.py')
| -rw-r--r-- | OpenSSL/SSL.py | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/OpenSSL/SSL.py b/OpenSSL/SSL.py index 8972097..eb26e76 100644 --- a/OpenSSL/SSL.py +++ b/OpenSSL/SSL.py @@ -1,5 +1,6 @@ +import six from warnings import warn -from sys import platform, version_info +from sys import platform from functools import wraps, partial from itertools import count from weakref import WeakValueDictionary @@ -314,12 +315,10 @@ class Context(object): # Backward compatibility if isinstance(cafile, _text_type): - if version_info.major == 2: + if six.PY2: warn("unicode in cafile is no longer accepted, use bytes", DeprecationWarning) - elif version_info.major == 3: - warn("str in cafile is no longer accepted, use bytes", DeprecationWarning) else: - warn("text in cafile is no longer accepted, use bytes", DeprecationWarning) + warn("str in cafile is no longer accepted, use bytes", DeprecationWarning) cafile = cafile.encode('utf-8') if cafile is None: @@ -985,12 +984,10 @@ class Connection(object): # Backward compatibility if isinstance(buf, _text_type): - if version_info.major == 2: + if six.PY2: warn("unicode in buf is no longer accepted, use bytes", DeprecationWarning) - elif version_info.major == 3: - warn("str in buf is no longer accepted, use bytes", DeprecationWarning) else: - warn("text in buf is no longer accepted, use bytes", DeprecationWarning) + warn("str in buf is no longer accepted, use bytes", DeprecationWarning) buf = buf.encode('utf-8') if isinstance(buf, _memoryview): @@ -1020,12 +1017,10 @@ class Connection(object): # Backward compatibility if isinstance(buf, _text_type): - if version_info.major == 2: + if six.PY2: warn("unicode in buf is no longer accepted, use bytes", DeprecationWarning) - elif version_info.major == 3: - warn("str in buf is no longer accepted, use bytes", DeprecationWarning) else: - warn("text in buf is no longer accepted, use bytes", DeprecationWarning) + warn("str in buf is no longer accepted, use bytes", DeprecationWarning) buf = buf.encode('utf-8') if isinstance(buf, _memoryview): @@ -1116,12 +1111,10 @@ class Connection(object): # Backward compatibility if isinstance(buf, _text_type): - if version_info.major == 2: + if six.PY2: warn("unicode in buf is no longer accepted, use bytes", DeprecationWarning) - elif version_info.major == 3: - warn("str in vuf is no longer accepted, use bytes", DeprecationWarning) else: - warn("text in buf is no longer accepted, use bytes", DeprecationWarning) + warn("str in buf is no longer accepted, use bytes", DeprecationWarning) buf = buf.encode("ascii") if self._into_ssl is None: |
