summaryrefslogtreecommitdiff
path: root/src/OpenSSL/_util.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2021-12-19 16:00:32 -0500
committerGitHub <noreply@github.com>2021-12-20 05:00:32 +0800
commitde073c62c809b2cd67315c5b3ae99ef38fcd26a9 (patch)
tree480a3c4a067f4b8401b39cc1fe4d543a20d7eb33 /src/OpenSSL/_util.py
parentc175f152a4b4c02f166035c915a847c3281b1e8c (diff)
downloadpyopenssl-de073c62c809b2cd67315c5b3ae99ef38fcd26a9.tar.gz
Remove native, it's behavior is confusing (#1069)
Instead just decode stuff at the call-sites -- 100% of which were passing bytes
Diffstat (limited to 'src/OpenSSL/_util.py')
-rw-r--r--src/OpenSSL/_util.py19
1 files changed, 1 insertions, 18 deletions
diff --git a/src/OpenSSL/_util.py b/src/OpenSSL/_util.py
index 6bd43a5..028989d 100644
--- a/src/OpenSSL/_util.py
+++ b/src/OpenSSL/_util.py
@@ -26,7 +26,7 @@ def text(charp):
"""
if not charp:
return ""
- return native(ffi.string(charp))
+ return ffi.string(charp).decode("utf-8")
def exception_from_error_queue(exception_type):
@@ -71,23 +71,6 @@ def make_assert(error):
return openssl_assert
-def native(s):
- """
- Convert :py:class:`bytes` or :py:class:`unicode` to the native
- :py:class:`str` type, using UTF-8 encoding if conversion is necessary.
-
- :raise UnicodeError: The input string is not UTF-8 decodeable.
-
- :raise TypeError: The input is neither :py:class:`bytes` nor
- :py:class:`unicode`.
- """
- if not isinstance(s, (bytes, str)):
- raise TypeError("%r is neither bytes nor unicode" % s)
- if isinstance(s, bytes):
- return s.decode("utf-8")
- return s
-
-
def path_string(s):
"""
Convert a Python path to a :py:class:`bytes` string identifying the same