diff options
Diffstat (limited to 'Lib/test/test_capi/test_unicode.py')
-rw-r--r-- | Lib/test/test_capi/test_unicode.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/test/test_capi/test_unicode.py b/Lib/test/test_capi/test_unicode.py index 3ec27a2..8ab5590 100644 --- a/Lib/test/test_capi/test_unicode.py +++ b/Lib/test/test_capi/test_unicode.py @@ -882,7 +882,10 @@ class CAPITest(unittest.TestCase): self.assertEqual(unicode_asutf8('abc', 4), b'abc\0') self.assertEqual(unicode_asutf8('абв', 7), b'\xd0\xb0\xd0\xb1\xd0\xb2\0') self.assertEqual(unicode_asutf8('\U0001f600', 5), b'\xf0\x9f\x98\x80\0') - self.assertEqual(unicode_asutf8('abc\0def', 8), b'abc\0def\0') + + # disallow embedded null characters + self.assertRaises(ValueError, unicode_asutf8, 'abc\0', 0) + self.assertRaises(ValueError, unicode_asutf8, 'abc\0def', 0) self.assertRaises(UnicodeEncodeError, unicode_asutf8, '\ud8ff', 0) self.assertRaises(TypeError, unicode_asutf8, b'abc', 0) |