File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3325,11 +3325,16 @@ static PyObject *
33253325_io_TextIOWrapper_closed_get_impl (textio * self )
33263326/*[clinic end generated code: output=b49b68f443a85e3c input=7dfcf43f63c7003d]*/
33273327{
3328- /* During destruction self->ok is 0 but self->buffer is non-NULL and this
3329- needs to error in that case which the safe buffer wrapper does not.
3328+ /* If partially constructed or deconstructed return that the underlying
3329+ buffer is closed.
3330+
3331+ The code managing the transition is responsible for closing. The closed
3332+ attribute is often called in re-initalization, as part of repr in error
3333+ cases, and when the I/O stack is garbage collected. */
3334+ if (self -> ok <= 0 ) {
3335+ Py_RETURN_TRUE ;
3336+ }
33303337
3331- Match original behavior by calling CHECK_ATTACHED explicitly. */
3332- CHECK_ATTACHED (self );
33333338 return buffer_getattr (self , & _Py_ID (closed ));
33343339}
33353340
You can’t perform that action at this time.
0 commit comments