diff options
author | Christian Heimes <christian@python.org> | 2021-06-11 07:15:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-11 07:15:48 (GMT) |
commit | e26014f1c47d26d6097ff7a0f25384bfbde714a9 (patch) | |
tree | 6fbe678ee47df13f0a8da945e8735fee6676656c /Lib/ssl.py | |
parent | c4955e2c4f9abafd33bbe4904a82f7962333a7d6 (diff) | |
download | cpython-e26014f1c47d26d6097ff7a0f25384bfbde714a9.zip cpython-e26014f1c47d26d6097ff7a0f25384bfbde714a9.tar.gz cpython-e26014f1c47d26d6097ff7a0f25384bfbde714a9.tar.bz2 |
bpo-44362: ssl: improve deprecation warnings and docs (GH-26646)
Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'Lib/ssl.py')
-rw-r--r-- | Lib/ssl.py | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -94,7 +94,7 @@ import sys import os from collections import namedtuple from enum import Enum as _Enum, IntEnum as _IntEnum, IntFlag as _IntFlag -from enum import _simple_enum, _test_simple_enum +from enum import _simple_enum import _ssl # if we can't import it, let the error propagate @@ -387,7 +387,7 @@ def match_hostname(cert, hostname): returns nothing. """ warnings.warn( - "ssl module: match_hostname() is deprecated", + "ssl.match_hostname() is deprecated", category=DeprecationWarning, stacklevel=2 ) @@ -492,8 +492,7 @@ class SSLContext(_SSLContext): def __new__(cls, protocol=None, *args, **kwargs): if protocol is None: warnings.warn( - "ssl module: " - "SSLContext() without protocol argument is deprecated.", + "ssl.SSLContext() without protocol argument is deprecated.", category=DeprecationWarning, stacklevel=2 ) @@ -536,7 +535,11 @@ class SSLContext(_SSLContext): ) def set_npn_protocols(self, npn_protocols): - warnings.warn("NPN is deprecated, use ALPN instead", stacklevel=2) + warnings.warn( + "ssl NPN is deprecated, use ALPN instead", + DeprecationWarning, + stacklevel=2 + ) protos = bytearray() for protocol in npn_protocols: b = bytes(protocol, 'ascii') @@ -940,7 +943,9 @@ class SSLObject: if a next protocol was not negotiated or if NPN is not supported by one of the peers.""" warnings.warn( - "ssl module: NPN is deprecated, use ALPN instead", stacklevel=2 + "ssl NPN is deprecated, use ALPN instead", + DeprecationWarning, + stacklevel=2 ) def selected_alpn_protocol(self): @@ -1157,7 +1162,9 @@ class SSLSocket(socket): def selected_npn_protocol(self): self._checkClosed() warnings.warn( - "ssl module: NPN is deprecated, use ALPN instead", stacklevel=2 + "ssl NPN is deprecated, use ALPN instead", + DeprecationWarning, + stacklevel=2 ) return None @@ -1419,7 +1426,7 @@ def wrap_socket(sock, keyfile=None, certfile=None, suppress_ragged_eofs=True, ciphers=None): warnings.warn( - "ssl module: wrap_socket is deprecated, use SSLContext.wrap_socket()", + "ssl.wrap_socket() is deprecated, use SSLContext.wrap_socket()", category=DeprecationWarning, stacklevel=2 ) |