Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
24 changes: 8 additions & 16 deletions Modules/_bisectmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ internal_bisect_right(PyObject *list, PyObject *item, Py_ssize_t lo, Py_ssize_t
Py_ssize_t mid;
int res;

if (lo < 0) {
PyErr_SetString(PyExc_ValueError, "lo must be non-negative");
return -1;
}
if (hi == -1) {
hi = PySequence_Size(list);
if (hi < 0)
Expand Down Expand Up @@ -153,7 +149,7 @@ _bisect.bisect_right -> Py_ssize_t

a: object
x: object
lo: Py_ssize_t = 0
lo: Py_ssize_t(allow_negative=False) = 0
hi: Py_ssize_t(c_default='-1', accept={int, NoneType}) = None
*
key: object = None
Expand All @@ -173,7 +169,7 @@ A custom key function can be supplied to customize the sort order.
static Py_ssize_t
_bisect_bisect_right_impl(PyObject *module, PyObject *a, PyObject *x,
Py_ssize_t lo, Py_ssize_t hi, PyObject *key)
/*[clinic end generated code: output=3a4bc09cc7c8a73d input=43071869772dd53a]*/
/*[clinic end generated code: output=3a4bc09cc7c8a73d input=b476bc45667273ac]*/
{
return internal_bisect_right(a, x, lo, hi, key);
}
Expand All @@ -183,7 +179,7 @@ _bisect.insort_right

a: object
x: object
lo: Py_ssize_t = 0
lo: Py_ssize_t(allow_negative=False) = 0
hi: Py_ssize_t(c_default='-1', accept={int, NoneType}) = None
*
key: object = None
Expand All @@ -201,7 +197,7 @@ A custom key function can be supplied to customize the sort order.
static PyObject *
_bisect_insort_right_impl(PyObject *module, PyObject *a, PyObject *x,
Py_ssize_t lo, Py_ssize_t hi, PyObject *key)
/*[clinic end generated code: output=ac3bf26d07aedda2 input=f60777d2b6ddb239]*/
/*[clinic end generated code: output=ac3bf26d07aedda2 input=f2caa8abec0763e8]*/
{
PyObject *result, *key_x;
Py_ssize_t index;
Expand Down Expand Up @@ -241,10 +237,6 @@ internal_bisect_left(PyObject *list, PyObject *item, Py_ssize_t lo, Py_ssize_t h
Py_ssize_t mid;
int res;

if (lo < 0) {
PyErr_SetString(PyExc_ValueError, "lo must be non-negative");
return -1;
}
if (hi == -1) {
hi = PySequence_Size(list);
if (hi < 0)
Expand Down Expand Up @@ -338,7 +330,7 @@ _bisect.bisect_left -> Py_ssize_t

a: object
x: object
lo: Py_ssize_t = 0
lo: Py_ssize_t(allow_negative=False) = 0
hi: Py_ssize_t(c_default='-1', accept={int, NoneType}) = None
*
key: object = None
Expand All @@ -358,7 +350,7 @@ A custom key function can be supplied to customize the sort order.
static Py_ssize_t
_bisect_bisect_left_impl(PyObject *module, PyObject *a, PyObject *x,
Py_ssize_t lo, Py_ssize_t hi, PyObject *key)
/*[clinic end generated code: output=70749d6e5cae9284 input=f29c4fe7f9b797c7]*/
/*[clinic end generated code: output=70749d6e5cae9284 input=9b4d49b5ddecfad7]*/
{
return internal_bisect_left(a, x, lo, hi, key);
}
Expand All @@ -369,7 +361,7 @@ _bisect.insort_left

a: object
x: object
lo: Py_ssize_t = 0
lo: Py_ssize_t(allow_negative=False) = 0
hi: Py_ssize_t(c_default='-1', accept={int, NoneType}) = None
*
key: object = None
Expand All @@ -387,7 +379,7 @@ A custom key function can be supplied to customize the sort order.
static PyObject *
_bisect_insort_left_impl(PyObject *module, PyObject *a, PyObject *x,
Py_ssize_t lo, Py_ssize_t hi, PyObject *key)
/*[clinic end generated code: output=b1d33e5e7ffff11e input=0a700a82edbd472c]*/
/*[clinic end generated code: output=b1d33e5e7ffff11e input=ff85a79826e22f31]*/
{
PyObject *result, *key_x;
Py_ssize_t index;
Expand Down
21 changes: 4 additions & 17 deletions Modules/_ctypes/_ctypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ _ctypes.CDataType.from_buffer as CDataType_from_buffer
type: self
cls: defining_class
obj: object
offset: Py_ssize_t = 0
offset: Py_ssize_t(allow_negative=False) = 0
/

C.from_buffer(object, offset=0) -> C instance
Expand All @@ -870,7 +870,7 @@ Create a C instance from a writeable buffer.
static PyObject *
CDataType_from_buffer_impl(PyObject *type, PyTypeObject *cls, PyObject *obj,
Py_ssize_t offset)
/*[clinic end generated code: output=57604e99635abd31 input=0f36cedd105ca28d]*/
/*[clinic end generated code: output=57604e99635abd31 input=8f43e6bc44373180]*/
{
PyObject *mv;
PyObject *result;
Expand Down Expand Up @@ -906,13 +906,6 @@ CDataType_from_buffer_impl(PyObject *type, PyTypeObject *cls, PyObject *obj,
return NULL;
}

if (offset < 0) {
PyErr_SetString(PyExc_ValueError,
"offset cannot be negative");
Py_DECREF(mv);
return NULL;
}

if (info->size > buffer->len - offset) {
PyErr_Format(PyExc_ValueError,
"Buffer size too small "
Expand Down Expand Up @@ -955,7 +948,7 @@ _ctypes.CDataType.from_buffer_copy as CDataType_from_buffer_copy
type: self
cls: defining_class
buffer: Py_buffer
offset: Py_ssize_t = 0
offset: Py_ssize_t(allow_negative=False) = 0
/

C.from_buffer_copy(object, offset=0) -> C instance
Expand All @@ -966,7 +959,7 @@ Create a C instance from a readable buffer.
static PyObject *
CDataType_from_buffer_copy_impl(PyObject *type, PyTypeObject *cls,
Py_buffer *buffer, Py_ssize_t offset)
/*[clinic end generated code: output=c8fc62b03e5cc6fa input=2a81e11b765a6253]*/
/*[clinic end generated code: output=c8fc62b03e5cc6fa input=41f97f512295ceec]*/
{
PyObject *result;

Expand All @@ -980,12 +973,6 @@ CDataType_from_buffer_copy_impl(PyObject *type, PyTypeObject *cls,
return NULL;
}

if (offset < 0) {
PyErr_SetString(PyExc_ValueError,
"offset cannot be negative");
return NULL;
}

if (info->size > buffer->len - offset) {
PyErr_Format(PyExc_ValueError,
"Buffer size too small (%zd instead of at least %zd bytes)",
Expand Down
12 changes: 11 additions & 1 deletion Modules/_ctypes/clinic/_ctypes.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 4 additions & 14 deletions Modules/_hashopenssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1017,23 +1017,18 @@ static PyType_Spec HASHobject_type_spec = {
/*[clinic input]
_hashlib.HASHXOF.digest

length: Py_ssize_t
length: Py_ssize_t(allow_negative=False)

Return the digest value as a bytes object.
[clinic start generated code]*/

static PyObject *
_hashlib_HASHXOF_digest_impl(HASHobject *self, Py_ssize_t length)
/*[clinic end generated code: output=dcb09335dd2fe908 input=3eb034ce03c55b21]*/
/*[clinic end generated code: output=dcb09335dd2fe908 input=224d047da2c12a42]*/
{
EVP_MD_CTX *temp_ctx;
PyObject *retval;

if (length < 0) {
PyErr_SetString(PyExc_ValueError, "negative digest length");
return NULL;
}

if (length == 0) {
return Py_GetConstant(Py_CONSTANT_EMPTY_BYTES);
}
Expand Down Expand Up @@ -1072,24 +1067,19 @@ _hashlib_HASHXOF_digest_impl(HASHobject *self, Py_ssize_t length)
/*[clinic input]
_hashlib.HASHXOF.hexdigest

length: Py_ssize_t
length: Py_ssize_t(allow_negative=False)

Return the digest value as a string of hexadecimal digits.
[clinic start generated code]*/

static PyObject *
_hashlib_HASHXOF_hexdigest_impl(HASHobject *self, Py_ssize_t length)
/*[clinic end generated code: output=519431cafa014f39 input=0e58f7238adb7ab8]*/
/*[clinic end generated code: output=519431cafa014f39 input=4a41b8ab5d3bfee2]*/
{
unsigned char *digest;
EVP_MD_CTX *temp_ctx;
PyObject *retval;

if (length < 0) {
PyErr_SetString(PyExc_ValueError, "negative digest length");
return NULL;
}

if (length == 0) {
return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
Expand Down
8 changes: 2 additions & 6 deletions Modules/arraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down
22 changes: 21 additions & 1 deletion Modules/clinic/_bisectmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion Modules/clinic/_hashopenssl.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Modules/clinic/arraymodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading