Skip to content

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Nov 14, 2023

  • Fix crash when encoding is not string or None.
  • Fix crash when both line_buffering and write_through raise exception
    when converted ti int.
  • Add a number of tests for constructor and reconfigure() method
    with invalid arguments.
    (cherry picked from commit ee06fff)

Co-authored-by: Serhiy Storchaka storchaka@gmail.com

…-111976)

* Fix crash when encoding is not string or None.
* Fix crash when both line_buffering and write_through raise exception
  when converted ti int.
* Add a number of tests for constructor and reconfigure() method
  with invalid arguments.
(cherry picked from commit ee06fff)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@vstinner
Copy link
Member

test_io failed on Address Sanitizer job:

ERROR: test_constructor (test.test_io.CTextIOWrapperTest.test_constructor)
----------------------------------------------------------------------
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcfe' in position 0: surrogates not allowed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/cpython/cpython/Lib/test/test_io.py", line 2631, in test_constructor
    t.__init__(b, encoding="utf-8", errors='\udcfe')
SystemError: <method 'readable' of '_io.BytesIO' objects> returned a result with an exception set

This PR should be backport to 3.11 with its fix. I will wait until #112089 is merged into 3.12.

…tor (pythonGH-112061) (pythonGH-112089)

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>
(cherry picked from commit 9302f05)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@serhiy-storchaka serhiy-storchaka merged commit e2421a3 into python:3.11 Nov 15, 2023
@JelleZijlstra JelleZijlstra mentioned this pull request Apr 22, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants