diff options
author | Victor Stinner <vstinner@python.org> | 2022-04-26 20:43:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 20:43:50 (GMT) |
commit | 80de0273c0caf8bae19787bb00255eb3fb2a2d0c (patch) | |
tree | eae25b99f66f046643c7990716ee7bd1b1c8ff2c | |
parent | b87f7f2c213225cbe5c4bd8f8a83883e0824c7d0 (diff) | |
download | cpython-80de0273c0caf8bae19787bb00255eb3fb2a2d0c.zip cpython-80de0273c0caf8bae19787bb00255eb3fb2a2d0c.tar.gz cpython-80de0273c0caf8bae19787bb00255eb3fb2a2d0c.tar.bz2 |
gh-68966: Deprecate the mailcap module (#91951)
-rw-r--r-- | Doc/library/mailcap.rst | 5 | ||||
-rw-r--r-- | Doc/library/netdata.rst | 1 | ||||
-rw-r--r-- | Doc/library/superseded.rst | 3 | ||||
-rw-r--r-- | Doc/whatsnew/3.11.rst | 4 | ||||
-rw-r--r-- | Lib/mailcap.py | 6 | ||||
-rw-r--r-- | Lib/test/test_mailcap.py | 13 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2022-04-26-09-09-07.gh-issue-68966.roapI2.rst | 3 |
7 files changed, 28 insertions, 7 deletions
diff --git a/Doc/library/mailcap.rst b/Doc/library/mailcap.rst index 7749b7d..416b181 100644 --- a/Doc/library/mailcap.rst +++ b/Doc/library/mailcap.rst @@ -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 diff --git a/Doc/library/netdata.rst b/Doc/library/netdata.rst index 8955e85..1541e2a 100644 --- a/Doc/library/netdata.rst +++ b/Doc/library/netdata.rst @@ -13,7 +13,6 @@ on the internet. email.rst json.rst - mailcap.rst mailbox.rst mimetypes.rst base64.rst diff --git a/Doc/library/superseded.rst b/Doc/library/superseded.rst index e3f9b0d..b38f166 100644 --- a/Doc/library/superseded.rst +++ b/Doc/library/superseded.rst @@ -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 diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index b812658..aa0a51b 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -1061,6 +1061,7 @@ Deprecated * :mod:`chunk` * :mod:`crypt` * :mod:`imghdr` + * :mod:`mailcap` * :mod:`msilib` * :mod:`nis` * :mod:`nntplib` @@ -1071,7 +1072,8 @@ Deprecated * :mod:`sunau` * :mod:`telnetlib` - (Contributed by Brett Cannon in :issue:`47061`.) + (Contributed by Brett Cannon in :issue:`47061` and Victor Stinner in + :gh:`68966`.) Removed diff --git a/Lib/mailcap.py b/Lib/mailcap.py index ae416a8..856b6a5 100644 --- a/Lib/mailcap.py +++ b/Lib/mailcap.py @@ -6,6 +6,12 @@ import warnings __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)) + + def lineno_sort_key(entry): # Sort in ascending order, with unspecified entries at the end if 'lineno' in entry: diff --git a/Lib/test/test_mailcap.py b/Lib/test/test_mailcap.py index ef9cad4..97a8fac 100644 --- a/Lib/test/test_mailcap.py +++ b/Lib/test/test_mailcap.py @@ -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") diff --git a/Misc/NEWS.d/next/Library/2022-04-26-09-09-07.gh-issue-68966.roapI2.rst b/Misc/NEWS.d/next/Library/2022-04-26-09-09-07.gh-issue-68966.roapI2.rst new file mode 100644 index 0000000..5c9ffbf --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-04-26-09-09-07.gh-issue-68966.roapI2.rst @@ -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. |