Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions Doc/library/mailcap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

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

.. deprecated-removed:: 3.11 3.13
See the :mod:`mimetypes` module for an alternative.

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

Mailcap files are used to configure how MIME-aware applications such as mail
Expand Down
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,11 @@ Deprecated
be able to parse Python 3.10 or newer. See the :pep:`617` (New PEG parser for
CPython). (Contributed by Victor Stinner in :issue:`40360`.)

* The :mod:`mailcap` module is now deprecated and will be removed in Python
Copy link
Member

Choose a reason for hiding this comment

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

Maybe list this with the other two PEP 594 ones below?

3.13. See :pep:`594` for the rationale and the :mod:`mimetypes` module for an
alternative.
(Contributed by Victor Stinner in :gh:`68966`.)

* Undocumented modules ``sre_compile``, ``sre_constants`` and ``sre_parse``
are now deprecated.
(Contributed by Serhiy Storchaka in :issue:`47152`.)
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
15 changes: 11 additions & 4 deletions Lib/test/test_mailcap.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
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


with warnings.catch_warnings():
# mailcap is deprecated
warnings.simplefilter('ignore', DeprecationWarning)
import mailcap
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.

Also changes to this file for the 2nd PR.



# 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.