mirror of
https://github.com/python/cpython.git
synced 2025-09-16 21:56:14 +00:00
[3.10] bpo-44498: Issue a deprecation warning on asynchat, asyncore and smtpd import (GH-26882) (GH-26904)
* Issue a deprecation warning on smtpd import
* Also issue DeprecationWarnings for asynchat and asyncore
* Fix some tests
* test___all__ requires the word 'module' or 'package' in the deprecation
warning text, so add those to smtpd, asynchat, and asyncore.
* In test_support, use pprint now instead of asyncore as the landmark.
* Add What's New
* Use ..deprecated::
* Use ..deprecated::
* Update Lib/smtpd.py
Co-authored-by: Miro Hrončok <miro@hroncok.cz>
* Update Doc/library/smtpd.rst
Co-authored-by: Miro Hrončok <miro@hroncok.cz>
* Import async{hat,ore} after the DeprecationWarning for this module
Co-authored-by: Miro Hrončok <miro@hroncok.cz>
(cherry picked from commit 8488b85c63
)
Co-authored-by: Barry Warsaw <barry@python.org>
Automerge-Triggered-By: GH:warsaw
This commit is contained in:
parent
11f1a30cdb
commit
a80a38ee9a
6 changed files with 40 additions and 9 deletions
|
@ -13,11 +13,10 @@
|
||||||
|
|
||||||
This module offers several classes to implement SMTP (email) servers.
|
This module offers several classes to implement SMTP (email) servers.
|
||||||
|
|
||||||
.. seealso::
|
.. deprecated:: 3.6
|
||||||
|
The `aiosmtpd <https://aiosmtpd.readthedocs.io/>`_ package is a recommended
|
||||||
The `aiosmtpd <http://aiosmtpd.readthedocs.io/>`_ package is a recommended
|
|
||||||
replacement for this module. It is based on :mod:`asyncio` and provides a
|
replacement for this module. It is based on :mod:`asyncio` and provides a
|
||||||
more straightforward API. :mod:`smtpd` should be considered deprecated.
|
more straightforward API.
|
||||||
|
|
||||||
Several server implementations are present; one is a generic
|
Several server implementations are present; one is a generic
|
||||||
do-nothing implementation, which can be overridden, while the other two offer
|
do-nothing implementation, which can be overridden, while the other two offer
|
||||||
|
|
|
@ -883,6 +883,12 @@ The :meth:`~array.array.index` method of :class:`array.array` now has
|
||||||
optional *start* and *stop* parameters.
|
optional *start* and *stop* parameters.
|
||||||
(Contributed by Anders Lorentsen and Zackery Spytz in :issue:`31956`.)
|
(Contributed by Anders Lorentsen and Zackery Spytz in :issue:`31956`.)
|
||||||
|
|
||||||
|
asynchat, asyncore, smtpd
|
||||||
|
-------------------------
|
||||||
|
These modules have been marked as deprecated in their module documentation
|
||||||
|
since Python 3.6. An import-time :class:`DeprecationWarning` has now been
|
||||||
|
added to all three of these modules.
|
||||||
|
|
||||||
base64
|
base64
|
||||||
------
|
------
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,14 @@ you - by calling your self.found_terminator() method.
|
||||||
import asyncore
|
import asyncore
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
||||||
|
from warnings import warn
|
||||||
|
warn(
|
||||||
|
'The asynchat module is deprecated. '
|
||||||
|
'The recommended replacement is asyncio',
|
||||||
|
DeprecationWarning,
|
||||||
|
stacklevel=2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class async_chat(asyncore.dispatcher):
|
class async_chat(asyncore.dispatcher):
|
||||||
"""This is an abstract class. You must derive from this class, and add
|
"""This is an abstract class. You must derive from this class, and add
|
||||||
|
|
|
@ -57,6 +57,13 @@ from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, \
|
||||||
ENOTCONN, ESHUTDOWN, EISCONN, EBADF, ECONNABORTED, EPIPE, EAGAIN, \
|
ENOTCONN, ESHUTDOWN, EISCONN, EBADF, ECONNABORTED, EPIPE, EAGAIN, \
|
||||||
errorcode
|
errorcode
|
||||||
|
|
||||||
|
warnings.warn(
|
||||||
|
'The asyncore module is deprecated. '
|
||||||
|
'The recommended replacement is asyncio',
|
||||||
|
DeprecationWarning,
|
||||||
|
stacklevel=2)
|
||||||
|
|
||||||
|
|
||||||
_DISCONNECTED = frozenset({ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE,
|
_DISCONNECTED = frozenset({ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE,
|
||||||
EBADF})
|
EBADF})
|
||||||
|
|
||||||
|
|
15
Lib/smtpd.py
15
Lib/smtpd.py
|
@ -83,8 +83,6 @@ import errno
|
||||||
import getopt
|
import getopt
|
||||||
import time
|
import time
|
||||||
import socket
|
import socket
|
||||||
import asyncore
|
|
||||||
import asynchat
|
|
||||||
import collections
|
import collections
|
||||||
from warnings import warn
|
from warnings import warn
|
||||||
from email._header_value_parser import get_addr_spec, get_angle_addr
|
from email._header_value_parser import get_addr_spec, get_angle_addr
|
||||||
|
@ -94,6 +92,19 @@ __all__ = [
|
||||||
"MailmanProxy",
|
"MailmanProxy",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
warn(
|
||||||
|
'The smtpd module is deprecated and unmaintained. Please see aiosmtpd '
|
||||||
|
'(https://aiosmtpd.readthedocs.io/) for the recommended replacement.',
|
||||||
|
DeprecationWarning,
|
||||||
|
stacklevel=2)
|
||||||
|
|
||||||
|
|
||||||
|
# These are imported after the above warning so that users get the correct
|
||||||
|
# deprecation warning.
|
||||||
|
import asyncore
|
||||||
|
import asynchat
|
||||||
|
|
||||||
|
|
||||||
program = sys.argv[0]
|
program = sys.argv[0]
|
||||||
__version__ = 'Python SMTP proxy version 0.3'
|
__version__ = 'Python SMTP proxy version 0.3'
|
||||||
|
|
||||||
|
|
|
@ -292,8 +292,8 @@ class TestSupport(unittest.TestCase):
|
||||||
|
|
||||||
def test_CleanImport(self):
|
def test_CleanImport(self):
|
||||||
import importlib
|
import importlib
|
||||||
with import_helper.CleanImport("asyncore"):
|
with import_helper.CleanImport("pprint"):
|
||||||
importlib.import_module("asyncore")
|
importlib.import_module("pprint")
|
||||||
|
|
||||||
def test_DirsOnSysPath(self):
|
def test_DirsOnSysPath(self):
|
||||||
with import_helper.DirsOnSysPath('foo', 'bar'):
|
with import_helper.DirsOnSysPath('foo', 'bar'):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue