File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -673,7 +673,7 @@ struct textio
673673 int detached ;
674674 Py_ssize_t chunk_size ;
675675 /* Use helpers _textiowrapper_buffer_* to access buffer; many
676- operations can set it to NULL (ref: gh-143008, gh-142594). */
676+ operations can set it to NULL (see gh-143008, gh-142594). */
677677 PyObject * buffer ;
678678 PyObject * encoding ;
679679 PyObject * encoder ;
@@ -734,20 +734,22 @@ struct textio
734734/* Helpers to safely operate on self->buffer.
735735
736736self->buffer can be detached (set to NULL) by any user code that is called
737- leading to NULL pointer dereferences (ex. gh-143008, gh-142594). Protect against
737+ leading to NULL pointer dereferences (see gh-143008, gh-142594). Protect against
738738that by using helpers to check self->buffer validity at callsites. */
739739static PyObject *
740740_textiowrapper_buffer_safe (textio * self ) {
741741 /* Check self->buffer directly but match errors of CHECK_ATTACHED since this
742742 is called during construction and destruction where self->ok which
743743 CHECK_ATTACHED uses does not imply self->buffer state. */
744744 if (self -> buffer == NULL ) {
745- if (self -> ok <= 0 )
745+ if (self -> ok <= 0 ) {
746746 PyErr_SetString (PyExc_ValueError ,
747747 "I/O operation on uninitialized object" );
748- else
748+ }
749+ else {
749750 PyErr_SetString (PyExc_ValueError ,
750751 "underlying buffer has been detached" );
752+ }
751753 return NULL ;
752754 }
753755 return self -> buffer ;
You can’t perform that action at this time.
0 commit comments