mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
GH-135763: AC: Use `Py_ssize_t(allow_negative=False)` (#138394)
This commit is contained in:
parent
32032ee376
commit
98b4cd6fe9
18 changed files with 152 additions and 126 deletions
|
|
@ -1518,7 +1518,7 @@ array.array.fromfile
|
|||
|
||||
cls: defining_class
|
||||
f: object
|
||||
n: Py_ssize_t
|
||||
n: Py_ssize_t(allow_negative=False)
|
||||
/
|
||||
|
||||
Read n objects from the file object f and append them to the end of the array.
|
||||
|
|
@ -1527,17 +1527,13 @@ Read n objects from the file object f and append them to the end of the array.
|
|||
static PyObject *
|
||||
array_array_fromfile_impl(arrayobject *self, PyTypeObject *cls, PyObject *f,
|
||||
Py_ssize_t n)
|
||||
/*[clinic end generated code: output=83a667080b345ebc input=b2b4bdfb7ad4d4ae]*/
|
||||
/*[clinic end generated code: output=83a667080b345ebc input=db46b06ac1b6de87]*/
|
||||
{
|
||||
PyObject *b, *res;
|
||||
Py_ssize_t itemsize = self->ob_descr->itemsize;
|
||||
Py_ssize_t nbytes;
|
||||
int not_enough_bytes;
|
||||
|
||||
if (n < 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "negative count");
|
||||
return NULL;
|
||||
}
|
||||
if (n > PY_SSIZE_T_MAX / itemsize) {
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue