diff options
-rw-r--r-- | Doc/library/smtpd.rst | 9 | ||||
-rw-r--r-- | Doc/whatsnew/3.10.rst | 6 | ||||
-rw-r--r-- | Lib/asynchat.py | 8 | ||||
-rw-r--r-- | Lib/asyncore.py | 7 | ||||
-rwxr-xr-x | Lib/smtpd.py | 15 | ||||
-rw-r--r-- | Lib/test/test_support.py | 4 |
6 files changed, 40 insertions, 9 deletions
diff --git a/Doc/library/smtpd.rst b/Doc/library/smtpd.rst index ae66e7e..611411d 100644 --- a/Doc/library/smtpd.rst +++ b/Doc/library/smtpd.rst @@ -13,11 +13,10 @@ This module offers several classes to implement SMTP (email) servers. -.. seealso:: - - The `aiosmtpd <http://aiosmtpd.readthedocs.io/>`_ package is a recommended - replacement for this module. It is based on :mod:`asyncio` and provides a - more straightforward API. :mod:`smtpd` should be considered deprecated. +.. deprecated:: 3.6 + The `aiosmtpd <https://aiosmtpd.readthedocs.io/>`_ package is a recommended + replacement for this module. It is based on :mod:`asyncio` and provides a + more straightforward API. Several server implementations are present; one is a generic do-nothing implementation, which can be overridden, while the other two offer diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 63d1bd0..2a43d26 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -883,6 +883,12 @@ The :meth:`~array.array.index` method of :class:`array.array` now has optional *start* and *stop* parameters. (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 ------ diff --git a/Lib/asynchat.py b/Lib/asynchat.py index f4ba361..de26ffa 100644 --- a/Lib/asynchat.py +++ b/Lib/asynchat.py @@ -48,6 +48,14 @@ you - by calling your self.found_terminator() method. import asyncore 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): """This is an abstract class. You must derive from this class, and add diff --git a/Lib/asyncore.py b/Lib/asyncore.py index eeea488..b1eea4b 100644 --- a/Lib/asyncore.py +++ b/Lib/asyncore.py @@ -57,6 +57,13 @@ from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, \ ENOTCONN, ESHUTDOWN, EISCONN, EBADF, ECONNABORTED, EPIPE, EAGAIN, \ errorcode +warnings.warn( + 'The asyncore module is deprecated. ' + 'The recommended replacement is asyncio', + DeprecationWarning, + stacklevel=2) + + _DISCONNECTED = frozenset({ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE, EBADF}) diff --git a/Lib/smtpd.py b/Lib/smtpd.py index d053602..1cd004f 100755 --- a/Lib/smtpd.py +++ b/Lib/smtpd.py @@ -76,8 +76,6 @@ import errno import getopt import time import socket -import asyncore -import asynchat import collections from warnings import warn from email._header_value_parser import get_addr_spec, get_angle_addr @@ -86,6 +84,19 @@ __all__ = [ "SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy", ] +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] __version__ = 'Python SMTP proxy version 0.3' diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index 55d78b7..b1d3411 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -292,8 +292,8 @@ class TestSupport(unittest.TestCase): def test_CleanImport(self): import importlib - with import_helper.CleanImport("asyncore"): - importlib.import_module("asyncore") + with import_helper.CleanImport("pprint"): + importlib.import_module("pprint") def test_DirsOnSysPath(self): with import_helper.DirsOnSysPath('foo', 'bar'): |