diff options
author | Pieter Eendebak <pieter.eendebak@gmail.com> | 2022-03-26 19:47:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-26 19:47:38 (GMT) |
commit | c23ddf5ec229b7302437a1cf32d366df5cc5b837 (patch) | |
tree | c073f9b67377bc1963b21470aca471a72f9b279a /Objects | |
parent | e8e737bcf6d22927caebc30c5d57ac4634063219 (diff) | |
download | cpython-c23ddf5ec229b7302437a1cf32d366df5cc5b837.zip cpython-c23ddf5ec229b7302437a1cf32d366df5cc5b837.tar.gz cpython-c23ddf5ec229b7302437a1cf32d366df5cc5b837.tar.bz2 |
bpo-47116: use _PyLong_FromUnsignedChar instead of PyLong_FromLong (GH-32110)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/bytearrayobject.c | 6 | ||||
-rw-r--r-- | Objects/bytesobject.c | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index cbe673a..74267cf 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -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 * @@ -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; @@ -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] diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 0039532..56c941a 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -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 @@ -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; |