Skip to content

Commit 56d16e8

Browse files
authored
gh-93243: Make smtpd private before porting its users (GH-93246)
gh-93243 This PR is required to reduce diffs of the following porting (no need to either maintain documentation and tests consistent with each porting step, or try to port everything and remove smtpd in a single PR). Automerge-Triggered-By: GH:warsaw
1 parent 29650fe commit 56d16e8

File tree

13 files changed

+23
-1312
lines changed

13 files changed

+23
-1312
lines changed

Doc/library/email.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,3 @@ Legacy API:
147147
Module :mod:`mailbox`
148148
Tools for creating, reading, and managing collections of messages on disk
149149
using a variety standard formats.
150-
151-
Module :mod:`smtpd`
152-
SMTP server framework (primarily useful for testing)

Doc/library/smtpd.rst

Lines changed: 0 additions & 268 deletions
This file was deleted.

Doc/library/superseded.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ backwards compatibility. They have been superseded by other modules.
2727
optparse.rst
2828
ossaudiodev.rst
2929
pipes.rst
30-
smtpd.rst
3130
sndhdr.rst
3231
spwd.rst
3332
sunau.rst

Doc/whatsnew/3.12.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,14 @@ Removed
299299
(and corresponding ``EXPERIMENTAL_ISOLATED_SUBINTERPRETERS``)
300300
have been removed.
301301

302+
* ``smtpd`` has been removed according to the schedule in :pep:`594`,
303+
having been deprecated in Python 3.4.7 and 3.5.4.
304+
Use aiosmtpd_ PyPI module or any other
305+
:mod:`asyncio`-based server instead.
306+
(Contributed by Oleg Iarygin in :gh:`93243`.)
307+
308+
.. _aiosmtpd: https://pypi.org/project/aiosmtpd/
309+
302310
* Remove ``io.OpenWrapper`` and ``_pyio.OpenWrapper``, deprecated in Python
303311
3.10: just use :func:`open` instead. The :func:`open` (:func:`io.open`)
304312
function is a built-in function. Since Python 3.10, :func:`_pyio.open` is
@@ -382,6 +390,10 @@ Changes in the Python API
382390
to :term:`filesystem encoding and error handler`.
383391
Argument files should be encoded in UTF-8 instead of ANSI Codepage on Windows.
384392

393+
* Removed the ``asyncore``-based ``smtpd`` module deprecated in Python 3.4.7
394+
and 3.5.4. A recommended replacement is the
395+
:mod:`asyncio`-based aiosmtpd_ PyPI module.
396+
385397
* :func:`shlex.split`: Passing ``None`` for *s* argument now raises an
386398
exception, rather than reading :data:`sys.stdin`. The feature was deprecated
387399
in Python 3.9.

Lib/test/mock_socket.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Mock socket module used by the smtpd and smtplib tests.
1+
"""Mock socket module used by the smtplib tests.
22
"""
33

44
# imported for _GLOBAL_DEFAULT_TIMEOUT
@@ -33,7 +33,7 @@ def close(self):
3333

3434

3535
class MockSocket:
36-
"""Mock socket object used by smtpd and smtplib tests.
36+
"""Mock socket object used by the smtplib tests.
3737
"""
3838
def __init__(self, family=None):
3939
global _reply_data

Lib/smtpd.py renamed to Lib/test/smtpd.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,16 @@
7777
import time
7878
import socket
7979
import collections
80-
from warnings import _deprecated, warn
80+
from test.support.import_helper import import_module
81+
from warnings import warn
8182
from email._header_value_parser import get_addr_spec, get_angle_addr
8283

8384
__all__ = [
8485
"SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy",
8586
]
8687

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))
92-
93-
94-
# These are imported after the above warning so that users get the correct
95-
# deprecation warning.
96-
import asyncore
97-
import asynchat
98-
88+
asyncore = import_module('asyncore', deprecated=True)
89+
asynchat = import_module('asynchat', deprecated=True)
9990

10091
program = sys.argv[0]
10192
__version__ = 'Python SMTP proxy version 0.3'

Lib/test/test_logging.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@
6161
from socketserver import (ThreadingUDPServer, DatagramRequestHandler,
6262
ThreadingTCPServer, StreamRequestHandler)
6363

64+
with warnings.catch_warnings():
65+
from . import smtpd
6466

6567
asyncore = warnings_helper.import_deprecated('asyncore')
66-
smtpd = warnings_helper.import_deprecated('smtpd')
6768

6869

6970
try:

0 commit comments

Comments
 (0)