-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1335,6 +1335,11 @@ def test_recoding(self): | |
| if len(i)!=2: | ||
| print(repr(i)) | ||
|
|
||
| punycode_decode_exceptions = [ | ||
| (b"xn--w&", | ||
| UnicodeError), | ||
| ] | ||
|
|
||
|
|
||
| class PunycodeTest(unittest.TestCase): | ||
| def test_encode(self): | ||
|
|
@@ -1355,6 +1360,12 @@ def test_decode(self): | |
| puny = puny.decode("ascii").encode("ascii") | ||
| self.assertEqual(uni, puny.decode("punycode")) | ||
|
|
||
| # Make sure punycode codec raises the right kind of exception | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rename |
||
| with self.assertRaises(exception): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We couls use |
||
| byt.decode('punycode') | ||
|
|
||
| class UnicodeInternalTest(unittest.TestCase): | ||
| @unittest.skipUnless(SIZEOF_WCHAR_T == 4, 'specific to 32-bit wchar_t') | ||
|
|
||
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.