]> granicus.if.org Git - python/commitdiff
Rename _PyObject_FastCall() to _PyObject_FastCallDict()
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 22 Aug 2016 20:48:54 +0000 (22:48 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 22 Aug 2016 20:48:54 +0000 (22:48 +0200)
Issue #27809:

* Rename _PyObject_FastCall() function to _PyObject_FastCallDict()
* Add _PyObject_FastCall(), _PyObject_CallNoArg() and _PyObject_CallArg1()
  macros calling _PyObject_FastCallDict()

12 files changed:
Include/abstract.h
Modules/_elementtree.c
Modules/_functoolsmodule.c
Modules/_pickle.c
Modules/_sre.c
Objects/abstract.c
Objects/fileobject.c
Objects/iterobject.c
Objects/typeobject.c
Python/ceval.c
Python/pythonrun.c
Python/sysmodule.c

index f67c6b215998a532dc3b3911adb7781834206e47..69c4890a9e7dbb7f94ee493b522e1c9c1da87e44 100644 (file)
@@ -279,9 +279,18 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
 
         Return the result on success. Raise an exception on return NULL on
         error. */
-     PyAPI_FUNC(PyObject *) _PyObject_FastCall(PyObject *func,
-                                               PyObject **args, int nargs,
-                                               PyObject *kwargs);
+     PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(PyObject *func,
+                                                   PyObject **args, int nargs,
+                                                   PyObject *kwargs);
+
+#define _PyObject_FastCall(func, args, nargs) \
+    _PyObject_FastCallDict((func), (args), (nargs), NULL)
+
+#define _PyObject_CallNoArg(func) \
+    _PyObject_FastCall((func), NULL, 0)
+
+#define _PyObject_CallArg1(func, arg) \
+    _PyObject_FastCall((func), &(arg), 1)
 
      PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *func,
                                                     PyObject *result,
@@ -291,7 +300,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
        /*
      Call a callable Python object, callable_object, with
      arguments and keywords arguments.  The 'args' argument can not be
-     NULL, but the 'kw' argument can be NULL.
+     NULL.
        */
 
      PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable_object,
index 5d124b3b423ba56f6a6febf70edd4b0fc7955273..721293aabef1ea8496020a1d91e1a04d8a7348b1 100644 (file)
@@ -858,7 +858,7 @@ deepcopy(PyObject *object, PyObject *memo)
 
     stack[0] = object;
     stack[1] = memo;
-    return _PyObject_FastCall(st->deepcopy_obj, stack, 2, NULL);
+    return _PyObject_FastCall(st->deepcopy_obj, stack, 2);
 }
 
 
index f7dbf15ab3d88c1b9bad38194fc25664ea16a22b..22e8088890baac1cfe444096b58763b0b1ad8aa2 100644 (file)
@@ -492,7 +492,7 @@ keyobject_richcompare(PyObject *ko, PyObject *other, int op)
      */
     stack[0] = x;
     stack[1] = y;
-    res = _PyObject_FastCall(compare, stack, 2, NULL);
+    res = _PyObject_FastCall(compare, stack, 2);
     if (res == NULL) {
         return NULL;
     }
index b454134270c4acd91740e499726a304f86a011db..fed3fa221e7df6de1adca5caac1e8b77ebab89f6 100644 (file)
@@ -357,7 +357,7 @@ _Pickle_FastCall(PyObject *func, PyObject *obj)
        significantly reduced the number of function calls we do. Thus, the
        benefits became marginal at best. */
 
-    result = _PyObject_FastCall(func, &obj, 1, NULL);
+    result = _PyObject_CallArg1(func, obj);
     Py_DECREF(obj);
     return result;
 }
@@ -1151,7 +1151,7 @@ _Unpickler_ReadFromFile(UnpicklerObject *self, Py_ssize_t n)
         return -1;
 
     if (n == READ_WHOLE_LINE) {
-        data = _PyObject_FastCall(self->readline, NULL, 0, NULL);
+        data = _PyObject_CallNoArg(self->readline);
     }
     else {
         PyObject *len;
@@ -3948,7 +3948,7 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
             /* Check for a __reduce__ method. */
             reduce_func = _PyObject_GetAttrId(obj, &PyId___reduce__);
             if (reduce_func != NULL) {
-                reduce_value = _PyObject_FastCall(reduce_func, NULL, 0, NULL);
+                reduce_value = _PyObject_CallNoArg(reduce_func);
             }
             else {
                 PyErr_Format(st->PicklingError,
index 3e8d7f8b48d76d34d9a2000f944bb926b7ebb78b..0a62f62dc65665050c545903b9718822884f88ee 100644 (file)
@@ -1157,7 +1157,7 @@ pattern_subx(PatternObject* self, PyObject* ptemplate, PyObject* string,
             match = pattern_new_match(self, &state, 1);
             if (!match)
                 goto error;
-            item = _PyObject_FastCall(filter, &match, 1, NULL);
+            item = _PyObject_CallArg1(filter, match);
             Py_DECREF(match);
             if (!item)
                 goto error;
index 32d4575788783a49977498680b19062e0fed215e..2ce7f327e92195cd5fd5b6ae27bca1834254c617 100644 (file)
@@ -2255,12 +2255,12 @@ _PyStack_AsTuple(PyObject **stack, Py_ssize_t nargs)
 }
 
 PyObject *
-_PyObject_FastCall(PyObject *func, PyObject **args, int nargs, PyObject *kwargs)
+_PyObject_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs)
 {
     ternaryfunc call;
     PyObject *result = NULL;
 
-    /* _PyObject_FastCall() must not be called with an exception set,
+    /* _PyObject_FastCallDict() must not be called with an exception set,
        because it may clear it (directly or indirectly) and so the
        caller loses its exception */
     assert(!PyErr_Occurred());
@@ -2318,7 +2318,7 @@ call_function_tail(PyObject *callable, PyObject *args)
     assert(args != NULL);
 
     if (!PyTuple_Check(args)) {
-        result = _PyObject_FastCall(callable, &args, 1, NULL);
+        result = _PyObject_CallArg1(callable, args);
     }
     else {
         result = PyObject_Call(callable, args, NULL);
@@ -2338,7 +2338,7 @@ PyObject_CallFunction(PyObject *callable, const char *format, ...)
     }
 
     if (!format || !*format) {
-        return _PyObject_FastCall(callable, NULL, 0, NULL);
+        return _PyObject_CallNoArg(callable);
     }
 
     va_start(va, format);
@@ -2364,7 +2364,7 @@ _PyObject_CallFunction_SizeT(PyObject *callable, const char *format, ...)
     }
 
     if (!format || !*format) {
-        return _PyObject_FastCall(callable, NULL, 0, NULL);
+        return _PyObject_CallNoArg(callable);
     }
 
     va_start(va, format);
@@ -2392,7 +2392,7 @@ callmethod(PyObject* func, const char *format, va_list va, int is_size_t)
     }
 
     if (!format || !*format) {
-        return _PyObject_FastCall(func, NULL, 0, NULL);
+        return _PyObject_CallNoArg(func);
     }
 
     if (is_size_t) {
index 83348a8ee3c79adbd04ec16d34eaffa934690519..f4424184d2df1beae58ae7beec0f037cbb3aa59c 100644 (file)
@@ -146,7 +146,7 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
         Py_DECREF(writer);
         return -1;
     }
-    result = _PyObject_FastCall(writer, &value, 1, NULL);
+    result = _PyObject_CallArg1(writer, value);
     Py_DECREF(value);
     Py_DECREF(writer);
     if (result == NULL)
index a8e6e1c0c75e1b7b11b49d7a696c35df9d39dc97..75b2fcbd411302f9a892de03cabc391225b03462 100644 (file)
@@ -214,7 +214,7 @@ calliter_iternext(calliterobject *it)
         return NULL;
     }
 
-    result = _PyObject_FastCall(it->it_callable, NULL, 0, NULL);
+    result = _PyObject_CallNoArg(it->it_callable);
     if (result != NULL) {
         int ok;
 
index 0f183558532745a2e43a2718ff5b26c8540bc32c..544d0b5f4ede26f937ce38f1df34377a81c0f4f6 100644 (file)
@@ -1450,7 +1450,7 @@ call_method(PyObject *o, _Py_Identifier *nameid, const char *format, ...)
         Py_DECREF(args);
     }
     else {
-        retval = _PyObject_FastCall(func, NULL, 0, NULL);
+        retval = _PyObject_CallNoArg(func);
     }
 
     Py_DECREF(func);
@@ -1490,7 +1490,7 @@ call_maybe(PyObject *o, _Py_Identifier *nameid, const char *format, ...)
         Py_DECREF(args);
     }
     else {
-        retval = _PyObject_FastCall(func, NULL, 0, NULL);
+        retval = _PyObject_CallNoArg(func);
     }
 
     Py_DECREF(func);
@@ -5834,7 +5834,7 @@ slot_sq_item(PyObject *self, Py_ssize_t i)
         goto error;
     }
 
-    retval = _PyObject_FastCall(func, &ival, 1, NULL);
+    retval = _PyObject_CallArg1(func, ival);
     Py_DECREF(func);
     Py_DECREF(ival);
     return retval;
@@ -5875,7 +5875,7 @@ slot_sq_contains(PyObject *self, PyObject *value)
         return -1;
     }
     if (func != NULL) {
-        res = _PyObject_FastCall(func, &value, 1, NULL);
+        res = _PyObject_CallArg1(func, value);
         Py_DECREF(func);
         if (res != NULL) {
             result = PyObject_IsTrue(res);
@@ -5967,7 +5967,7 @@ slot_nb_bool(PyObject *self)
         using_len = 1;
     }
 
-    value = _PyObject_FastCall(func, NULL, 0, NULL);
+    value = _PyObject_CallNoArg(func);
     if (value == NULL) {
         goto error;
     }
@@ -6245,7 +6245,7 @@ slot_tp_richcompare(PyObject *self, PyObject *other, int op)
         PyErr_Clear();
         Py_RETURN_NOTIMPLEMENTED;
     }
-    res = _PyObject_FastCall(func, &other, 1, NULL);
+    res = _PyObject_CallArg1(func, other);
     Py_DECREF(func);
     return res;
 }
@@ -6266,7 +6266,7 @@ slot_tp_iter(PyObject *self)
     }
 
     if (func != NULL) {
-        res = _PyObject_FastCall(func, NULL, 0, NULL);
+        res = _PyObject_CallNoArg(func);
         Py_DECREF(func);
         return res;
     }
index bd0cbe758f68e03b8320c00eec111c127f7e0567..96380bca96cdddc7eb4cfc2bd0921141a98cafae 100644 (file)
@@ -4593,7 +4593,7 @@ PyEval_CallObjectWithKeywords(PyObject *func, PyObject *args, PyObject *kwargs)
 
     if (args == NULL) {
         if (kwargs == NULL) {
-            return _PyObject_FastCall(func, NULL, 0, 0);
+            return _PyObject_CallNoArg(func);
         }
 
         args = PyTuple_New(0);
@@ -5298,7 +5298,7 @@ import_name(PyFrameObject *f, PyObject *name, PyObject *fromlist, PyObject *leve
     stack[2] = f->f_locals == NULL ? Py_None : f->f_locals;
     stack[3] = fromlist;
     stack[4] = level;
-    res = _PyObject_FastCall(import_func, stack, 5, NULL);
+    res = _PyObject_FastCall(import_func, stack, 5);
     Py_DECREF(import_func);
     return res;
 }
index 2968b34cc8ed28d7fa66269c296720b6f7162265..3fb6f15dd7ccf45ef58e670947e0f626ed2daa9e 100644 (file)
@@ -636,7 +636,7 @@ PyErr_PrintEx(int set_sys_last_vars)
         stack[0] = exception;
         stack[1] = v;
         stack[2] = tb;
-        result = _PyObject_FastCall(hook, stack, 3, NULL);
+        result = _PyObject_FastCall(hook, stack, 3);
         if (result == NULL) {
             PyObject *exception2, *v2, *tb2;
             if (PyErr_ExceptionMatches(PyExc_SystemExit)) {
index be8e164bba2035d781e0cfd5e8e8d17b363d7e40..c170bd5889f58ab66cda47c88e58a8e76fb51ee6 100644 (file)
@@ -380,7 +380,7 @@ call_trampoline(PyObject* callback,
     stack[2] = (arg != NULL) ? arg : Py_None;
 
     /* call the Python-level function */
-    result = _PyObject_FastCall(callback, stack, 3, NULL);
+    result = _PyObject_FastCall(callback, stack, 3);
 
     PyFrame_LocalsToFast(frame, 1);
     if (result == NULL) {
@@ -2122,7 +2122,7 @@ sys_pyfile_write_unicode(PyObject *unicode, PyObject *file)
     if (writer == NULL)
         goto error;
 
-    result = _PyObject_FastCall(writer, &unicode, 1, NULL);
+    result = _PyObject_CallArg1(writer, unicode);
     if (result == NULL) {
         goto error;
     } else {