summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-06-30 01:05:01 (GMT)
committerGitHub <noreply@github.com>2023-06-30 01:05:01 (GMT)
commit8c5f74fc89e35827c52753fe620b32207d537319 (patch)
tree62a1eba40b01250e97f2c5cd263456b4cb7e734a /Python/ceval.c
parente7bc8d16364bde54487eab349a29d58345e35f28 (diff)
downloadcpython-8c5f74fc89e35827c52753fe620b32207d537319.zip
cpython-8c5f74fc89e35827c52753fe620b32207d537319.tar.gz
cpython-8c5f74fc89e35827c52753fe620b32207d537319.tar.bz2
gh-106023: Update code using _PyObject_FastCall() (#106257)
Replace _PyObject_FastCall() calls with PyObject_Vectorcall().
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 65b6f24..2010e9e 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -4,7 +4,7 @@
#include "Python.h"
#include "pycore_abstract.h" // _PyIndex_Check()
-#include "pycore_call.h" // _PyObject_FastCallDictTstate()
+#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_ceval.h" // _PyEval_SignalAsyncExc()
#include "pycore_code.h"
#include "pycore_function.h"
@@ -2431,40 +2431,37 @@ static PyObject *
import_name(PyThreadState *tstate, _PyInterpreterFrame *frame,
PyObject *name, PyObject *fromlist, PyObject *level)
{
- PyObject *import_func, *res;
- PyObject* stack[5];
-
- import_func = _PyDict_GetItemWithError(frame->f_builtins, &_Py_ID(__import__));
+ PyObject *import_func = _PyDict_GetItemWithError(frame->f_builtins,
+ &_Py_ID(__import__));
if (import_func == NULL) {
if (!_PyErr_Occurred(tstate)) {
_PyErr_SetString(tstate, PyExc_ImportError, "__import__ not found");
}
return NULL;
}
+
PyObject *locals = frame->f_locals;
+ if (locals == NULL) {
+ locals = Py_None;
+ }
+
/* Fast path for not overloaded __import__. */
if (_PyImport_IsDefaultImportFunc(tstate->interp, import_func)) {
int ilevel = _PyLong_AsInt(level);
if (ilevel == -1 && _PyErr_Occurred(tstate)) {
return NULL;
}
- res = PyImport_ImportModuleLevelObject(
+ return PyImport_ImportModuleLevelObject(
name,
frame->f_globals,
- locals == NULL ? Py_None :locals,
+ locals,
fromlist,
ilevel);
- return res;
}
+ PyObject* args[5] = {name, frame->f_globals, locals, fromlist, level};
Py_INCREF(import_func);
-
- stack[0] = name;
- stack[1] = frame->f_globals;
- stack[2] = locals == NULL ? Py_None : locals;
- stack[3] = fromlist;
- stack[4] = level;
- res = _PyObject_FastCall(import_func, stack, 5);
+ PyObject *res = PyObject_Vectorcall(import_func, args, 5, NULL);
Py_DECREF(import_func);
return res;
}