Skip to content

Commit 897e813

Browse files
committed
gh-60107: gh-138616: Minor code changes
1 parent 974cc01 commit 897e813

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Modules/_io/iobase.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ static PyObject *
921921
_io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n)
922922
/*[clinic end generated code: output=6cdeb731e3c9f13c input=b6d0dcf6417d1374]*/
923923
{
924-
PyObject *b, *res;
924+
PyObject *b, *res, *mv;
925925

926926
if (n < 0) {
927927
return PyObject_CallMethodNoArgs(self, &_Py_ID(readall));
@@ -931,7 +931,7 @@ _io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n)
931931
if (b == NULL)
932932
return NULL;
933933

934-
PyObject *mv = PyMemoryView_FromMemory(PyBytes_AS_STRING(b), n, PyBUF_WRITE);
934+
mv = PyMemoryView_FromMemory(PyBytes_AS_STRING(b), n, PyBUF_WRITE);
935935
if (mv == NULL) {
936936
Py_DECREF(b);
937937
return NULL;
@@ -952,11 +952,9 @@ _io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n)
952952
return NULL;
953953
}
954954

955-
if (n != PyBytes_GET_SIZE(b)) {
956-
if (_PyBytes_Resize(&b, n) < 0) {
957-
Py_DECREF(b);
958-
return NULL;
959-
}
955+
if (_PyBytes_Resize(&b, n) < 0) {
956+
Py_DECREF(b);
957+
return NULL;
960958
}
961959

962960
return b;

0 commit comments

Comments
 (0)