Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4e64198

Browse files
Fix state assignment
1 parent e9b0a27 commit 4e64198

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Modules/_io/textio.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,8 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
11691169

11701170
self->buffer = Py_NewRef(buffer);
11711171

1172+
_PyIO_State *state = find_io_state_by_def(Py_TYPE(self));
1173+
self->state = state;
11721174
/* Build the decoder object */
11731175
if (_textiowrapper_set_decoder(self, codec_info, PyUnicode_AsUTF8(errors)) != 0)
11741176
goto error;
@@ -1180,7 +1182,6 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
11801182
/* Finished sorting out the codec details */
11811183
Py_CLEAR(codec_info);
11821184

1183-
_PyIO_State *state = find_io_state_by_def(Py_TYPE(self));
11841185
if (Py_IS_TYPE(buffer, state->PyBufferedReader_Type) ||
11851186
Py_IS_TYPE(buffer, state->PyBufferedWriter_Type) ||
11861187
Py_IS_TYPE(buffer, state->PyBufferedRandom_Type))
@@ -1216,8 +1217,7 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
12161217
if (_textiowrapper_fix_encoder_state(self) < 0) {
12171218
goto error;
12181219
}
1219-
1220-
self->state = state;
1220+
12211221
self->ok = 1;
12221222
return 0;
12231223

0 commit comments

Comments
 (0)