MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / PyObject_Vectorcall

Function PyObject_Vectorcall

asyncpg/protocol/record/pythoncapi_compat.h:610–679  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

608// gh-105922 added PyObject_Vectorcall() to Python 3.9.0a4
609#if PY_VERSION_HEX < 0x030900A4
610static inline PyObject*
611PyObject_Vectorcall(PyObject *callable, PyObject *const *args,
612 size_t nargsf, PyObject *kwnames)
613{
614#if PY_VERSION_HEX >= 0x030800B1 && !defined(PYPY_VERSION)
615 // bpo-36974 added _PyObject_Vectorcall() to Python 3.8.0b1
616 return _PyObject_Vectorcall(callable, args, nargsf, kwnames);
617#else
618 PyObject *posargs = NULL, *kwargs = NULL;
619 PyObject *res;
620 Py_ssize_t nposargs, nkwargs, i;
621
622 if (nargsf != 0 && args == NULL) {
623 PyErr_BadInternalCall();
624 goto error;
625 }
626 if (kwnames != NULL && !PyTuple_Check(kwnames)) {
627 PyErr_BadInternalCall();
628 goto error;
629 }
630
631 nposargs = (Py_ssize_t)PyVectorcall_NARGS(nargsf);
632 if (kwnames) {
633 nkwargs = PyTuple_GET_SIZE(kwnames);
634 }
635 else {
636 nkwargs = 0;
637 }
638
639 posargs = PyTuple_New(nposargs);
640 if (posargs == NULL) {
641 goto error;
642 }
643 if (nposargs) {
644 for (i=0; i < nposargs; i++) {
645 PyTuple_SET_ITEM(posargs, i, Py_NewRef(*args));
646 args++;
647 }
648 }
649
650 if (nkwargs) {
651 kwargs = PyDict_New();
652 if (kwargs == NULL) {
653 goto error;
654 }
655
656 for (i = 0; i < nkwargs; i++) {
657 PyObject *key = PyTuple_GET_ITEM(kwnames, i);
658 PyObject *value = *args;
659 args++;
660 if (PyDict_SetItem(kwargs, key, value) < 0) {
661 goto error;
662 }
663 }
664 }
665 else {
666 kwargs = NULL;
667 }

Callers

nothing calls this directly

Calls 1

PyVectorcall_NARGSFunction · 0.85

Tested by

no test coverage detected