Commit 74319ae2 authored by Victor Stinner's avatar Victor Stinner

Use Py_ssize_t type for number of arguments

Issue #27848: use Py_ssize_t rather than C int for the number of function
positional and keyword arguments.
parent c532b3c1
...@@ -280,7 +280,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ ...@@ -280,7 +280,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
Return the result on success. Raise an exception on return NULL on Return the result on success. Raise an exception on return NULL on
error. */ error. */
PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(PyObject *func, PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(PyObject *func,
PyObject **args, int nargs, PyObject **args, Py_ssize_t nargs,
PyObject *kwargs); PyObject *kwargs);
#define _PyObject_FastCall(func, args, nargs) \ #define _PyObject_FastCall(func, args, nargs) \
......
...@@ -61,7 +61,8 @@ PyAPI_FUNC(int) PyFunction_SetAnnotations(PyObject *, PyObject *); ...@@ -61,7 +61,8 @@ PyAPI_FUNC(int) PyFunction_SetAnnotations(PyObject *, PyObject *);
#ifndef Py_LIMITED_API #ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) _PyFunction_FastCallDict( PyAPI_FUNC(PyObject *) _PyFunction_FastCallDict(
PyObject *func, PyObject *func,
PyObject **args, int nargs, PyObject **args,
Py_ssize_t nargs,
PyObject *kwargs); PyObject *kwargs);
#endif #endif
......
...@@ -39,7 +39,8 @@ PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *); ...@@ -39,7 +39,8 @@ PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *);
#ifndef Py_LIMITED_API #ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) _PyCFunction_FastCallDict(PyObject *func, PyAPI_FUNC(PyObject *) _PyCFunction_FastCallDict(PyObject *func,
PyObject **args, int nargs, PyObject **args,
Py_ssize_t nargs,
PyObject *kwargs); PyObject *kwargs);
#endif #endif
......
...@@ -2255,7 +2255,7 @@ _PyStack_AsTuple(PyObject **stack, Py_ssize_t nargs) ...@@ -2255,7 +2255,7 @@ _PyStack_AsTuple(PyObject **stack, Py_ssize_t nargs)
} }
PyObject * PyObject *
_PyObject_FastCallDict(PyObject *func, PyObject **args, int nargs, _PyObject_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs,
PyObject *kwargs) PyObject *kwargs)
{ {
ternaryfunc call; ternaryfunc call;
......
...@@ -146,15 +146,20 @@ PyCFunction_Call(PyObject *func, PyObject *args, PyObject *kwds) ...@@ -146,15 +146,20 @@ PyCFunction_Call(PyObject *func, PyObject *args, PyObject *kwds)
} }
PyObject * PyObject *
_PyCFunction_FastCallDict(PyObject *func_obj, PyObject **args, int nargs, _PyCFunction_FastCallDict(PyObject *func_obj, PyObject **args, Py_ssize_t nargs,
PyObject *kwargs) PyObject *kwargs)
{ {
PyCFunctionObject* func = (PyCFunctionObject*)func_obj; PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
PyCFunction meth = PyCFunction_GET_FUNCTION(func); PyCFunction meth = PyCFunction_GET_FUNCTION(func);
PyObject *self = PyCFunction_GET_SELF(func); PyObject *self = PyCFunction_GET_SELF(func);
PyObject *result; PyObject *result;
int flags; int flags;
assert(func != NULL);
assert(nargs >= 0);
assert(nargs == 0 || args != NULL);
assert(kwargs == NULL || PyDict_Check(kwargs));
/* _PyCFunction_FastCallDict() must not be called with an exception set, /* _PyCFunction_FastCallDict() must not be called with an exception set,
because it may clear it (directly or indirectly) and so the because it may clear it (directly or indirectly) and so the
caller loses its exception */ caller loses its exception */
......
...@@ -2095,7 +2095,7 @@ builtin_sorted(PyObject *self, PyObject *args, PyObject *kwds) ...@@ -2095,7 +2095,7 @@ builtin_sorted(PyObject *self, PyObject *args, PyObject *kwds)
PyObject *callable; PyObject *callable;
static char *kwlist[] = {"iterable", "key", "reverse", 0}; static char *kwlist[] = {"iterable", "key", "reverse", 0};
int reverse; int reverse;
int nargs; Py_ssize_t nargs;
/* args 1-3 should match listsort in Objects/listobject.c */ /* args 1-3 should match listsort in Objects/listobject.c */
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Oi:sorted", if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Oi:sorted",
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment