Skip to content
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

gh-68966: Deprecate the mailcap module #91951

Merged
merged 4 commits into from Apr 26, 2022
Merged

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Apr 26, 2022

No description provided.

@vstinner
Copy link
Member Author

vstinner commented Apr 26, 2022

cc @brettcannon @hugovk

mimetypes is not a replacement, but provide a "similar" feature. mailcap opens a file with an application, whereas mimetypes gets the MIME type of a file. On Linux, the xdg-open program is an alternative, but it's not portable.

@vstinner
Copy link
Member Author

vstinner commented Apr 26, 2022

I updated the doc to mention PEP 594 for the rationale. I didn't mention PEP 594 in the deprecation message.

@vstinner
Copy link
Member Author

vstinner commented Apr 26, 2022

The Steering Council decided to deprecate the mailcap module as part of PEP 594, so in Python 3.11:

@@ -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

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

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

@hugovk
Copy link
Member

hugovk commented Apr 26, 2022

For the others, the documentation changes was done separately (and also list on Doc/library/superseded.rst), so they could be backported to 3.9 and 3.10.

For example, see #31891 and #31984.

The SC also wanted to leave out the targeted removal date in docs (but not warnings): #31891 (comment)

Please could you split the PR?

@vstinner
Copy link
Member Author

vstinner commented Apr 26, 2022

@hugovk: I updated my PR. Would you mind to review it again?

Doc/library/mailcap.rst Show resolved Hide resolved
@@ -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

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

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

@vstinner vstinner Apr 26, 2022

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.

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

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.

Lib/test/test_mailcap.py Outdated Show resolved Hide resolved
hugovk
hugovk approved these changes Apr 26, 2022
Copy link
Member

@hugovk hugovk left a comment

Thank you!

@vstinner vstinner merged commit 80de027 into python:main Apr 26, 2022
13 checks passed
@vstinner vstinner deleted the deprecate_mailcap branch Apr 26, 2022
@vstinner
Copy link
Member Author

vstinner commented Apr 26, 2022

@hugovk: I created #91971 for Python 3.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants