mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Close #13093: PyUnicode_EncodeDecimal() doesn't support error handlers
different than "strict" anymore. The caller was unable to compute the size of the output buffer: it depends on the error handler.
This commit is contained in:
parent
e7ede06757
commit
6345be9a14
3 changed files with 26 additions and 127 deletions
|
@ -1816,20 +1816,10 @@ class UnicodeTest(string_tests.CommonTest,
|
|||
b' 3.14 ')
|
||||
self.assertRaises(UnicodeEncodeError,
|
||||
unicode_encodedecimal, "123\u20ac", "strict")
|
||||
self.assertEqual(unicode_encodedecimal("123\u20ac", "replace"),
|
||||
b'123?')
|
||||
self.assertEqual(unicode_encodedecimal("123\u20ac", "ignore"),
|
||||
b'123')
|
||||
self.assertEqual(unicode_encodedecimal("123\u20ac", "xmlcharrefreplace"),
|
||||
b'123€')
|
||||
self.assertEqual(unicode_encodedecimal("123\u20ac", "backslashreplace"),
|
||||
b'123\\u20ac')
|
||||
self.assertEqual(unicode_encodedecimal("123\u20ac\N{EM SPACE}", "replace"),
|
||||
b'123? ')
|
||||
self.assertEqual(unicode_encodedecimal("123\u20ac\u20ac", "replace"),
|
||||
b'123??')
|
||||
self.assertEqual(unicode_encodedecimal("123\u20ac\u0660", "replace"),
|
||||
b'123?0')
|
||||
self.assertRaisesRegex(
|
||||
ValueError,
|
||||
"^'decimal' codec can't encode character",
|
||||
unicode_encodedecimal, "123\u20ac", "replace")
|
||||
|
||||
def test_transform_decimal(self):
|
||||
from _testcapi import unicode_transformdecimaltoascii as transform_decimal
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue