From 60827f82d2ad7d2a94db093c2836595b46937c07 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Fri, 30 Aug 2019 00:39:35 +0300 Subject: Fix for Python 4 (#862) * Fix for Python 4 * Fix for Python 4 --- src/OpenSSL/_util.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/OpenSSL/_util.py') 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 -- cgit v1.2.1