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

Replace cgi module with email.message #11098

Merged
merged 1 commit into from
May 24, 2022
Merged

Replace cgi module with email.message #11098

merged 1 commit into from
May 24, 2022

Conversation

fungi
Copy link
Contributor

@fungi fungi commented May 8, 2022

As of Python 3.11.0b1, the cgi module is deprecated per PEP 594
(Removing dead batteries from the standard library), and raises
DeprecationWarning when imported. The only places pip relies on this
are pip._internal.index.collector._get_encoding_from_headers() and
pip._internal.network.download.parse_content_disposition() calling
parse_headers(), so replace that with the solution recommended in an
old PEP 594 thread from 2019: https://discuss.python.org/t/1704/14

Fixes: #11099

@fungi
Copy link
Contributor Author

fungi commented May 8, 2022

After digging into a number of possibilities, I ran across a solution in the PEP 594 discussions from 2019 which point out that you an just use email.message.Message objects as an alternative. I have a working implementation with that I'll push shortly.

Edit: As someone else pointed out in Discord just now, that solution also got copied directly into the PEP's text. I must be going blind.

@fungi fungi changed the title Replace stdlib cgi module with requests Replace cgi module with email.message May 8, 2022
news/11099.bugfix.rst Outdated Show resolved Hide resolved
@hugovk
Copy link
Contributor

hugovk commented May 9, 2022

GitHub tip:

Put something like "Fixes #11099" in the PR messages, and when this is merged, it'll autoclose the issue.

[Docs]

As of Python 3.11.0b1, the cgi module is deprecated per PEP 594
(Removing dead batteries from the standard library), and raises
DeprecationWarning when imported. The only places pip relies on this
are pip._internal.index.collector._get_encoding_from_headers() and
pip._internal.network.download.parse_content_disposition() calling
parse_headers(), so replace that with the solution recommended in an
old PEP 594 thread from 2019: https://discuss.python.org/t/1704/14

Fixes: #11099
@fungi
Copy link
Contributor Author

fungi commented May 9, 2022

Fixes #11099"

Added. If it's not obvious, I spend most of my time with other code review platforms and have to look up GitHub's conventions every time I try to use it. Thanks for the tip!

@EwoutH
Copy link

EwoutH commented May 24, 2022

Thanks for this effort! What's needed to merge this?

@pradyunsg pradyunsg changed the title Replace cgi module with email.message Replace cgi module with email.message May 24, 2022
@pradyunsg pradyunsg merged commit 7a42bce into pypa:main May 24, 2022
@q0w
Copy link
Contributor

q0w commented Jun 6, 2022

or like this aio-libs/aiohttp#6708

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The cgi module is deprecated in Python 3.11.0b1
6 participants