Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8a31c82

Browse files
committed
Fix PyObject_Call() parameter names
Issue #27128: arg=>args, kw=>kwargs. Same change for PyEval_CallObjectWithKeywords().
1 parent 0d1a799 commit 8a31c82

4 files changed

Lines changed: 19 additions & 16 deletions

File tree

Include/abstract.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
264264
*/
265265

266266
PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable_object,
267-
PyObject *args, PyObject *kw);
267+
PyObject *args, PyObject *kwargs);
268268

269269
#ifndef Py_LIMITED_API
270270
PyAPI_FUNC(PyObject*) _PyStack_AsTuple(PyObject **stack,

Include/ceval.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern "C" {
88
/* Interface to random parts in ceval.c */
99

1010
PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
11-
PyObject *, PyObject *, PyObject *);
11+
PyObject *func, PyObject *args, PyObject *kwargs);
1212

1313
/* Inline this */
1414
#define PyEval_CallObject(func,arg) \

Objects/abstract.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,7 +2194,7 @@ _Py_CheckFunctionResult(PyObject *func, PyObject *result, const char *where)
21942194
}
21952195

21962196
PyObject *
2197-
PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
2197+
PyObject_Call(PyObject *func, PyObject *args, PyObject *kwargs)
21982198
{
21992199
ternaryfunc call;
22002200
PyObject *result;
@@ -2203,6 +2203,8 @@ PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
22032203
because it may clear it (directly or indirectly) and so the
22042204
caller loses its exception */
22052205
assert(!PyErr_Occurred());
2206+
assert(PyTuple_Check(args));
2207+
assert(kwargs == NULL || PyDict_Check(kwargs));
22062208

22072209
call = func->ob_type->tp_call;
22082210
if (call == NULL) {
@@ -2214,7 +2216,7 @@ PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
22142216
if (Py_EnterRecursiveCall(" while calling a Python object"))
22152217
return NULL;
22162218

2217-
result = (*call)(func, arg, kw);
2219+
result = (*call)(func, args, kwargs);
22182220

22192221
Py_LeaveRecursiveCall();
22202222

Python/ceval.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4580,7 +4580,7 @@ PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
45804580
The arg must be a tuple or NULL. The kw must be a dict or NULL. */
45814581

45824582
PyObject *
4583-
PyEval_CallObjectWithKeywords(PyObject *func, PyObject *arg, PyObject *kw)
4583+
PyEval_CallObjectWithKeywords(PyObject *func, PyObject *args, PyObject *kwargs)
45844584
{
45854585
PyObject *result;
45864586

@@ -4591,32 +4591,33 @@ PyEval_CallObjectWithKeywords(PyObject *func, PyObject *arg, PyObject *kw)
45914591
assert(!PyErr_Occurred());
45924592
#endif
45934593

4594-
if (arg == NULL) {
4595-
if (kw == NULL) {
4594+
if (args == NULL) {
4595+
if (kwargs == NULL) {
45964596
return _PyObject_FastCall(func, NULL, 0, 0);
45974597
}
45984598

4599-
arg = PyTuple_New(0);
4600-
if (arg == NULL)
4599+
args = PyTuple_New(0);
4600+
if (args == NULL)
46014601
return NULL;
46024602
}
4603-
else if (!PyTuple_Check(arg)) {
4603+
else if (!PyTuple_Check(args)) {
46044604
PyErr_SetString(PyExc_TypeError,
46054605
"argument list must be a tuple");
46064606
return NULL;
46074607
}
4608-
else
4609-
Py_INCREF(arg);
4608+
else {
4609+
Py_INCREF(args);
4610+
}
46104611

4611-
if (kw != NULL && !PyDict_Check(kw)) {
4612+
if (kwargs != NULL && !PyDict_Check(kwargs)) {
46124613
PyErr_SetString(PyExc_TypeError,
46134614
"keyword list must be a dictionary");
4614-
Py_DECREF(arg);
4615+
Py_DECREF(args);
46154616
return NULL;
46164617
}
46174618

4618-
result = PyObject_Call(func, arg, kw);
4619-
Py_DECREF(arg);
4619+
result = PyObject_Call(func, args, kwargs);
4620+
Py_DECREF(args);
46204621

46214622
return result;
46224623
}

0 commit comments

Comments
 (0)