mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-133968: Add PyUnicodeWriter_WriteASCII() function (#133973)
Replace most PyUnicodeWriter_WriteUTF8() calls with PyUnicodeWriter_WriteASCII(). Unrelated change to please the linter: remove an unused import in test_ctypes. Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
4109a9c6b3
commit
f49a07b531
17 changed files with 103 additions and 31 deletions
|
@ -1776,6 +1776,13 @@ class PyUnicodeWriterTest(unittest.TestCase):
|
|||
self.assertEqual(writer.finish(),
|
||||
"ascii-latin1=\xE9-euro=\u20AC.")
|
||||
|
||||
def test_ascii(self):
|
||||
writer = self.create_writer(0)
|
||||
writer.write_ascii(b"Hello ", -1)
|
||||
writer.write_ascii(b"", 0)
|
||||
writer.write_ascii(b"Python! <truncated>", 6)
|
||||
self.assertEqual(writer.finish(), "Hello Python")
|
||||
|
||||
def test_invalid_utf8(self):
|
||||
writer = self.create_writer(0)
|
||||
with self.assertRaises(UnicodeDecodeError):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue