Skip to content

Commit c40e6d6

Browse files
vstinnercmaloney
andauthored
[3.13][3.15] gh-143008: Fix race re-initializing TextIOWrapper (#151203) (#151227)
[3.15] gh-143008: Fix race re-initializing TextIOWrapper (#151203) __init__() changes multiple variables and may be called more than once from multiple threads. (cherry picked from commit 0318867) Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
1 parent 78ed7ff commit c40e6d6

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
@@ -1049,6 +1049,7 @@ io_check_errors(PyObject *errors)
10491049

10501050

10511051
/*[clinic input]
1052+
@critical_section
10521053
_io.TextIOWrapper.__init__
10531054
buffer: object
10541055
encoding: str(accept={str, NoneType}) = None
@@ -1092,7 +1093,7 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
10921093
const char *encoding, PyObject *errors,
10931094
const char *newline, int line_buffering,
10941095
int write_through)
1095-
/*[clinic end generated code: output=72267c0c01032ed2 input=e6cfaaaf6059d4f5]*/
1096+
/*[clinic end generated code: output=72267c0c01032ed2 input=0f077220214c40a4]*/
10961097
{
10971098
PyObject *raw, *codec_info = NULL;
10981099
PyObject *res;

0 commit comments

Comments
 (0)