]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-68966: Deprecate the mailcap module (#91951)
authorVictor Stinner <vstinner@python.org>
Tue, 26 Apr 2022 20:43:50 +0000 (22:43 +0200)
committerGitHub <noreply@github.com>
Tue, 26 Apr 2022 20:43:50 +0000 (22:43 +0200)
Doc/library/mailcap.rst
Doc/library/netdata.rst
Doc/library/superseded.rst
Doc/whatsnew/3.11.rst
Lib/mailcap.py
Lib/test/test_mailcap.py
Misc/NEWS.d/next/Library/2022-04-26-09-09-07.gh-issue-68966.roapI2.rst [new file with mode: 0644]

index 7749b7dd45ef4463517474536b2348564b6c714c..416b181f45a772ad5052dd6d959d64fec4a252bf 100644 (file)
@@ -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
index 8955e859ab634cc5eef6f6970e92f87ad8501c3f..1541e2a54445900ccd406966eae586c4ca7fb262 100644 (file)
@@ -13,7 +13,6 @@ on the internet.
 
    email.rst
    json.rst
-   mailcap.rst
    mailbox.rst
    mimetypes.rst
    base64.rst
index e3f9b0d37fe10bdbd9acf86a8f74d6a923108ad9..b38f16691f6ea9ac72cdbf7dda7ecd6d1d1052dd 100644 (file)
@@ -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
index b812658d5e91e8f843d7dac6bbc85494954a8e94..aa0a51b4375f18839e12e651434f00501e52cf5d 100644 (file)
@@ -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
index ae416a8e9fb27314c41c3f5682ded746196ec3c4..856b6a55475f388ba198d2759bee8cb3a08dfbe9 100644 (file)
@@ -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:
index ef9cad498a75c2620d806362f8048458bd48c310..97a8fac6e074adc8f57cba5af1f3dc13b5f6f9c8 100644 (file)
@@ -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 (file)
index 0000000..5c9ffbf
--- /dev/null
@@ -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.