Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Crash report
What happened?
Unlike toTextIOWrapper constructor,TextIOWrapper.reconfigure() does not check that the encoding argument is actually None or string. If it is not None, it calls_PyUnicode_EqualToASCIIString that only works with strings and crashes in debug build. There may be other similar errors in other arguments.
>>>import sys>>> sys.stdout.reconfigure(encoding=42)Objects/unicodeobject.c:552: _PyUnicode_CheckConsistency: Assertion failed: PyType_HasFeature((Py_TYPE(((PyObject*)((op))))), ((1UL << 28)))Enable tracemalloc to get the memory block allocation tracebackobject address : 0x55a2e3147ca8object refcount : 4294967295object type : 0x55a2e3119f00object type name: intobject repr : 42Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailedPython runtime state: initializedCurrent thread 0x00007fc99ee43740 (most recent call first): File "<stdin>-1", line 1 in <module>Aborted (core dumped)
CPython versions tested on:
3.10, 3.11, 3.12
Operating systems tested on:
No response
Output from running 'python -VV' on the command line:
No response
Linked PRs
- gh-111942: Fix crashes in TextIOWrapper.reconfigure() #111976
- [3.12] gh-111942: Fix crashes in TextIOWrapper.reconfigure() (GH-111976) #112058
- [3.11] gh-111942: Fix crashes in TextIOWrapper.reconfigure() (GH-111976) #112059
- gh-111942: Fix SystemError in the TextIOWrapper constructor #112061
- gh-111942: Fix test_io test_constructor() #112067
- [3.12] gh-111942: Fix SystemError in the TextIOWrapper constructor (GH-112061) #112085
- [3.12] gh-111942: Fix SystemError in the TextIOWrapper constructor (#112061) #112089
- [3.11] gh-111942: Remove an extra incref in textiowrapper_change_encoding #126542