| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -83,7 +83,7 @@ def replace_surrogate_encode(mystring): | |||
| 83 | 83 | # The following magic comes from Py3.3's Python/codecs.c file: | |
| 84 | 84 | if not 0xD800 <= code <= 0xDCFF: | |
| 85 | 85 | # Not a surrogate. Fail with the original exception. | |
| 86 | - raise exc | ||
| 86 | + raise NotASurrogateError | ||
| 87 | 87 | # mybytes = [0xe0 | (code >> 12), | |
| 88 | 88 | # 0x80 | ((code >> 6) & 0x3f), | |
| 89 | 89 | # 0x80 | (code & 0x3f)] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,6 +33,12 @@ def test_encode_ascii_surrogateescape(self): | |||
| 33 | 33 | b = payload.encode('ascii', 'surrogateescape') | |
| 34 | 34 | self.assertEqual(b, b'cMO2c3RhbA\xc3\xa1=\n') | |
| 35 | 35 | ||
| 36 | + def test_encode_ascii_unicode(self): | ||
| 37 | + """ | ||
| 38 | + Verify that exceptions are raised properly. | ||
| 39 | + """ | ||
| 40 | + self.assertRaises(UnicodeEncodeError, u'\N{SNOWMAN}'.encode, 'US-ASCII', 'surrogateescape') | ||
| 41 | + | ||
| 36 | 42 | @expectedFailurePY2 | |
| 37 | 43 | def test_encode_ascii_surrogateescape_non_newstr(self): | |
| 38 | 44 | """ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments