8000 bpo-47116: use _PyLong_FromUnsignedChar instead of PyLong_FromLong by eendebakpt · Pull Request #32110 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-47116: use _PyLong_FromUnsignedChar instead of PyLong_FromLong #32110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Objects/bytearrayobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ bytearray_getitem(PyByteArrayObject *self, Py_ssize_t i)
PyErr_SetString(PyExc_IndexError, "bytearray index out of range");
return NULL;
}
return PyLong_FromLong((unsigned char)(PyByteArray_AS_STRING(self)[i]));
return _PyLong_FromUnsignedChar((unsigned char)(self->ob_start[i]));
}

static PyObject *
Expand All @@ -415,7 +415,7 @@ bytearray_subscript(PyByteArrayObject *self, PyObject *index)
PyErr_SetString(PyExc_IndexError, "bytearray index out of range");
return NULL;
}
return PyLong_FromLong((unsigned char)(PyByteArray_AS_STRING(self)[i]));
return _PyLong_FromUnsignedChar((unsigned char)(self->ob_start[i]));
}
else if (PySlice_Check(index)) {
Py_ssize_t start, stop, step, slicelength, i;
Expand Down Expand Up @@ -1841,7 +1841,7 @@ bytearray_pop_impl(PyByteArrayObject *self, Py_ssize_t index)
if (PyByteArray_Resize((PyObject *)self, n - 1) < 0)
return NULL;

return PyLong_FromLong((unsigned char)value);
return _PyLong_FromUnsignedChar((unsigned char)value);
}

/*[clinic input]
Expand Down
< 8000 /div>
4 changes: 2 additions & 2 deletions Objects/bytesobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,7 @@ bytes_item(PyBytesObject *a, Py_ssize_t i)
PyErr_SetString(PyExc_IndexError, "index out of range");
return NULL;
}
return PyLong_FromLong((unsigned char)a->ob_sval[i]);
return _PyLong_FromUnsignedChar((unsigned char)a->ob_sval[i]);
}

static int
Expand Down Expand Up @@ -1595,7 +1595,7 @@ bytes_subscript(PyBytesObject* self, PyObject* item)
"index out of range");
return NULL;
}
return PyLong_FromLong((unsigned char)self->ob_sval[i]);
return _PyLong_FromUnsignedChar((unsigned char)self->ob_sval[i]);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength, i;
Expand Down
0