summaryrefslogtreecommitdiff
path: root/src/OpenSSL/_util.py
diff options
context:
space:
mode:
authorHugo van Kemenade <hugovk@users.noreply.github.com>2019-08-30 00:39:35 +0300
committerAlex Gaynor <alex.gaynor@gmail.com>2019-08-29 17:39:35 -0400
commit60827f82d2ad7d2a94db093c2836595b46937c07 (patch)
tree45b1fbfe4a349858490d499fad72bc57abe002a2 /src/OpenSSL/_util.py
parenta18137385f574603535b29ad935f496d307ab3ae (diff)
downloadpyopenssl-60827f82d2ad7d2a94db093c2836595b46937c07.tar.gz
Fix for Python 4 (#862)
* Fix for Python 4 * Fix for Python 4
Diffstat (limited to 'src/OpenSSL/_util.py')
-rw-r--r--src/OpenSSL/_util.py16
1 files changed, 8 insertions, 8 deletions
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 @@ def native(s):
"""
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 @@ def path_string(s):
raise TypeError("Path must be represented as bytes or unicode string")
-if PY3:
+if PY2:
def byte_string(s):
- return s.encode("charmap")
+ return s
else:
def byte_string(s):
- return s
+ return s.encode("charmap")
# A marker object to observe whether some optional arguments are passed any