diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-11-14 20:02:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-14 20:02:28 (GMT) |
commit | 9302f05f9af07332c414b3c19003efd1b1763cf3 (patch) | |
tree | 496fcbadb2abf8e0db779fa4e942fcfc9a91234c /Lib/test | |
parent | 0ff6368519ed7542ad8b443de01108690102420a (diff) | |
download | cpython-9302f05f9af07332c414b3c19003efd1b1763cf3.zip cpython-9302f05f9af07332c414b3c19003efd1b1763cf3.tar.gz cpython-9302f05f9af07332c414b3c19003efd1b1763cf3.tar.bz2 |
gh-111942: Fix SystemError in the TextIOWrapper constructor (#112061)
In non-debug more the check for the "errors" argument is skipped,
and then PyUnicode_AsUTF8() can fail, but its result was not checked.
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_io.py | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index fe622e8..ab33892 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -2725,9 +2725,7 @@ class TextIOWrapperTest(unittest.TestCase): if support.Py_DEBUG or sys.flags.dev_mode or self.is_C: with self.assertRaises(UnicodeEncodeError): t.__init__(b, encoding="utf-8", errors='\udcfe') - if support.Py_DEBUG or sys.flags.dev_mode: - # TODO: If encoded to UTF-8, should also be checked for - # embedded null characters. + if support.Py_DEBUG or sys.flags.dev_mode or self.is_C: with self.assertRaises(ValueError): t.__init__(b, encoding="utf-8", errors='replace\0') with self.assertRaises(TypeError): |