Skip to content

Commit ef8b7e1

Browse files
committed
gh-143008: Fix race re-initilaizing TextIOWrapper
__init__ changes multiple variables and may be called more than once from multiple threads.
1 parent dcb049f commit ef8b7e1

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix race conditions when re-initializing a :class:`io.TextIOWrapper` object.

Modules/_io/clinic/textio.c.h

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/textio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,7 @@ io_check_errors(PyObject *errors)
10611061

10621062

10631063
/*[clinic input]
1064+
@critical_section
10641065
_io.TextIOWrapper.__init__
10651066
buffer: object
10661067
encoding: str(accept={str, NoneType}) = None
@@ -1104,7 +1105,7 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
11041105
const char *encoding, PyObject *errors,
11051106
const char *newline, int line_buffering,
11061107
int write_through)
1107-
/*[clinic end generated code: output=72267c0c01032ed2 input=e6cfaaaf6059d4f5]*/
1108+
/*[clinic end generated code: output=72267c0c01032ed2 input=0f077220214c40a4]*/
11081109
{
11091110
PyObject *raw, *codec_info = NULL;
11101111
PyObject *res;

0 commit comments

Comments
 (0)