twisted / treq

Python requests like API built on top of Twisted's HTTP client.
Other
585 stars 137 forks source link

Eliminate use of `cgi` #377

Closed twm closed 6 months ago

twm commented 6 months ago

Stop using cgi, which was deprecated in Python 3.11 and dropped in Python 3.13. Replace it with the multipart package, which becomes a dependency.

Fixes #355.

glyph commented 6 months ago

Does vendoring a stdlib function have license implications? I'd rather deal with the possibility of tinkering in the email module than copy the PSF license.

twm commented 6 months ago

@glyph I thought we've vendored stuff from the stdlib in Twisted before... is that not the case?

twm commented 6 months ago

Okay, I switched to using multipart for everything.

adiroiban commented 6 months ago

Thanks for the feedback. Much appreciated!

I have approved the PR and I am ok with using multipart for treq.

My comment about multipart vs stdlib was more of a FYI for what was done in twisted/twisted to fix this issue.

Also, I remember some discussions for getting treq code include in Twisted and have it as a high-level API .

From what I can see in this PR, multipart is used in "production" only to parse the Content-Type header. I was hoping that HTTP and MIME have the same standard for Content-Type header format.


I think that HTTP handling should be a core feature of any library, and this is why I would prefer to have http code implemented in stdlib.

For example, in Twisted, HTTP protocol handling is part of main Twisted package, while for LDAP we have a separate package.

Something similar for stdlib. I would expect Python to have a good enough HTTP handing, and use a separate package for LDAP handling.

opoplawski commented 1 month ago

Any chance we could get a new release with this fix? Fedora rawhide just updated to Python 3.13b2 and treq is failing to build. This PR doesn't apply cleanly to 23.11.0. Thanks.

adiroiban commented 1 month ago

I think that first we should fix the 3.13 support in twisted/twisted

stratakis commented 1 month ago

Any chance we could get a new release with this fix? Fedora rawhide just updated to Python 3.13b2 and treq is failing to build. This PR doesn't apply cleanly to 23.11.0. Thanks.

Unfortunately on Fedora we don't package multipart, but python-multipart which is a different project. And while not entirely sure of the stability of each project, the multipart used here looks abandoned upstream (no commits since 2021).

cjwatson commented 1 month ago

multipart may not be super-active, but it isn't abandoned. I just released 0.2.5.

stratakis commented 1 month ago

multipart may not be super-active, but it isn't abandoned. I just released 0.2.5.

That is awesome, thanks for the response here :). I'll work on getting it packaged for Fedora then.

twm commented 1 month ago

@opoplawski Thanks for the ping! I'm currently a bit loopy on cough medicine, but I should be able to manage a release this weekend or next week.