Skip to content

gh-68966: Deprecate the mailcap module #91951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Doc/library/mailcap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@

.. module:: mailcap
:synopsis: Mailcap file handling.
:deprecated:

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

.. deprecated:: 3.11
The :mod:`mailcap` module is deprecated. See :pep:`594` for the rationale
and the :mod:`mimetypes` module for an alternative.

--------------

Mailcap files are used to configure how MIME-aware applications such as mail
Expand Down
1 change: 0 additions & 1 deletion Doc/library/netdata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ on the internet.

email.rst
json.rst
mailcap.rst
mailbox.rst
mimetypes.rst
base64.rst
Expand Down
3 changes: 2 additions & 1 deletion Doc/library/superseded.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ backwards compatibility. They have been superseded by other modules.
crypt.rst
imghdr.rst
imp.rst
mailcap.rst
msilib.rst
nntplib.rst
nis.rst
nntplib.rst
optparse.rst
ossaudiodev.rst
pipes.rst
Expand Down
4 changes: 3 additions & 1 deletion Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,7 @@ Deprecated
* :mod:`chunk`
* :mod:`crypt`
* :mod:`imghdr`
* :mod:`mailcap`
* :mod:`msilib`
* :mod:`nis`
* :mod:`nntplib`
Expand All @@ -1070,7 +1071,8 @@ Deprecated
* :mod:`spwd`
* :mod:`sunau`

(Contributed by Brett Cannon in :issue:`47061`.)
(Contributed by Brett Cannon in :issue:`47061` and Victor Stinner in
:gh:`68966`.)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the others, we should include these 3.11.rst changes in the 2nd PR that'll do the code warnings, because we don't want to backport this bit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to modify the backport but push all changes at once in the main branch.



Removed
Expand Down
6 changes: 6 additions & 0 deletions Lib/mailcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
__all__ = ["getcaps","findmatch"]


_DEPRECATION_MSG = ('The {name} module is deprecated and will be removed in '
'Python {remove}. See the mimetypes module for an '
'alternative.')
warnings._deprecated(__name__, _DEPRECATION_MSG, remove=(3, 13))
Copy link
Member

@hugovk hugovk Apr 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's include this in a 2nd, non-backport PR.



def lineno_sort_key(entry):
# Sort in ascending order, with unspecified entries at the end
if 'lineno' in entry:
Expand Down
13 changes: 9 additions & 4 deletions Lib/test/test_mailcap.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import mailcap
import os
import copy
import os
import sys
import test.support
from test.support import os_helper
import unittest
import sys
import warnings
from test.support import os_helper
from test.support import warnings_helper


mailcap = warnings_helper.import_deprecated('mailcap')


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