Reuse six imports
diff --git a/OpenSSL/SSL.py b/OpenSSL/SSL.py
index eb26e76..01d654f 100644
--- a/OpenSSL/SSL.py
+++ b/OpenSSL/SSL.py
@@ -1,4 +1,3 @@
-import six
from warnings import warn
from sys import platform
from functools import wraps, partial
@@ -8,6 +7,7 @@
from six import text_type as _text_type
from six import integer_types as integer_types
+from six import PY2 as _PY2
from OpenSSL._util import (
ffi as _ffi,
@@ -315,7 +315,7 @@
# Backward compatibility
if isinstance(cafile, _text_type):
- if six.PY2:
+ if _PY2:
warn("unicode in cafile is no longer accepted, use bytes", DeprecationWarning)
else:
warn("str in cafile is no longer accepted, use bytes", DeprecationWarning)
@@ -984,7 +984,7 @@
# Backward compatibility
if isinstance(buf, _text_type):
- if six.PY2:
+ if _PY2:
warn("unicode in buf is no longer accepted, use bytes", DeprecationWarning)
else:
warn("str in buf is no longer accepted, use bytes", DeprecationWarning)
@@ -1017,7 +1017,7 @@
# Backward compatibility
if isinstance(buf, _text_type):
- if six.PY2:
+ if _PY2:
warn("unicode in buf is no longer accepted, use bytes", DeprecationWarning)
else:
warn("str in buf is no longer accepted, use bytes", DeprecationWarning)
@@ -1111,7 +1111,7 @@
# Backward compatibility
if isinstance(buf, _text_type):
- if six.PY2:
+ if _PY2:
warn("unicode in buf is no longer accepted, use bytes", DeprecationWarning)
else:
warn("str in buf is no longer accepted, use bytes", DeprecationWarning)
diff --git a/OpenSSL/crypto.py b/OpenSSL/crypto.py
index cc99105..0909e6e 100644
--- a/OpenSSL/crypto.py
+++ b/OpenSSL/crypto.py
@@ -1,4 +1,3 @@
-import six
from warnings import warn
from time import time
from base64 import b16encode
@@ -1957,10 +1956,10 @@
# Backward compatibility
if isinstance(passphrase, _text_type):
- if six.PY2:
- warn("unicode in passphrase is no longer accepted, use bytes", DeprecationWarning)
- else:
+ if _PY3:
warn("str in passphrase is no longer accepted, use bytes", DeprecationWarning)
+ else:
+ warn("unicode in passphrase is no longer accepted, use bytes", DeprecationWarning)
passphrase = passphrase.encode('utf-8')
if self._cacerts is None:
@@ -2263,10 +2262,10 @@
# Backward compatibility
if isinstance(data, _text_type):
- if six.PY2:
- warn("unicode in passphrase is no longer accepted, use bytes", DeprecationWarning)
- else:
+ if _PY3:
warn("str in passphrase is no longer accepted, use bytes", DeprecationWarning)
+ else:
+ warn("unicode in passphrase is no longer accepted, use bytes", DeprecationWarning)
data = data.encode('utf-8')
digest_obj = _lib.EVP_get_digestbyname(_byte_string(digest))
@@ -2306,10 +2305,10 @@
# Backward compatibility
if isinstance(data, _text_type):
- if six.PY2:
- warn("unicode in passphrase is no longer accepted, use bytes", DeprecationWarning)
- else:
+ if _PY3:
warn("str in passphrase is no longer accepted, use bytes", DeprecationWarning)
+ else:
+ warn("unicode in passphrase is no longer accepted, use bytes", DeprecationWarning)
data = data.encode('utf-8')
digest_obj = _lib.EVP_get_digestbyname(_byte_string(digest))
@@ -2406,10 +2405,10 @@
# Backward compatibility
if isinstance(passphrase, _text_type):
- if six.PY2:
- warn("unicode in passphrase is no longer accepted, use bytes", DeprecationWarning)
- else:
+ if _PY3:
warn("str in passphrase is no longer accepted, use bytes", DeprecationWarning)
+ else:
+ warn("unicode in passphrase is no longer accepted, use bytes", DeprecationWarning)
passphrase = passphrase.encode('utf-8')
if isinstance(buffer, _text_type):