-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
bpo-30566: Fix IndexError in the punycode codec #1986
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
|
Could you add a test for this? |
|
I have added a test case to the punycode Test-suite. |
berkerpeksag
left a comment
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.
Please also add a NEWS file. See https://devguide.python.org/committing/#what-s-new-and-news-entries for details.
| # Make sure punycode codec raises the right kind of exception | ||
| # when given invalid punycode to decode | ||
| def test_decode_exceptions(self): | ||
| for byt, exception in punycode_decode_exceptions: |
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.
I'd rename byt to puny.
| if len(i)!=2: | ||
| print(repr(i)) | ||
|
|
||
| punycode_decode_exceptions = [ |
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.
I'd rename this to invalid_punycode_testcases.
| puny = puny.decode("ascii").encode("ascii") | ||
| self.assertEqual(uni, puny.decode("punycode")) | ||
|
|
||
| # Make sure punycode codec raises the right kind of exception |
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.
Style nit: We can drop this comment.
| # when given invalid punycode to decode | ||
| def test_decode_exceptions(self): | ||
| for byt, exception in punycode_decode_exceptions: | ||
| with self.assertRaises(exception): |
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.
We couls use self.subTest() to make test failure messages clearer.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
I removed the " needs backport to 3.6" label, the 3.6 branch no longer accept bugfixes (only security fixes are accepted): https://devguide.python.org/#status-of-python-branches |
|
@vikhegde Would you like to move this forward by implementing @berkerpeksag's suggestions? |
|
This pull request seems to have been abandoned, so I'm going to close it. It can reopened if the original author is interested in working on it again or a new pull request can be created to replace it. Thank you! |
A bug in the punycode codec raises an IndexError when we attempt to decode the string "xn--w&". The fix is straightforward and obvious one-liner. Bug number: bpo-30566
https://bugs.python.org/issue30566