[Python-checkins] cpython: Fix PyObject_Call() parameter names

victor.stinner python-checkins at python.org
Fri Aug 19 11:32:22 EDT 2016


https://hg.python.org/cpython/rev/f1ad6f64a11e
changeset:   102763:f1ad6f64a11e
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri Aug 19 17:12:23 2016 +0200
summary:
  Fix PyObject_Call() parameter names

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

Same change for PyEval_CallObjectWithKeywords().

files:
  Include/abstract.h |   2 +-
  Include/ceval.h    |   2 +-
  Objects/abstract.c |   6 ++++--
  Python/ceval.c     |  27 ++++++++++++++-------------
  4 files changed, 20 insertions(+), 17 deletions(-)


diff --git a/Include/abstract.h b/Include/abstract.h
--- a/Include/abstract.h
+++ b/Include/abstract.h
@@ -264,7 +264,7 @@
        */
 
      PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable_object,
-                                          PyObject *args, PyObject *kw);
+                                          PyObject *args, PyObject *kwargs);
 
 #ifndef Py_LIMITED_API
     PyAPI_FUNC(PyObject*) _PyStack_AsTuple(PyObject **stack,
diff --git a/Include/ceval.h b/Include/ceval.h
--- a/Include/ceval.h
+++ b/Include/ceval.h
@@ -8,7 +8,7 @@
 /* Interface to random parts in ceval.c */
 
 PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
-    PyObject *, PyObject *, PyObject *);
+    PyObject *func, PyObject *args, PyObject *kwargs);
 
 /* Inline this */
 #define PyEval_CallObject(func,arg) \
diff --git a/Objects/abstract.c b/Objects/abstract.c
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2194,7 +2194,7 @@
 }
 
 PyObject *
-PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
+PyObject_Call(PyObject *func, PyObject *args, PyObject *kwargs)
 {
     ternaryfunc call;
     PyObject *result;
@@ -2203,6 +2203,8 @@
        because it may clear it (directly or indirectly) and so the
        caller loses its exception */
     assert(!PyErr_Occurred());
+    assert(PyTuple_Check(args));
+    assert(kwargs == NULL || PyDict_Check(kwargs));
 
     call = func->ob_type->tp_call;
     if (call == NULL) {
@@ -2214,7 +2216,7 @@
     if (Py_EnterRecursiveCall(" while calling a Python object"))
         return NULL;
 
-    result = (*call)(func, arg, kw);
+    result = (*call)(func, args, kwargs);
 
     Py_LeaveRecursiveCall();
 
diff --git a/Python/ceval.c b/Python/ceval.c
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -4580,7 +4580,7 @@
    The arg must be a tuple or NULL.  The kw must be a dict or NULL. */
 
 PyObject *
-PyEval_CallObjectWithKeywords(PyObject *func, PyObject *arg, PyObject *kw)
+PyEval_CallObjectWithKeywords(PyObject *func, PyObject *args, PyObject *kwargs)
 {
     PyObject *result;
 
@@ -4591,32 +4591,33 @@
     assert(!PyErr_Occurred());
 #endif
 
-    if (arg == NULL) {
-        if (kw == NULL) {
+    if (args == NULL) {
+        if (kwargs == NULL) {
             return _PyObject_FastCall(func, NULL, 0, 0);
         }
 
-        arg = PyTuple_New(0);
-        if (arg == NULL)
+        args = PyTuple_New(0);
+        if (args == NULL)
             return NULL;
     }
-    else if (!PyTuple_Check(arg)) {
+    else if (!PyTuple_Check(args)) {
         PyErr_SetString(PyExc_TypeError,
                         "argument list must be a tuple");
         return NULL;
     }
-    else
-        Py_INCREF(arg);
-
-    if (kw != NULL && !PyDict_Check(kw)) {
+    else {
+        Py_INCREF(args);
+    }
+
+    if (kwargs != NULL && !PyDict_Check(kwargs)) {
         PyErr_SetString(PyExc_TypeError,
                         "keyword list must be a dictionary");
-        Py_DECREF(arg);
+        Py_DECREF(args);
         return NULL;
     }
 
-    result = PyObject_Call(func, arg, kw);
-    Py_DECREF(arg);
+    result = PyObject_Call(func, args, kwargs);
+    Py_DECREF(args);
 
     return result;
 }

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list