Rename warn_text to something a little more descriptive.
diff --git a/OpenSSL/SSL.py b/OpenSSL/SSL.py
index 36ef14a..54092c5 100644
--- a/OpenSSL/SSL.py
+++ b/OpenSSL/SSL.py
@@ -13,7 +13,7 @@
lib as _lib,
exception_from_error_queue as _exception_from_error_queue,
native as _native,
- warn_text as _warn_text,
+ text_to_bytes_and_warn as _text_to_bytes_and_warn,
path_string as _path_string,
)
@@ -1127,7 +1127,7 @@
:return: The number of bytes written
"""
# Backward compatibility
- buf = _warn_text("buf", buf)
+ buf = _text_to_bytes_and_warn("buf", buf)
if isinstance(buf, _memoryview):
buf = buf.tobytes()
@@ -1153,7 +1153,7 @@
API, the value is ignored
:return: The number of bytes written
"""
- buf = _warn_text("buf", buf)
+ buf = _text_to_bytes_and_warn("buf", buf)
if isinstance(buf, _memoryview):
buf = buf.tobytes()
@@ -1279,7 +1279,7 @@
:param buf: The string to put into the memory BIO.
:return: The number of bytes written
"""
- buf = _warn_text("buf", buf)
+ buf = _text_to_bytes_and_warn("buf", buf)
if self._into_ssl is None:
raise TypeError("Connection sock was not None")
diff --git a/OpenSSL/_util.py b/OpenSSL/_util.py
index 9909250..8d59252 100644
--- a/OpenSSL/_util.py
+++ b/OpenSSL/_util.py
@@ -99,7 +99,7 @@
text_type.__name__ + " for {0} is no longer accepted, use bytes"
)
-def warn_text(label, obj):
+def text_to_bytes_and_warn(label, obj):
"""
If ``obj`` is text, emit a warning that it should be bytes instead and try
to convert it to bytes automatically.
diff --git a/OpenSSL/crypto.py b/OpenSSL/crypto.py
index 6013ca3..f9e189c 100644
--- a/OpenSSL/crypto.py
+++ b/OpenSSL/crypto.py
@@ -14,7 +14,8 @@
exception_from_error_queue as _exception_from_error_queue,
byte_string as _byte_string,
native as _native,
- warn_text as _warn_text)
+ text_to_bytes_and_warn as _text_to_bytes_and_warn,
+)
FILETYPE_PEM = _lib.SSL_FILETYPE_PEM
FILETYPE_ASN1 = _lib.SSL_FILETYPE_ASN1
@@ -2075,7 +2076,7 @@
:return: The string containing the PKCS12
"""
- passphrase = _warn_text("passphrase", passphrase)
+ passphrase = _text_to_bytes_and_warn("passphrase", passphrase)
if self._cacerts is None:
cacerts = _ffi.NULL
@@ -2374,7 +2375,7 @@
:param digest: message digest to use
:return: signature
"""
- data = _warn_text("data", data)
+ data = _text_to_bytes_and_warn("data", data)
digest_obj = _lib.EVP_get_digestbyname(_byte_string(digest))
if digest_obj == _ffi.NULL:
@@ -2410,7 +2411,7 @@
:param digest: message digest to use
:return: None if the signature is correct, raise exception otherwise
"""
- data = _warn_text("data", data)
+ data = _text_to_bytes_and_warn("data", data)
digest_obj = _lib.EVP_get_digestbyname(_byte_string(digest))
if digest_obj == _ffi.NULL:
@@ -2502,7 +2503,7 @@
:param passphrase: (Optional) The password to decrypt the PKCS12 lump
:returns: The PKCS12 object
"""
- passphrase = _warn_text("passphrase", passphrase)
+ passphrase = _text_to_bytes_and_warn("passphrase", passphrase)
if isinstance(buffer, _text_type):
buffer = buffer.encode("ascii")