]> granicus.if.org Git - python/commitdiff
call_trampoline() now uses fast call
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 19 Aug 2016 23:22:57 +0000 (01:22 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 19 Aug 2016 23:22:57 +0000 (01:22 +0200)
Issue #27128.

Python/sysmodule.c

index 56175d9544e804effaf1de0ba3bc4ba844f5b504..74b8560ae842fdada1f4ed1050628ecad6567953 100644 (file)
@@ -368,34 +368,25 @@ static PyObject *
 call_trampoline(PyObject* callback,
                 PyFrameObject *frame, int what, PyObject *arg)
 {
-    PyObject *args;
-    PyObject *whatstr;
     PyObject *result;
+    PyObject *stack[3];
 
-    args = PyTuple_New(3);
-    if (args == NULL)
-        return NULL;
-    if (PyFrame_FastToLocalsWithError(frame) < 0)
+    if (PyFrame_FastToLocalsWithError(frame) < 0) {
         return NULL;
+    }
 
-    Py_INCREF(frame);
-    whatstr = whatstrings[what];
-    Py_INCREF(whatstr);
-    if (arg == NULL)
-        arg = Py_None;
-    Py_INCREF(arg);
-    PyTuple_SET_ITEM(args, 0, (PyObject *)frame);
-    PyTuple_SET_ITEM(args, 1, whatstr);
-    PyTuple_SET_ITEM(args, 2, arg);
+    stack[0] = (PyObject *)frame;
+    stack[1] = whatstrings[what];
+    stack[2] = (arg != NULL) ? arg : Py_None;
 
     /* call the Python-level function */
-    result = PyEval_CallObject(callback, args);
+    result = _PyObject_FastCall(callback, stack, 3, NULL);
+
     PyFrame_LocalsToFast(frame, 1);
-    if (result == NULL)
+    if (result == NULL) {
         PyTraceBack_Here(frame);
+    }
 
-    /* cleanup */
-    Py_DECREF(args);
     return result;
 }