Skip to content

Commit 32b3387

Browse files
authored
bpo-47061: use warnings._deprecated() with asynchat, asyncore, and smtpd (GH-32350)
1 parent 59a99ae commit 32b3387

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

Lib/asynchat.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@
4848
import asyncore
4949
from collections import deque
5050

51-
from warnings import warn
52-
warn(
53-
'The asynchat module is deprecated and will be removed in Python 3.12. '
54-
'The recommended replacement is asyncio',
55-
DeprecationWarning,
56-
stacklevel=2)
51+
from warnings import _deprecated
52+
53+
_DEPRECATION_MSG = ('The {name} module is deprecated and will be removed in '
54+
'Python {remove}. The recommended replacement is asyncio')
55+
_deprecated(__name__, _DEPRECATION_MSG, remove=(3, 12))
5756

5857

5958

Lib/asyncore.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,9 @@
5757
ENOTCONN, ESHUTDOWN, EISCONN, EBADF, ECONNABORTED, EPIPE, EAGAIN, \
5858
errorcode
5959

60-
warnings.warn(
61-
'The asyncore module is deprecated and will be removed in Python 3.12. '
62-
'The recommended replacement is asyncio',
63-
DeprecationWarning,
64-
stacklevel=2)
60+
_DEPRECATION_MSG = ('The {name} module is deprecated and will be removed in '
61+
'Python {remove}. The recommended replacement is asyncio')
62+
warnings._deprecated(__name__, _DEPRECATION_MSG, remove=(3, 12))
6563

6664

6765
_DISCONNECTED = frozenset({ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE,

Lib/smtpd.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,18 @@
7777
import time
7878
import socket
7979
import collections
80-
from warnings import warn
80+
from warnings import _deprecated, warn
8181
from email._header_value_parser import get_addr_spec, get_angle_addr
8282

8383
__all__ = [
8484
"SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy",
8585
]
8686

87-
warn(
88-
'The smtpd module is deprecated and unmaintained and will be removed '
89-
'in Python 3.12. Please see aiosmtpd '
90-
'(https://aiosmtpd.readthedocs.io/) for the recommended replacement.',
91-
DeprecationWarning,
92-
stacklevel=2)
87+
_DEPRECATION_MSG = ('The {name} module is deprecated and unmaintained and will '
88+
'be removed in Python {remove}. Please see aiosmtpd '
89+
'(https://aiosmtpd.readthedocs.io/) for the recommended '
90+
'replacement.')
91+
_deprecated(__name__, _DEPRECATION_MSG, remove=(3, 12))
9392

9493

9594
# These are imported after the above warning so that users get the correct

0 commit comments

Comments
 (0)