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

🔧 Stop using the cgi stdlib module #2021

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

radez
Copy link
Contributor

@radez radez commented Feb 19, 2024

the module was deprecatied in py 3.11 and removed in py 3.13 there are examples of using the email module to resolve this: PEP 594
python-babel/babel#873
https://stackoverflow.com/questions/69068527/python-3-cgi-parse-header

This method doesn't seem to work for cherrypy.
The email.message module is trying to create a higher level object that is intelligent about the headers it has defined. The cgi.parse_header function is a very low level unintelligent function that simply parses header content based on structure and does not inspect the contents. Because of the intelligence of the email.message object cherrypy can't use it in the very generic way that the cgi.parse_header function was being used.

Fix #2014

What kind of change does this PR introduce?

  • [ X ] bug fix
  • feature
  • docs update
  • tests/coverage improvement
  • refactoring
  • other

What is the related issue number (starting with #)
#2014

What is the current behavior? (You can also link to an open issue here)
Deprecation warnings in 3.11 & and 3.12
Module import error in 3.13
#2014

What is the new behavior (if this is a feature change)?

Other information:

Checklist:

  • [ X ] I think the code is well written
  • [ X ] I wrote good commit messages
  • [ X ] I have squashed related commits together after the changes have been approved
  • Unit tests for the changes exist
  • Integration tests for the changes exist (if applicable)
  • [ X ] I used the same coding conventions as the rest of the project
  • [ X ] The new code doesn't generate linter offenses
  • [ X ] Documentation reflects the changes
  • [ X ] The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences

the module was deprecatied in py 3.11 and removed in py 3.13
there are examples of using the email module to resolve this:
PEP 594
python-babel/babel#873
https://stackoverflow.com/questions/69068527/python-3-cgi-parse-header

This method doesn't seem to work for cherrypy.
The email.message module is trying to create a higher level
object that is intelligent about the headers it has defined. The
cgi.parse_header function is a very low level unintelligent function
that simply parses header content based on structure and does not
inspect the contents. Because of the intelligence of the email.message
object cherrypy can't use it in the very generic way that the
cgi.parse_header function was being used.

Fix cherrypy#2014
@Safihre
Copy link
Contributor

Safihre commented Feb 24, 2024

Why are the tests still upset? Seems like the right change!

@webknjaz
Copy link
Member

That's flakiness. I bet restarting a few jobs would make it pass. Though, Dan was going to add some regression tests for the change, which is what the PR is waiting for.

@Safihre
Copy link
Contributor

Safihre commented May 16, 2024

It's been months, and Python 3.13 is now in beta-phase.
Can we get this fixed now?

@radez
Copy link
Contributor Author

radez commented May 16, 2024

We're waiting on this: #2027
I got side tracked at work and didn't finish getting #2027 in

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.

Python 3.13: ModuleNotFoundError: No module named 'cgi'
3 participants