Skip to content

#11848 Remove the usage of cgi.parse_multipart and replace with email module.#12058

Merged
glyph merged 4 commits intotrunkfrom
11848-cgi-removal-take2
Dec 25, 2023
Merged

#11848 Remove the usage of cgi.parse_multipart and replace with email module.#12058
glyph merged 4 commits intotrunkfrom
11848-cgi-removal-take2

Conversation

@adiroiban
Copy link
Member

Scope and purpose

Fixes #11848

This should be the last usage of cgi module in Twisted.

It uses the stdlib email module.

I with with stdlib to reduce the need for an extra dependency or reinvent the wheel.

I think that if there are any issued with stdlib, they should be fixed upstream.

See twisted/treq#355 for other options.

"""
Like C{cgi.parse_qs}, but with support for parsing byte strings on Python 3.

This was created to help with Python 2 to Python 3 migration.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added this comment to trigger a conversation.

Maybe this function should be deprecated (in a separate PR), and just use stdlib.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just replace it with a deprecated alias of parse_qs, or does its behavior differ significantly?

In any case yeah eventually deprecating it sounds good.

@adiroiban
Copy link
Member Author

I did a quick fix. The tests pass... but I am not sure this is the right fix.

needs-review

Copy link
Member

@glyph glyph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really glad to see the process working and advance builds with alphas causing us to catch up with deprecations

"""
Like C{cgi.parse_qs}, but with support for parsing byte strings on Python 3.

This was created to help with Python 2 to Python 3 migration.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just replace it with a deprecated alias of parse_qs, or does its behavior differ significantly?

In any case yeah eventually deprecating it sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants