Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/future/utils/surrogateescape.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def replace_surrogate_encode(mystring):
# The following magic comes from Py3.3's Python/codecs.c file:
if not 0xD800 <= code <= 0xDCFF:
# Not a surrogate. Fail with the original exception.
raise exc
raise NotASurrogateError
# mybytes = [0xe0 | (code >> 12),
# 0x80 | ((code >> 6) & 0x3f),
# 0x80 | (code & 0x3f)]
Expand Down
6 changes: 6 additions & 0 deletions tests/test_future/test_surrogateescape.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def test_encode_ascii_surrogateescape(self):
b = payload.encode('ascii', 'surrogateescape')
self.assertEqual(b, b'cMO2c3RhbA\xc3\xa1=\n')

def test_encode_ascii_unicode(self):
"""
Verify that exceptions are raised properly.
"""
self.assertRaises(UnicodeEncodeError, u'\N{SNOWMAN}'.encode, 'US-ASCII', 'surrogateescape')

@expectedFailurePY2
def test_encode_ascii_surrogateescape_non_newstr(self):
"""
Expand Down