]> granicus.if.org Git - python/commitdiff
Fix PyObject_Call() parameter names
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 19 Aug 2016 15:12:23 +0000 (17:12 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 19 Aug 2016 15:12:23 +0000 (17:12 +0200)
Issue #27128: arg=>args, kw=>kwargs.

Same change for PyEval_CallObjectWithKeywords().

Include/abstract.h
Include/ceval.h
Objects/abstract.c
Python/ceval.c

index 280402cae3dfa0544d5a004db79460e8964a67cb..f67c6b215998a532dc3b3911adb7781834206e47 100644 (file)
@@ -264,7 +264,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
        */
 
      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,
index d194044911e9eb8216e73b2c410c3d3d34c1e7e6..73b4ca632821e26fc7e9e184b1cbcbce889b927b 100644 (file)
@@ -8,7 +8,7 @@ extern "C" {
 /* 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) \
index aaa6fc81b6923400e70391b255d805935f8152cc..dcf3eb55454723b7f717f87bee12b50b1d4ea27f 100644 (file)
@@ -2194,7 +2194,7 @@ _Py_CheckFunctionResult(PyObject *func, PyObject *result, const char *where)
 }
 
 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 @@ PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
        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 @@ PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
     if (Py_EnterRecursiveCall(" while calling a Python object"))
         return NULL;
 
-    result = (*call)(func, arg, kw);
+    result = (*call)(func, args, kwargs);
 
     Py_LeaveRecursiveCall();
 
index 75eaa8110a28f16fb0be96e0a4e901c2080eb9a9..905859ef3b611c254a36afe0d6abc749d3e6bffc 100644 (file)
@@ -4580,7 +4580,7 @@ PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
    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 @@ PyEval_CallObjectWithKeywords(PyObject *func, PyObject *arg, PyObject *kw)
     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);
+    else {
+        Py_INCREF(args);
+    }
 
-    if (kw != NULL && !PyDict_Check(kw)) {
+    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;
 }