summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2019-11-14 12:36:21 (GMT)
committerGitHub <noreply@github.com>2019-11-14 12:36:21 (GMT)
commit4d231bcc77ac8ce7d11bda0804130dcdd678f710 (patch)
tree5cb1019d966e2e29977430b0824d11ccf8bd24e4 /Python/bltinmodule.c
parentb9e681261cd5ce6db0a79461c58d7cc52cfa4902 (diff)
downloadcpython-4d231bcc77ac8ce7d11bda0804130dcdd678f710.zip
cpython-4d231bcc77ac8ce7d11bda0804130dcdd678f710.tar.gz
cpython-4d231bcc77ac8ce7d11bda0804130dcdd678f710.tar.bz2
bpo-38644: Add _PyObject_Call() (GH-17089)
* Add pycore_call.h internal header file. * Add _PyObject_Call(): PyObject_Call() with tstate * Add _PyObject_CallNoArgTstate(): _PyObject_CallNoArg() with tstate * Add _PyObject_FastCallDictTstate(): _PyObject_FastCallDict() with tstate * _PyObject_Call_Prepend() now takes tstate * Replace _PyObject_FastCall() calls with _PyObject_VectorcallTstate() calls
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r--Python/bltinmodule.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index d79e254..4470310 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -4,6 +4,7 @@
#include <ctype.h>
#include "ast.h"
#undef Yield /* undefine macro conflicting with <winbase.h> */
+#include "pycore_pyerrors.h"
#include "pycore_pystate.h"
#include "pycore_tupleobject.h"
@@ -1254,23 +1255,23 @@ map_next(mapobject *lz)
{
PyObject *small_stack[_PY_FASTCALL_SMALL_STACK];
PyObject **stack;
- Py_ssize_t niters, nargs, i;
PyObject *result = NULL;
+ PyThreadState *tstate = _PyThreadState_GET();
- niters = PyTuple_GET_SIZE(lz->iters);
+ const Py_ssize_t niters = PyTuple_GET_SIZE(lz->iters);
if (niters <= (Py_ssize_t)Py_ARRAY_LENGTH(small_stack)) {
stack = small_stack;
}
else {
stack = PyMem_Malloc(niters * sizeof(stack[0]));
if (stack == NULL) {
- PyErr_NoMemory();
+ _PyErr_NoMemory(tstate);
return NULL;
}
}
- nargs = 0;
- for (i=0; i < niters; i++) {
+ Py_ssize_t nargs = 0;
+ for (Py_ssize_t i=0; i < niters; i++) {
PyObject *it = PyTuple_GET_ITEM(lz->iters, i);
PyObject *val = Py_TYPE(it)->tp_iternext(it);
if (val == NULL) {
@@ -1280,10 +1281,10 @@ map_next(mapobject *lz)
nargs++;
}
- result = _PyObject_FastCall(lz->func, stack, nargs);
+ result = _PyObject_VectorcallTstate(tstate, lz->func, stack, nargs, NULL);
exit:
- for (i=0; i < nargs; i++) {
+ for (Py_ssize_t i=0; i < nargs; i++) {
Py_DECREF(stack[i]);
}
if (stack != small_stack) {