Skip to content

Commit 80de027

Browse files
authored
gh-68966: Deprecate the mailcap module (#91951)
1 parent b87f7f2 commit 80de027

File tree

7 files changed

+28
-7
lines changed

7 files changed

+28
-7
lines changed

Doc/library/mailcap.rst

+5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33

44
.. module:: mailcap
55
:synopsis: Mailcap file handling.
6+
:deprecated:
67

78
**Source code:** :source:`Lib/mailcap.py`
89

10+
.. deprecated:: 3.11
11+
The :mod:`mailcap` module is deprecated. See :pep:`594` for the rationale
12+
and the :mod:`mimetypes` module for an alternative.
13+
914
--------------
1015

1116
Mailcap files are used to configure how MIME-aware applications such as mail

Doc/library/netdata.rst

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ on the internet.
1313

1414
email.rst
1515
json.rst
16-
mailcap.rst
1716
mailbox.rst
1817
mimetypes.rst
1918
base64.rst

Doc/library/superseded.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ backwards compatibility. They have been superseded by other modules.
2020
crypt.rst
2121
imghdr.rst
2222
imp.rst
23+
mailcap.rst
2324
msilib.rst
24-
nntplib.rst
2525
nis.rst
26+
nntplib.rst
2627
optparse.rst
2728
ossaudiodev.rst
2829
pipes.rst

Doc/whatsnew/3.11.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,7 @@ Deprecated
10611061
* :mod:`chunk`
10621062
* :mod:`crypt`
10631063
* :mod:`imghdr`
1064+
* :mod:`mailcap`
10641065
* :mod:`msilib`
10651066
* :mod:`nis`
10661067
* :mod:`nntplib`
@@ -1071,7 +1072,8 @@ Deprecated
10711072
* :mod:`sunau`
10721073
* :mod:`telnetlib`
10731074

1074-
(Contributed by Brett Cannon in :issue:`47061`.)
1075+
(Contributed by Brett Cannon in :issue:`47061` and Victor Stinner in
1076+
:gh:`68966`.)
10751077

10761078

10771079
Removed

Lib/mailcap.py

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
__all__ = ["getcaps","findmatch"]
77

88

9+
_DEPRECATION_MSG = ('The {name} module is deprecated and will be removed in '
10+
'Python {remove}. See the mimetypes module for an '
11+
'alternative.')
12+
warnings._deprecated(__name__, _DEPRECATION_MSG, remove=(3, 13))
13+
14+
915
def lineno_sort_key(entry):
1016
# Sort in ascending order, with unspecified entries at the end
1117
if 'lineno' in entry:

Lib/test/test_mailcap.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import mailcap
2-
import os
31
import copy
2+
import os
3+
import sys
44
import test.support
5-
from test.support import os_helper
65
import unittest
7-
import sys
6+
import warnings
7+
from test.support import os_helper
8+
from test.support import warnings_helper
9+
10+
11+
mailcap = warnings_helper.import_deprecated('mailcap')
12+
813

914
# Location of mailcap file
1015
MAILCAPFILE = test.support.findfile("mailcap.txt")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The :mod:`mailcap` module is now deprecated and will be removed in Python 3.13.
2+
See :pep:`594` for the rationale and the :mod:`mimetypes` module for an
3+
alternative. Patch by Victor Stinner.

0 commit comments

Comments
 (0)