summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2021-12-19 16:12:59 -0500
committerGitHub <noreply@github.com>2021-12-20 05:12:59 +0800
commit8b85cfd411af794e77e9be645316607063234975 (patch)
tree3cc505d2bd8e2099b7040139550f242557f81176
parentde073c62c809b2cd67315c5b3ae99ef38fcd26a9 (diff)
downloadpyopenssl-8b85cfd411af794e77e9be645316607063234975.tar.gz
Rename path_string to path_bytes since that's what it actually does (#1067)
-rw-r--r--src/OpenSSL/SSL.py14
-rw-r--r--src/OpenSSL/_util.py14
-rw-r--r--src/OpenSSL/crypto.py6
3 files changed, 17 insertions, 17 deletions
diff --git a/src/OpenSSL/SSL.py b/src/OpenSSL/SSL.py
index 5f655f4..d4eb243 100644
--- a/src/OpenSSL/SSL.py
+++ b/src/OpenSSL/SSL.py
@@ -12,7 +12,7 @@ from OpenSSL._util import (
ffi as _ffi,
lib as _lib,
make_assert as _make_assert,
- path_string as _path_string,
+ path_bytes as _path_bytes,
text_to_bytes_and_warn as _text_to_bytes_and_warn,
no_zero_allocator as _no_zero_allocator,
)
@@ -781,12 +781,12 @@ class Context(object):
if cafile is None:
cafile = _ffi.NULL
else:
- cafile = _path_string(cafile)
+ cafile = _path_bytes(cafile)
if capath is None:
capath = _ffi.NULL
else:
- capath = _path_string(capath)
+ capath = _path_bytes(capath)
load_result = _lib.SSL_CTX_load_verify_locations(
self._context, cafile, capath
@@ -920,7 +920,7 @@ class Context(object):
:return: None
"""
- certfile = _path_string(certfile)
+ certfile = _path_bytes(certfile)
result = _lib.SSL_CTX_use_certificate_chain_file(
self._context, certfile
@@ -940,7 +940,7 @@ class Context(object):
:return: None
"""
- certfile = _path_string(certfile)
+ certfile = _path_bytes(certfile)
if not isinstance(filetype, int):
raise TypeError("filetype must be an integer")
@@ -998,7 +998,7 @@ class Context(object):
:return: None
"""
- keyfile = _path_string(keyfile)
+ keyfile = _path_bytes(keyfile)
if filetype is _UNSPECIFIED:
filetype = FILETYPE_PEM
@@ -1169,7 +1169,7 @@ class Context(object):
:return: None
"""
- dhfile = _path_string(dhfile)
+ dhfile = _path_bytes(dhfile)
bio = _lib.BIO_new_file(dhfile, b"r")
if bio == _ffi.NULL:
diff --git a/src/OpenSSL/_util.py b/src/OpenSSL/_util.py
index 028989d..a3d5075 100644
--- a/src/OpenSSL/_util.py
+++ b/src/OpenSSL/_util.py
@@ -71,21 +71,21 @@ def make_assert(error):
return openssl_assert
-def path_string(s):
+def path_bytes(s):
"""
- Convert a Python path to a :py:class:`bytes` string identifying the same
- path and which can be passed into an OpenSSL API accepting a filename.
+ Convert a Python path to a :py:class:`bytes` for the path which can be
+ passed into an OpenSSL API accepting a filename.
:param s: A path (valid for os.fspath).
:return: An instance of :py:class:`bytes`.
"""
- strpath = os.fspath(s) # returns str or bytes
+ b = os.fspath(s)
- if isinstance(strpath, str):
- return strpath.encode(sys.getfilesystemencoding())
+ if isinstance(b, str):
+ return b.encode(sys.getfilesystemencoding())
else:
- return strpath
+ return b
def byte_string(s):
diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py
index 4c5d9f3..f6d90e1 100644
--- a/src/OpenSSL/crypto.py
+++ b/src/OpenSSL/crypto.py
@@ -13,7 +13,7 @@ from OpenSSL._util import (
lib as _lib,
exception_from_error_queue as _exception_from_error_queue,
byte_string as _byte_string,
- path_string as _path_string,
+ path_bytes as _path_bytes,
UNSPECIFIED as _UNSPECIFIED,
text_to_bytes_and_warn as _text_to_bytes_and_warn,
make_assert as _make_assert,
@@ -1728,12 +1728,12 @@ class X509Store(object):
if cafile is None:
cafile = _ffi.NULL
else:
- cafile = _path_string(cafile)
+ cafile = _path_bytes(cafile)
if capath is None:
capath = _ffi.NULL
else:
- capath = _path_string(capath)
+ capath = _path_bytes(capath)
load_result = _lib.X509_STORE_load_locations(
self._store, cafile, capath