Skip to content

Commit 8b85cfd

Browse files
authored
Rename path_string to path_bytes since that's what it actually does (#1067)
1 parent de073c6 commit 8b85cfd

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/OpenSSL/SSL.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ffi as _ffi,
1313
lib as _lib,
1414
make_assert as _make_assert,
15-
path_string as _path_string,
15+
path_bytes as _path_bytes,
1616
text_to_bytes_and_warn as _text_to_bytes_and_warn,
1717
no_zero_allocator as _no_zero_allocator,
1818
)
@@ -781,12 +781,12 @@ def load_verify_locations(self, cafile, capath=None):
781781
if cafile is None:
782782
cafile = _ffi.NULL
783783
else:
784-
cafile = _path_string(cafile)
784+
cafile = _path_bytes(cafile)
785785

786786
if capath is None:
787787
capath = _ffi.NULL
788788
else:
789-
capath = _path_string(capath)
789+
capath = _path_bytes(capath)
790790

791791
load_result = _lib.SSL_CTX_load_verify_locations(
792792
self._context, cafile, capath
@@ -920,7 +920,7 @@ def use_certificate_chain_file(self, certfile):
920920
921921
:return: None
922922
"""
923-
certfile = _path_string(certfile)
923+
certfile = _path_bytes(certfile)
924924

925925
result = _lib.SSL_CTX_use_certificate_chain_file(
926926
self._context, certfile
@@ -940,7 +940,7 @@ def use_certificate_file(self, certfile, filetype=FILETYPE_PEM):
940940
941941
:return: None
942942
"""
943-
certfile = _path_string(certfile)
943+
certfile = _path_bytes(certfile)
944944
if not isinstance(filetype, int):
945945
raise TypeError("filetype must be an integer")
946946

@@ -998,7 +998,7 @@ def use_privatekey_file(self, keyfile, filetype=_UNSPECIFIED):
998998
999999
:return: None
10001000
"""
1001-
keyfile = _path_string(keyfile)
1001+
keyfile = _path_bytes(keyfile)
10021002

10031003
if filetype is _UNSPECIFIED:
10041004
filetype = FILETYPE_PEM
@@ -1169,7 +1169,7 @@ def load_tmp_dh(self, dhfile):
11691169
11701170
:return: None
11711171
"""
1172-
dhfile = _path_string(dhfile)
1172+
dhfile = _path_bytes(dhfile)
11731173

11741174
bio = _lib.BIO_new_file(dhfile, b"r")
11751175
if bio == _ffi.NULL:

src/OpenSSL/_util.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,21 @@ def openssl_assert(ok):
7171
return openssl_assert
7272

7373

74-
def path_string(s):
74+
def path_bytes(s):
7575
"""
76-
Convert a Python path to a :py:class:`bytes` string identifying the same
77-
path and which can be passed into an OpenSSL API accepting a filename.
76+
Convert a Python path to a :py:class:`bytes` for the path which can be
77+
passed into an OpenSSL API accepting a filename.
7878
7979
:param s: A path (valid for os.fspath).
8080
8181
:return: An instance of :py:class:`bytes`.
8282
"""
83-
strpath = os.fspath(s) # returns str or bytes
83+
b = os.fspath(s)
8484

85-
if isinstance(strpath, str):
86-
return strpath.encode(sys.getfilesystemencoding())
85+
if isinstance(b, str):
86+
return b.encode(sys.getfilesystemencoding())
8787
else:
88-
return strpath
88+
return b
8989

9090

9191
def byte_string(s):

src/OpenSSL/crypto.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
lib as _lib,
1414
exception_from_error_queue as _exception_from_error_queue,
1515
byte_string as _byte_string,
16-
path_string as _path_string,
16+
path_bytes as _path_bytes,
1717
UNSPECIFIED as _UNSPECIFIED,
1818
text_to_bytes_and_warn as _text_to_bytes_and_warn,
1919
make_assert as _make_assert,
@@ -1728,12 +1728,12 @@ def load_locations(self, cafile, capath=None):
17281728
if cafile is None:
17291729
cafile = _ffi.NULL
17301730
else:
1731-
cafile = _path_string(cafile)
1731+
cafile = _path_bytes(cafile)
17321732

17331733
if capath is None:
17341734
capath = _ffi.NULL
17351735
else:
1736-
capath = _path_string(capath)
1736+
capath = _path_bytes(capath)
17371737

17381738
load_result = _lib.X509_STORE_load_locations(
17391739
self._store, cafile, capath

0 commit comments

Comments
 (0)