]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-47061: use `warnings._deprecated()` with asynchat, asyncore, and smtpd (GH-32350)
authorBrett Cannon <brett@python.org>
Wed, 6 Apr 2022 18:22:39 +0000 (11:22 -0700)
committerGitHub <noreply@github.com>
Wed, 6 Apr 2022 18:22:39 +0000 (11:22 -0700)
Lib/asynchat.py
Lib/asyncore.py
Lib/smtpd.py

index e081e67c75acb01332bee52dcc05e81eac34d436..bed797e989e13665eca74c0be5baf527b669a6ef 100644 (file)
@@ -48,12 +48,11 @@ you - by calling your self.found_terminator() method.
 import asyncore
 from collections import deque
 
-from warnings import warn
-warn(
-    'The asynchat module is deprecated and will be removed in Python 3.12. '
-    'The recommended replacement is asyncio',
-    DeprecationWarning,
-    stacklevel=2)
+from warnings import _deprecated
+
+_DEPRECATION_MSG = ('The {name} module is deprecated and will be removed in '
+                    'Python {remove}. The recommended replacement is asyncio')
+_deprecated(__name__, _DEPRECATION_MSG, remove=(3, 12))
 
 
 
index a360d404395e5b1623b1b1393839b1174afd1865..57c86871f3dcf09afc2bfc5e84be4c54b6b6e740 100644 (file)
@@ -57,11 +57,9 @@ from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, \
      ENOTCONN, ESHUTDOWN, EISCONN, EBADF, ECONNABORTED, EPIPE, EAGAIN, \
      errorcode
 
-warnings.warn(
-    'The asyncore module is deprecated and will be removed in Python 3.12. '
-    'The recommended replacement is asyncio',
-    DeprecationWarning,
-    stacklevel=2)
+_DEPRECATION_MSG = ('The {name} module is deprecated and will be removed in '
+                    'Python {remove}. The recommended replacement is asyncio')
+warnings._deprecated(__name__, _DEPRECATION_MSG, remove=(3, 12))
 
 
 _DISCONNECTED = frozenset({ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE,
index eeda155b920f7526c4779525a5cc60d5c0416fdd..b23579f120716fe7a356a3510d93bd1cdd892a77 100755 (executable)
@@ -77,19 +77,18 @@ import getopt
 import time
 import socket
 import collections
-from warnings import warn
+from warnings import _deprecated, warn
 from email._header_value_parser import get_addr_spec, get_angle_addr
 
 __all__ = [
     "SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy",
 ]
 
-warn(
-    'The smtpd module is deprecated and unmaintained and will be removed '
-    'in Python 3.12.  Please see aiosmtpd '
-    '(https://aiosmtpd.readthedocs.io/) for the recommended replacement.',
-    DeprecationWarning,
-    stacklevel=2)
+_DEPRECATION_MSG = ('The {name} module is deprecated and unmaintained and will '
+                    'be removed in Python {remove}.  Please see aiosmtpd '
+                    '(https://aiosmtpd.readthedocs.io/) for the recommended '
+                    'replacement.')
+_deprecated(__name__, _DEPRECATION_MSG, remove=(3, 12))
 
 
 # These are imported after the above warning so that users get the correct