Accept Unicode str values in parse_options_header - #321
Open
gyanu2507 wants to merge 2 commits into
Open
Conversation
The function already takes str, but encoding as latin-1 raised UnicodeEncodeError for filenames like 中文.doc. Fall back to UTF-8 when latin-1 cannot represent the value.
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
No issues found across 3 files
You’re at about 97% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
parse_options_headeralready takesstr | bytes | None, but astrwith characters outside Latin-1 raisesUnicodeEncodeError. That's the filename case people actually hit:Bytes (the WSGI path) were already fine. For
strthis encodes as Latin-1 when it fits and falls back to UTF-8 otherwise, so the public API matches its type hint.The issue asked which of the three options you wanted. I went with supporting Unicode
strrather than a clearer error, because the signature already acceptsstrand that's what callers pass for filenames. Happy to switch to a dedicated error if you'd rather keep the Latin-1-only contract explicit.Fixes#319