summaryrefslogtreecommitdiff
path: root/src/OpenSSL/_util.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2021-10-04 16:22:33 +0800
committerGitHub <noreply@github.com>2021-10-04 01:22:33 -0700
commita42ec20880d44150022b8cd9c852fff6cca2dcaa (patch)
tree8cf9b1fdbd21fd50ebb07d9cf684bbfb40a7e764 /src/OpenSSL/_util.py
parent91d670ff9353e1040ff87e369f3098167bd86ee0 (diff)
downloadpyopenssl-a42ec20880d44150022b8cd9c852fff6cca2dcaa.tar.gz
py27 going, going, gone (#1047)
* py27 going, going, gone * black * more black * ok then * forgot to remove pypy2
Diffstat (limited to 'src/OpenSSL/_util.py')
-rw-r--r--src/OpenSSL/_util.py32
1 files changed, 8 insertions, 24 deletions
diff --git a/src/OpenSSL/_util.py b/src/OpenSSL/_util.py
index 53c0b9e..8235f5b 100644
--- a/src/OpenSSL/_util.py
+++ b/src/OpenSSL/_util.py
@@ -1,8 +1,6 @@
import sys
import warnings
-from six import PY2, text_type
-
from cryptography.hazmat.bindings.openssl.binding import Binding
@@ -83,14 +81,10 @@ def native(s):
:raise TypeError: The input is neither :py:class:`bytes` nor
:py:class:`unicode`.
"""
- if not isinstance(s, (bytes, text_type)):
+ if not isinstance(s, (bytes, str)):
raise TypeError("%r is neither bytes nor unicode" % s)
- if PY2:
- if isinstance(s, text_type):
- return s.encode("utf-8")
- else:
- if isinstance(s, bytes):
- return s.decode("utf-8")
+ if isinstance(s, bytes):
+ return s.decode("utf-8")
return s
@@ -105,31 +99,21 @@ def path_string(s):
"""
if isinstance(s, bytes):
return s
- elif isinstance(s, text_type):
+ elif isinstance(s, str):
return s.encode(sys.getfilesystemencoding())
else:
raise TypeError("Path must be represented as bytes or unicode string")
-if PY2:
-
- def byte_string(s):
- return s
-
-
-else:
-
- def byte_string(s):
- return s.encode("charmap")
+def byte_string(s):
+ return s.encode("charmap")
# A marker object to observe whether some optional arguments are passed any
# value or not.
UNSPECIFIED = object()
-_TEXT_WARNING = (
- text_type.__name__ + " for {0} is no longer accepted, use bytes"
-)
+_TEXT_WARNING = "str for {0} is no longer accepted, use bytes"
def text_to_bytes_and_warn(label, obj):
@@ -145,7 +129,7 @@ def text_to_bytes_and_warn(label, obj):
UTF-8 encoding of that text is returned. Otherwise, ``obj`` itself is
returned.
"""
- if isinstance(obj, text_type):
+ if isinstance(obj, str):
warnings.warn(
_TEXT_WARNING.format(label),
category=DeprecationWarning,