-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
[2.7] bpo-36742: Fix urlparse.urlsplit() error message for Unicode URL #13937
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
Conversation
If urlparse.urlsplit() detects an invalid netloc according to NFKC normalization, the error message type is now str rather than unicode, and use repr() to format the URL, to prevent <exception str() failed> when display the error message.
This change fix the bug described at: https://bugs.python.org/issue36742#msg344981 Script:
Output without the fix:
Output with the fix:
|
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.
lgtm.
Lib/urlparse.py
Outdated
u"characters under NFKC normalization") | ||
raise ValueError("netloc %r contains invalid characters " | ||
"under NFKC normalization" | ||
% netloc2) |
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.
Should netloc
be reported in the error message? Python 3 and previous error messages report netloc
.
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.
Oh. You're right. I also fixed this bug and I updated the unit test to test this case.
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.
LGTM. Thanks.
Thanks for review @tirkarthi and @orsenthil! |
If urlparse.urlsplit() detects an invalid netloc according to NFKC
normalization, the error message type is now str rather than unicode,
and use repr() to format the URL, to prevent <exception str() failed>
when display the error message.
https://bugs.python.org/issue36742