From: Brett Cannon Date: Wed, 6 Apr 2022 18:22:39 +0000 (-0700) Subject: bpo-47061: use `warnings._deprecated()` with asynchat, asyncore, and smtpd (GH-32350) X-Git-Tag: v3.11.0b1~439 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=32b33879c2e19cde735c1971b06869976200e1d8;p=thirdparty%2FPython%2Fcpython.git bpo-47061: use `warnings._deprecated()` with asynchat, asyncore, and smtpd (GH-32350) --- diff --git a/Lib/asynchat.py b/Lib/asynchat.py index e081e67c75ac..bed797e989e1 100644 --- a/Lib/asynchat.py +++ b/Lib/asynchat.py @@ -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)) diff --git a/Lib/asyncore.py b/Lib/asyncore.py index a360d404395e..57c86871f3dc 100644 --- a/Lib/asyncore.py +++ b/Lib/asyncore.py @@ -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, diff --git a/Lib/smtpd.py b/Lib/smtpd.py index eeda155b920f..b23579f12071 100755 --- a/Lib/smtpd.py +++ b/Lib/smtpd.py @@ -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