Skip to content

Commit 1974630

Browse files
committed
fix invalid return value in newlines
1 parent 15e972b commit 1974630

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Modules/_io/stringio.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -977,11 +977,11 @@ stringio_closed(stringio *self, void *context)
977977
if (self->ok <= 0) {
978978
PyErr_SetString(PyExc_ValueError,
979979
"I/O operation on uninitialized object");
980-
goto cleanup;
980+
goto exit;
981981
};
982982
result = PyBool_FromLong(self->closed);
983983

984-
cleanup:
984+
exit:
985985
Py_END_CRITICAL_SECTION();
986986
return result;
987987
}
@@ -995,15 +995,15 @@ stringio_line_buffering(stringio *self, void *context)
995995
if (self->ok <= 0) {
996996
PyErr_SetString(PyExc_ValueError,
997997
"I/O operation on uninitialized object");
998-
goto cleanup;
998+
goto exit;
999999
};
10001000
if (self->closed) {
10011001
PyErr_SetString(PyExc_ValueError, "I/O operation on closed file");
1002-
goto cleanup;
1002+
goto exit;
10031003
};
10041004
result = Py_NewRef(Py_False);
10051005

1006-
cleanup:
1006+
exit:
10071007
Py_END_CRITICAL_SECTION();
10081008
return result;
10091009
}
@@ -1017,18 +1017,19 @@ stringio_newlines(stringio *self, void *context)
10171017
if (self->ok <= 0) {
10181018
PyErr_SetString(PyExc_ValueError,
10191019
"I/O operation on uninitialized object");
1020-
goto cleanup;
1020+
goto exit;
10211021
};
10221022
if (self->closed) {
10231023
PyErr_SetString(PyExc_ValueError, "I/O operation on closed file");
1024-
goto cleanup;
1024+
goto exit;
10251025
};
10261026
if (self->decoder == NULL) {
1027-
goto cleanup;
1027+
result = Py_NewRef(Py_None);
1028+
goto exit;
10281029
}
10291030
result = PyObject_GetAttr(self->decoder, &_Py_ID(newlines));
10301031

1031-
cleanup:
1032+
exit:
10321033
Py_END_CRITICAL_SECTION();
10331034
return result;
10341035
}

0 commit comments

Comments
 (0)