Fix for Python 4 (#862)
* Fix for Python 4
* Fix for Python 4
diff --git a/src/OpenSSL/_util.py b/src/OpenSSL/_util.py
index cf8b888..cdcacc8 100644
--- a/src/OpenSSL/_util.py
+++ b/src/OpenSSL/_util.py
@@ -1,7 +1,7 @@
import sys
import warnings
-from six import PY3, binary_type, text_type
+from six import PY2, binary_type, text_type
from cryptography.hazmat.bindings.openssl.binding import Binding
@@ -81,12 +81,12 @@
"""
if not isinstance(s, (binary_type, text_type)):
raise TypeError("%r is neither bytes nor unicode" % s)
- if PY3:
- if isinstance(s, binary_type):
- return s.decode("utf-8")
- else:
+ if PY2:
if isinstance(s, text_type):
return s.encode("utf-8")
+ else:
+ if isinstance(s, binary_type):
+ return s.decode("utf-8")
return s
@@ -107,12 +107,12 @@
raise TypeError("Path must be represented as bytes or unicode string")
-if PY3:
- def byte_string(s):
- return s.encode("charmap")
-else:
+if PY2:
def byte_string(s):
return s
+else:
+ def byte_string(s):
+ return s.encode("charmap")
# A marker object to observe whether some optional arguments are passed any