Kaydet (Commit) 8a31c820 authored tarafından Victor Stinner's avatar Victor Stinner

Fix PyObject_Call() parameter names

Issue #27128: arg=>args, kw=>kwargs.

Same change for PyEval_CallObjectWithKeywords().
üst 0d1a7993
...@@ -264,7 +264,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ ...@@ -264,7 +264,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/ */
PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable_object, PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable_object,
PyObject *args, PyObject *kw); PyObject *args, PyObject *kwargs);
#ifndef Py_LIMITED_API #ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject*) _PyStack_AsTuple(PyObject **stack, PyAPI_FUNC(PyObject*) _PyStack_AsTuple(PyObject **stack,
......
...@@ -8,7 +8,7 @@ extern "C" { ...@@ -8,7 +8,7 @@ extern "C" {
/* Interface to random parts in ceval.c */ /* Interface to random parts in ceval.c */
PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords( PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
PyObject *, PyObject *, PyObject *); PyObject *func, PyObject *args, PyObject *kwargs);
/* Inline this */ /* Inline this */
#define PyEval_CallObject(func,arg) \ #define PyEval_CallObject(func,arg) \
......
...@@ -2194,7 +2194,7 @@ _Py_CheckFunctionResult(PyObject *func, PyObject *result, const char *where) ...@@ -2194,7 +2194,7 @@ _Py_CheckFunctionResult(PyObject *func, PyObject *result, const char *where)
} }
PyObject * PyObject *
PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) PyObject_Call(PyObject *func, PyObject *args, PyObject *kwargs)
{ {
ternaryfunc call; ternaryfunc call;
PyObject *result; PyObject *result;
...@@ -2203,6 +2203,8 @@ PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) ...@@ -2203,6 +2203,8 @@ PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
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 */
assert(!PyErr_Occurred()); assert(!PyErr_Occurred());
assert(PyTuple_Check(args));
assert(kwargs == NULL || PyDict_Check(kwargs));
call = func->ob_type->tp_call; call = func->ob_type->tp_call;
if (call == NULL) { if (call == NULL) {
...@@ -2214,7 +2216,7 @@ PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) ...@@ -2214,7 +2216,7 @@ PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
if (Py_EnterRecursiveCall(" while calling a Python object")) if (Py_EnterRecursiveCall(" while calling a Python object"))
return NULL; return NULL;
result = (*call)(func, arg, kw); result = (*call)(func, args, kwargs);
Py_LeaveRecursiveCall(); Py_LeaveRecursiveCall();
......
...@@ -4580,7 +4580,7 @@ PyEval_MergeCompilerFlags(PyCompilerFlags *cf) ...@@ -4580,7 +4580,7 @@ PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
The arg must be a tuple or NULL. The kw must be a dict or NULL. */ The arg must be a tuple or NULL. The kw must be a dict or NULL. */
PyObject * PyObject *
PyEval_CallObjectWithKeywords(PyObject *func, PyObject *arg, PyObject *kw) PyEval_CallObjectWithKeywords(PyObject *func, PyObject *args, PyObject *kwargs)
{ {
PyObject *result; PyObject *result;
...@@ -4591,32 +4591,33 @@ PyEval_CallObjectWithKeywords(PyObject *func, PyObject *arg, PyObject *kw) ...@@ -4591,32 +4591,33 @@ PyEval_CallObjectWithKeywords(PyObject *func, PyObject *arg, PyObject *kw)
assert(!PyErr_Occurred()); assert(!PyErr_Occurred());
#endif #endif
if (arg == NULL) { if (args == NULL) {
if (kw == NULL) { if (kwargs == NULL) {
return _PyObject_FastCall(func, NULL, 0, 0); return _PyObject_FastCall(func, NULL, 0, 0);
} }
arg = PyTuple_New(0); args = PyTuple_New(0);
if (arg == NULL) if (args == NULL)
return NULL; return NULL;
} }
else if (!PyTuple_Check(arg)) { else if (!PyTuple_Check(args)) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"argument list must be a tuple"); "argument list must be a tuple");
return NULL; return NULL;
} }
else else {
Py_INCREF(arg); Py_INCREF(args);
}
if (kw != NULL && !PyDict_Check(kw)) { if (kwargs != NULL && !PyDict_Check(kwargs)) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"keyword list must be a dictionary"); "keyword list must be a dictionary");
Py_DECREF(arg); Py_DECREF(args);
return NULL; return NULL;
} }
result = PyObject_Call(func, arg, kw); result = PyObject_Call(func, args, kwargs);
Py_DECREF(arg); Py_DECREF(args);
return result; return result;
} }
......
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