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

DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13 #437

Open
jugmac00 opened this issue May 29, 2022 · 14 comments · May be fixed by #466
Open

DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13 #437

jugmac00 opened this issue May 29, 2022 · 14 comments · May be fixed by #466

Comments

@jugmac00
Copy link

jugmac00 commented May 29, 2022

git clone https://github.com/morepath/morepath
cd morepath
tox -e py311

...

.tox/py311/lib/python3.11/site-packages/webob/compat.py:5
  /home/jugmac00/Projects/my-all-repos/output_zope/morepath/morepath/.tox/py311/lib/python3.11/site-packages/webob/compat.py:5: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13
    from cgi import parse_header

Also see:
https://peps.python.org/pep-0594/#cgi

And yes I know - it will take a couple of years until anybody will use 3.14 :-)

Anyhow, seeing the same deprecation warnings with every test run is slightly annoying. If you are ok with the suggested replacement (see pep), I'd create a PR.

@mmerickel
Copy link
Member

webob has bigger problems with cgi than just the parse_header method but that being said I don’t see a big problem with the suggested fix. I would require a little due diligence to ensure that they are actually compatible apis.

Bitter rant: due diligence because the pep isn’t very trustworthy in its analyses from the perspective of the maintainer of a very popular library that’s apparently using a library so unpopular that it’s getting dropped from the stdlib.

@ondrejj
Copy link

ondrejj commented Oct 23, 2023

Any update for this issue?

Reported in red hat bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=2245641

@ztane
Copy link

ztane commented Dec 13, 2023

The title could now be changed to "ImportError: no such module cgi" :'D

@ztane
Copy link

ztane commented Dec 13, 2023

Anyway, the cgi.py of 3.11 at least, contains ~1k lines in one file, of which ~700 lines are actually relevant, there is some unbelievable CGI html output garbage and some logging methods so I can understand why people want it gone, is it license-wise possible to vendor the 3.11 / 3.12 version into WebOb compat?

And with all due respect to Martijn for proposing those replacements; those replacement strategies are already in use in cgi.py as far as I can see and what remains... are those 700 lines of code.

@spiqueras
Copy link

In case there's interest, I've tested installing the legacy-cgi package with Python 3.13.0a3 and all tests pass. Branch is here: https://github.com/spiqueras/webob/tree/py3.13

@mgorny
Copy link

mgorny commented May 18, 2024

Python 3.13.0b1 is out, and the cgi removal is "official" now.

@robtaylor
Copy link

any update on this?

@luhn
Copy link
Contributor

luhn commented Oct 7, 2024

I opened a PR to swap out cgi for the multipart package: #466

@mgorny
Copy link

mgorny commented Oct 8, 2024

For the record, multipart is not usable at the moment because two package authors claim the same package name, neither wants to give up, and packages randomly require one or the other: defnull/multipart#53 Kludex/python-multipart#152.

@robtaylor
Copy link

robtaylor commented Oct 8, 2024 via email

@hynek
Copy link

hynek commented Oct 9, 2024

FWIW there's also https://github.com/jackrosenthal/legacy-cgi which seems to be copy/paste of the CGI module. Conditionally depending on it might be the easier route to unblock 3.13 for the Pyramid ecosystem until the multipart situation is somehow resolved?

@defnull
Copy link

defnull commented Oct 11, 2024

For the record, multipart is not usable at the moment because two package authors claim the same package name, neither wants to give up, and packages randomly require one or the other: defnull/multipart#53 Kludex/python-multipart#152.

Some aspects that might help here:

  • The primary dependent of python-multipart is Starlette (FastAPI). There are others, but conflicts should be unlikely outside of Starlette/FastAPI projects. python-multipart is also optional and not a hard dependency for Starlette applications.
  • Depending on multipart does not cause issues for python-multipart users, only the other way around. Packages take priority over single-file modules during import.

Probably not the nicest solution, but it would be possible to depend on multipart and also vendor it, then detect conflicts at runtime and fall back on the vendored version if necessary and print a warning. This would not break any existing applications for anyone, and it would also not require this project to always keep the vendored version up to date as it is only used in rare conflict situations.

@frenzymadness
Copy link

I'm just afraid that testing all possible combinations would make the testsuite complex.

@cjwatson
Copy link

cjwatson commented Nov 6, 2024

The multipart vs. python-multipart situation should be resolved now (see pypa/packaging-problems#818).

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 a pull request may close this issue.