diff options
author | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2015-04-13 20:49:50 -0400 |
---|---|---|
committer | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2015-04-13 20:49:50 -0400 |
commit | 39a8d590ffb7c8adaa641f182ac7571ba30936a9 (patch) | |
tree | 0277d7a2ca2c135f906c36853cc494051186244e | |
parent | 93477426f7931b6b36b3ec01922250b385fe808f (diff) | |
download | pyopenssl-39a8d590ffb7c8adaa641f182ac7571ba30936a9.tar.gz |
Rename warn_text to something a little more descriptive.
-rw-r--r-- | OpenSSL/SSL.py | 8 | ||||
-rw-r--r-- | OpenSSL/_util.py | 2 | ||||
-rw-r--r-- | OpenSSL/crypto.py | 11 |
3 files changed, 11 insertions, 10 deletions
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 @@ from OpenSSL._util import ( 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 @@ class Connection(object): :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 @@ class Connection(object): 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 @@ class Connection(object): :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_WARNING = ( 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 @@ from OpenSSL._util import ( 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 @@ class PKCS12(object): :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 @@ def sign(pkey, data, digest): :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 @@ def verify(cert, signature, data, digest): :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 @@ def load_pkcs12(buffer, passphrase=None): :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") |