-
Notifications
You must be signed in to change notification settings - Fork 0
Removes deprecated cgi function and replaces with email.message.Message #1
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
base: master
Are you sure you want to change the base?
Conversation
pywebcopy/urls.py
Outdated
| # Adapted from https://peps.python.org/pep-0594/#cgi | ||
| m = Message() | ||
| m['content-type'] = value | ||
| return dict(m.get_params()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem quite right. It returns a single value, but the return type is expected to be two values. Also the get_params method is stated to be a legacy function. I think we should be using the EmailMessage replacement described here: https://docs.python.org/3.12/library/cgi.html#cgi.parse_header
def parse_separated_header(value: str):
msg = EmailMessage()
msg['content-type'] = 'application/json; charset="utf8"'
main, params = msg.get_content_type(), msg['content-type'].params
return main, params
docs/urls.html
Outdated
| if not content_type: | ||
| return default | ||
| content_type, params = parse_header(content_type) | ||
| content_type, params = parse_separated_header(content_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This documentation does not match the code. Is this auto-generated, or do we have to edit this by hand?
Should be:
content_type = Parse_separated_header(content_type)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are other changes not present in this documentation file as well -- the parse_separated_header function, the imports... This should be generated by pdoc3, but I think the original author gitignored any files related to generating docs, so it's hard to know what their process was. If I just run pdoc on this project, I get slightly broken formatting, but it looks close to the original docs.
Replaces use of cgi