7#include "nuitka/prelude.h"
10PyObject *CALL_FUNCTION_NO_ARGS(PyThreadState *tstate, PyObject *called) {
13 if (Nuitka_Function_Check(called)) {
14 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
21 if (function->m_args_simple && 0 == function->m_args_positional_count) {
22 result = function->m_c_code(tstate, function, NULL);
23 }
else if (function->m_args_simple && 0 + function->m_defaults_given == function->m_args_positional_count) {
24 PyObject **python_pars = &PyTuple_GET_ITEM(function->m_defaults, 0);
26 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
27 Py_INCREF(python_pars[i]);
30 result = function->m_c_code(tstate, function, python_pars);
32 result = Nuitka_CallFunctionNoArgs(tstate, function);
35 Py_LeaveRecursiveCall();
37 CHECK_OBJECT_X(result);
40 }
else if (Nuitka_Method_Check(called)) {
43 if (method->m_object == NULL) {
46 "unbound compiled_method %s%s must be called with %s instance as first argument (got nothing instead)",
47 GET_CALLABLE_NAME((PyObject *)method->m_function), GET_CALLABLE_DESC((PyObject *)method->m_function),
48 GET_CLASS_NAME(method->m_class));
51 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
59 if (function->m_args_simple && 0 + 1 == function->m_args_positional_count) {
60 PyObject *python_pars[0 + 1];
62 python_pars[0] = method->m_object;
63 Py_INCREF(method->m_object);
65 result = function->m_c_code(tstate, function, python_pars);
66 }
else if (function->m_args_simple &&
67 0 + 1 + function->m_defaults_given == function->m_args_positional_count) {
68 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
70 python_pars[0] = method->m_object;
71 Py_INCREF(method->m_object);
73 memcpy(python_pars + 1 + 0, &PyTuple_GET_ITEM(function->m_defaults, 0),
74 function->m_defaults_given *
sizeof(PyObject *));
76 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
77 Py_INCREF(python_pars[i]);
80 result = function->m_c_code(tstate, function, python_pars);
82 result = Nuitka_CallMethodFunctionNoArgs(tstate, function, method->m_object);
85 Py_LeaveRecursiveCall();
87 CHECK_OBJECT_X(result);
91#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
92 }
else if (PyCFunction_CheckExact(called)) {
93#if PYTHON_VERSION >= 0x380
94#ifdef _NUITKA_FULL_COMPAT
95 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
100 int flags = PyCFunction_GET_FLAGS(called);
104 if (!(flags & METH_VARARGS)) {
105 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
107 assert(func != NULL);
108 result = func(called, NULL, 0, NULL);
110 CHECK_OBJECT_X(result);
112 PyCFunction method = PyCFunction_GET_FUNCTION(called);
113 PyObject *self = PyCFunction_GET_SELF(called);
115 PyObject *pos_args = const_tuple_empty;
117 if (flags & METH_KEYWORDS) {
118 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
120 result = (*method)(self, pos_args);
124#ifdef _NUITKA_FULL_COMPAT
125 Py_LeaveRecursiveCall();
127 CHECK_OBJECT_X(result);
129 return Nuitka_CheckFunctionResult(tstate, called, result);
132 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
134 if (likely(flags & METH_NOARGS)) {
137#ifdef _NUITKA_FULL_COMPAT
138 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
142 PyCFunction method = PyCFunction_GET_FUNCTION(called);
143 PyObject *self = PyCFunction_GET_SELF(called);
145 PyObject *result = (*method)(self, NULL);
147#ifdef _NUITKA_FULL_COMPAT
148 Py_LeaveRecursiveCall();
150 CHECK_OBJECT_X(result);
152 return Nuitka_CheckFunctionResult(tstate, called, result);
153 }
else if (unlikely(flags & METH_O)) {
154 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (0 given)",
155 ((PyCFunctionObject *)called)->m_ml->ml_name);
157 }
else if (flags & METH_VARARGS) {
160#ifdef _NUITKA_FULL_COMPAT
161 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
165 PyCFunction method = PyCFunction_GET_FUNCTION(called);
166 PyObject *self = PyCFunction_GET_SELF(called);
170#if PYTHON_VERSION < 0x360
171 PyObject *pos_args = const_tuple_empty;
172 if (flags & METH_KEYWORDS) {
173 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
175 result = (*method)(self, pos_args);
179 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
180 PyObject *pos_args = const_tuple_empty;
181 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
182 }
else if (flags == METH_FASTCALL) {
183#if PYTHON_VERSION < 0x370
184 result = (*(_PyCFunctionFast)method)(self, NULL, 0, NULL);
186 PyObject *pos_args = const_tuple_empty;
187 result = (*(_PyCFunctionFast)method)(self, &pos_args, 0);
190 PyObject *pos_args = const_tuple_empty;
191 result = (*method)(self, pos_args);
195#ifdef _NUITKA_FULL_COMPAT
196 Py_LeaveRecursiveCall();
199 CHECK_OBJECT_X(result);
201 return Nuitka_CheckFunctionResult(tstate, called, result);
205#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
206 }
else if (PyFunction_Check(called)) {
207#if PYTHON_VERSION < 0x3b0
208 PyObject *result = callPythonFunctionNoArgs(called);
210 PyObject *result = _PyFunction_Vectorcall(called, NULL, 0, NULL);
212 CHECK_OBJECT_X(result);
216#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
217 }
else if (PyType_Check(called)) {
218 PyTypeObject *type = Py_TYPE(called);
220 if (type->tp_call == PyType_Type.tp_call) {
221 PyTypeObject *called_type = (PyTypeObject *)(called);
223 if (unlikely(called_type->tp_new == NULL)) {
224 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
228 PyObject *pos_args = const_tuple_empty;
231 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
232 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
233 formatCannotInstantiateAbstractClass(tstate, called_type);
237 obj = called_type->tp_alloc(called_type, 0);
240 obj = called_type->tp_new(called_type, pos_args, NULL);
243 if (likely(obj != NULL)) {
244 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
251 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
252 if (type->tp_init == default_tp_init_wrapper) {
254 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
257 assert(init_method != NULL);
259 bool is_compiled_function =
false;
260 bool init_method_needs_release =
false;
262 if (likely(init_method != NULL)) {
263 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
265 if (func == Nuitka_Function_Type.tp_descr_get) {
266 is_compiled_function =
true;
267 }
else if (func != NULL) {
268 init_method = func(init_method, obj, (PyObject *)(type));
269 init_method_needs_release =
true;
273 if (unlikely(init_method == NULL)) {
274 if (!HAS_ERROR_OCCURRED(tstate)) {
275 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
276 const_str_plain___init__);
283 if (is_compiled_function) {
284 result = Nuitka_CallMethodFunctionNoArgs(
287 result = CALL_FUNCTION_NO_ARGS(tstate, init_method);
289 if (init_method_needs_release) {
290 Py_DECREF(init_method);
294 if (unlikely(result == NULL)) {
301 if (unlikely(result != Py_None)) {
304 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
309 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
322#if PYTHON_VERSION < 0x300
323 }
else if (PyClass_Check(called)) {
324 PyObject *obj = PyInstance_NewRaw(called, NULL);
326 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
328 if ((init_method == NULL)) {
329 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
337 bool is_compiled_function =
false;
339 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
341 if (descr_get == NULL) {
342 Py_INCREF(init_method);
343 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
344 is_compiled_function =
true;
345 }
else if (descr_get != NULL) {
346 PyObject *descr_method = descr_get(init_method, obj, called);
348 if (unlikely(descr_method == NULL)) {
352 init_method = descr_method;
356 if (is_compiled_function) {
357 result = Nuitka_CallMethodFunctionNoArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj);
359 result = CALL_FUNCTION_NO_ARGS(tstate, init_method);
360 Py_DECREF(init_method);
362 if (unlikely(result == NULL)) {
368 if (unlikely(result != Py_None)) {
369 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
377#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
378 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
379 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
381 if (likely(func != NULL)) {
382 PyObject *result = func(called, NULL, 0, NULL);
384 CHECK_OBJECT_X(result);
386 return Nuitka_CheckFunctionResult(tstate, called, result);
393 PRINT_STRING(
"FALLBACK");
398 PyObject *result = CALL_FUNCTION(tstate, called, const_tuple_empty, NULL);
400 CHECK_OBJECT_X(result);
404PyObject *CALL_FUNCTION_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *called, PyObject *arg) {
405 PyObject *
const *args = &arg;
406 CHECK_OBJECT(called);
407 CHECK_OBJECTS(args, 1);
409 if (Nuitka_Function_Check(called)) {
410 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
417 if (function->m_args_simple && 1 == function->m_args_positional_count) {
419 result = function->m_c_code(tstate, function, (PyObject **)args);
420 }
else if (function->m_args_simple && 1 + function->m_defaults_given == function->m_args_positional_count) {
421 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
423 memcpy(python_pars, args, 1 *
sizeof(PyObject *));
424 memcpy(python_pars + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
425 function->m_defaults_given *
sizeof(PyObject *));
427 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
428 Py_INCREF(python_pars[i]);
431 result = function->m_c_code(tstate, function, python_pars);
433 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 1);
436 Py_LeaveRecursiveCall();
438 CHECK_OBJECT_X(result);
441 }
else if (Nuitka_Method_Check(called)) {
444 if (method->m_object == NULL) {
445 PyObject *self = args[0];
447 int res = PyObject_IsInstance(self, method->m_class);
449 if (unlikely(res < 0)) {
451 }
else if (unlikely(res == 0)) {
452 PyErr_Format(PyExc_TypeError,
453 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
455 GET_CALLABLE_NAME((PyObject *)method->m_function),
456 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
457 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
462 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 1);
464 CHECK_OBJECT_X(result);
468 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
476 if (function->m_args_simple && 1 + 1 == function->m_args_positional_count) {
477 PyObject *python_pars[1 + 1];
479 python_pars[0] = method->m_object;
480 Py_INCREF(method->m_object);
482 python_pars[1] = args[0];
484 result = function->m_c_code(tstate, function, python_pars);
485 }
else if (function->m_args_simple &&
486 1 + 1 + function->m_defaults_given == function->m_args_positional_count) {
487 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
489 python_pars[0] = method->m_object;
490 Py_INCREF(method->m_object);
492 memcpy(python_pars + 1, args, 1 *
sizeof(PyObject *));
493 memcpy(python_pars + 1 + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
494 function->m_defaults_given *
sizeof(PyObject *));
496 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
497 Py_INCREF(python_pars[i]);
500 result = function->m_c_code(tstate, function, python_pars);
502 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 1);
505 Py_LeaveRecursiveCall();
507 CHECK_OBJECT_X(result);
511#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
512 }
else if (PyCFunction_CheckExact(called)) {
513#if PYTHON_VERSION >= 0x380
514#ifdef _NUITKA_FULL_COMPAT
515 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
520 int flags = PyCFunction_GET_FLAGS(called);
524 if (!(flags & METH_VARARGS)) {
525 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
527 assert(func != NULL);
528 result = func(called, args, 1, NULL);
530 CHECK_OBJECT_X(result);
532 PyCFunction method = PyCFunction_GET_FUNCTION(called);
533 PyObject *self = PyCFunction_GET_SELF(called);
535 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
537 if (flags & METH_KEYWORDS) {
538 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
540 result = (*method)(self, pos_args);
546#ifdef _NUITKA_FULL_COMPAT
547 Py_LeaveRecursiveCall();
549 CHECK_OBJECT_X(result);
551 return Nuitka_CheckFunctionResult(tstate, called, result);
554 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
556 if (unlikely(flags & METH_NOARGS)) {
557 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (1 given)",
558 ((PyCFunctionObject *)called)->m_ml->ml_name);
560 }
else if ((flags & METH_O)) {
563#ifdef _NUITKA_FULL_COMPAT
564 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
568 PyCFunction method = PyCFunction_GET_FUNCTION(called);
569 PyObject *self = PyCFunction_GET_SELF(called);
571 PyObject *result = (*method)(self, args[0]);
573#ifdef _NUITKA_FULL_COMPAT
574 Py_LeaveRecursiveCall();
577 CHECK_OBJECT_X(result);
579 return Nuitka_CheckFunctionResult(tstate, called, result);
580 }
else if (flags & METH_VARARGS) {
583#ifdef _NUITKA_FULL_COMPAT
584 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
588 PyCFunction method = PyCFunction_GET_FUNCTION(called);
589 PyObject *self = PyCFunction_GET_SELF(called);
593#if PYTHON_VERSION < 0x360
594 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
595 if (flags & METH_KEYWORDS) {
596 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
598 result = (*method)(self, pos_args);
603 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
604 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
605 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
607 }
else if (flags == METH_FASTCALL) {
608#if PYTHON_VERSION < 0x370
609 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 1, NULL);
611 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
612 result = (*(_PyCFunctionFast)method)(self, &pos_args, 1);
616 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
617 result = (*method)(self, pos_args);
622#ifdef _NUITKA_FULL_COMPAT
623 Py_LeaveRecursiveCall();
626 CHECK_OBJECT_X(result);
628 return Nuitka_CheckFunctionResult(tstate, called, result);
632#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
633 }
else if (PyFunction_Check(called)) {
634#if PYTHON_VERSION < 0x3b0
635 PyObject *result = callPythonFunction(called, args, 1);
637 PyObject *result = _PyFunction_Vectorcall(called, args, 1, NULL);
639 CHECK_OBJECT_X(result);
643#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
644 }
else if (PyType_Check(called)) {
645 PyTypeObject *type = Py_TYPE(called);
647 if (type->tp_call == PyType_Type.tp_call) {
648 PyTypeObject *called_type = (PyTypeObject *)(called);
650 if (unlikely(called == (PyObject *)&PyType_Type)) {
651 PyObject *result = (PyObject *)Py_TYPE(args[0]);
656 if (unlikely(called_type->tp_new == NULL)) {
657 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
661 PyObject *pos_args = NULL;
664 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
665 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
666 formatCannotInstantiateAbstractClass(tstate, called_type);
670 obj = called_type->tp_alloc(called_type, 0);
673 pos_args = MAKE_TUPLE(tstate, args, 1);
674 obj = called_type->tp_new(called_type, pos_args, NULL);
677 if (likely(obj != NULL)) {
678 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
686 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
687 if (type->tp_init == default_tp_init_wrapper) {
688 Py_XDECREF(pos_args);
691 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
694 assert(init_method != NULL);
696 bool is_compiled_function =
false;
697 bool init_method_needs_release =
false;
699 if (likely(init_method != NULL)) {
700 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
702 if (func == Nuitka_Function_Type.tp_descr_get) {
703 is_compiled_function =
true;
704 }
else if (func != NULL) {
705 init_method = func(init_method, obj, (PyObject *)(type));
706 init_method_needs_release =
true;
710 if (unlikely(init_method == NULL)) {
711 if (!HAS_ERROR_OCCURRED(tstate)) {
712 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
713 const_str_plain___init__);
720 if (is_compiled_function) {
721 result = Nuitka_CallMethodFunctionPosArgs(
724 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
726 if (init_method_needs_release) {
727 Py_DECREF(init_method);
731 if (unlikely(result == NULL)) {
738 if (unlikely(result != Py_None)) {
741 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
745 if (pos_args == NULL) {
746 pos_args = MAKE_TUPLE(tstate, args, 1);
749 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
751 Py_XDECREF(pos_args);
758 Py_XDECREF(pos_args);
765#if PYTHON_VERSION < 0x300
766 }
else if (PyClass_Check(called)) {
767 PyObject *obj = PyInstance_NewRaw(called, NULL);
769 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
771 if (unlikely(init_method == NULL)) {
772 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
779 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
783 bool is_compiled_function =
false;
785 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
787 if (descr_get == NULL) {
788 Py_INCREF(init_method);
789 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
790 is_compiled_function =
true;
791 }
else if (descr_get != NULL) {
792 PyObject *descr_method = descr_get(init_method, obj, called);
794 if (unlikely(descr_method == NULL)) {
798 init_method = descr_method;
802 if (is_compiled_function) {
803 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
806 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
807 Py_DECREF(init_method);
809 if (unlikely(result == NULL)) {
815 if (unlikely(result != Py_None)) {
816 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
824#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
825 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
826 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
828 if (likely(func != NULL)) {
829 PyObject *result = func(called, args, 1, NULL);
831 CHECK_OBJECT_X(result);
833 return Nuitka_CheckFunctionResult(tstate, called, result);
840 PRINT_STRING(
"FALLBACK");
845 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
847 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
851 CHECK_OBJECT_X(result);
855PyObject *CALL_FUNCTION_WITH_POS_ARGS1(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
856 assert(PyTuple_CheckExact(pos_args));
857 assert(PyTuple_GET_SIZE(pos_args) == 1);
858 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
859 CHECK_OBJECT(called);
860 CHECK_OBJECTS(args, 1);
862 if (Nuitka_Function_Check(called)) {
863 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
870 if (function->m_args_simple && 1 == function->m_args_positional_count) {
872 result = function->m_c_code(tstate, function, (PyObject **)args);
873 }
else if (function->m_args_simple && 1 + function->m_defaults_given == function->m_args_positional_count) {
874 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
876 memcpy(python_pars, args, 1 *
sizeof(PyObject *));
877 memcpy(python_pars + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
878 function->m_defaults_given *
sizeof(PyObject *));
880 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
881 Py_INCREF(python_pars[i]);
884 result = function->m_c_code(tstate, function, python_pars);
886 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 1);
889 Py_LeaveRecursiveCall();
891 CHECK_OBJECT_X(result);
894 }
else if (Nuitka_Method_Check(called)) {
897 if (method->m_object == NULL) {
898 PyObject *self = args[0];
900 int res = PyObject_IsInstance(self, method->m_class);
902 if (unlikely(res < 0)) {
904 }
else if (unlikely(res == 0)) {
905 PyErr_Format(PyExc_TypeError,
906 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
908 GET_CALLABLE_NAME((PyObject *)method->m_function),
909 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
910 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
915 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 1);
917 CHECK_OBJECT_X(result);
921 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
929 if (function->m_args_simple && 1 + 1 == function->m_args_positional_count) {
930 PyObject *python_pars[1 + 1];
932 python_pars[0] = method->m_object;
933 Py_INCREF(method->m_object);
935 python_pars[1] = args[0];
937 result = function->m_c_code(tstate, function, python_pars);
938 }
else if (function->m_args_simple &&
939 1 + 1 + function->m_defaults_given == function->m_args_positional_count) {
940 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
942 python_pars[0] = method->m_object;
943 Py_INCREF(method->m_object);
945 memcpy(python_pars + 1, args, 1 *
sizeof(PyObject *));
946 memcpy(python_pars + 1 + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
947 function->m_defaults_given *
sizeof(PyObject *));
949 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
950 Py_INCREF(python_pars[i]);
953 result = function->m_c_code(tstate, function, python_pars);
955 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 1);
958 Py_LeaveRecursiveCall();
960 CHECK_OBJECT_X(result);
964#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
965 }
else if (PyCFunction_CheckExact(called)) {
966#if PYTHON_VERSION >= 0x380
967#ifdef _NUITKA_FULL_COMPAT
968 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
973 int flags = PyCFunction_GET_FLAGS(called);
977 if (!(flags & METH_VARARGS)) {
978 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
980 assert(func != NULL);
981 result = func(called, args, 1, NULL);
983 CHECK_OBJECT_X(result);
985 PyCFunction method = PyCFunction_GET_FUNCTION(called);
986 PyObject *self = PyCFunction_GET_SELF(called);
988 if (flags & METH_KEYWORDS) {
989 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
991 result = (*method)(self, pos_args);
995#ifdef _NUITKA_FULL_COMPAT
996 Py_LeaveRecursiveCall();
998 CHECK_OBJECT_X(result);
1000 return Nuitka_CheckFunctionResult(tstate, called, result);
1003 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
1005 if (unlikely(flags & METH_NOARGS)) {
1006 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (1 given)",
1007 ((PyCFunctionObject *)called)->m_ml->ml_name);
1009 }
else if ((flags & METH_O)) {
1012#ifdef _NUITKA_FULL_COMPAT
1013 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1017 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1018 PyObject *self = PyCFunction_GET_SELF(called);
1020 PyObject *result = (*method)(self, args[0]);
1022#ifdef _NUITKA_FULL_COMPAT
1023 Py_LeaveRecursiveCall();
1026 CHECK_OBJECT_X(result);
1028 return Nuitka_CheckFunctionResult(tstate, called, result);
1029 }
else if (flags & METH_VARARGS) {
1032#ifdef _NUITKA_FULL_COMPAT
1033 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1037 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1038 PyObject *self = PyCFunction_GET_SELF(called);
1042#if PYTHON_VERSION < 0x360
1043 if (flags & METH_KEYWORDS) {
1044 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1046 result = (*method)(self, pos_args);
1050 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
1051 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1052 }
else if (flags == METH_FASTCALL) {
1053#if PYTHON_VERSION < 0x370
1054 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 1, NULL);
1056 result = (*(_PyCFunctionFast)method)(self, &pos_args, 1);
1059 result = (*method)(self, pos_args);
1063#ifdef _NUITKA_FULL_COMPAT
1064 Py_LeaveRecursiveCall();
1067 CHECK_OBJECT_X(result);
1069 return Nuitka_CheckFunctionResult(tstate, called, result);
1073#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
1074 }
else if (PyFunction_Check(called)) {
1075#if PYTHON_VERSION < 0x3b0
1076 PyObject *result = callPythonFunction(called, args, 1);
1078 PyObject *result = _PyFunction_Vectorcall(called, args, 1, NULL);
1080 CHECK_OBJECT_X(result);
1084#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
1085 }
else if (PyType_Check(called)) {
1086 PyTypeObject *type = Py_TYPE(called);
1088 if (type->tp_call == PyType_Type.tp_call) {
1089 PyTypeObject *called_type = (PyTypeObject *)(called);
1091 if (unlikely(called == (PyObject *)&PyType_Type)) {
1092 PyObject *result = (PyObject *)Py_TYPE(args[0]);
1097 if (unlikely(called_type->tp_new == NULL)) {
1098 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
1104 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
1105 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
1106 formatCannotInstantiateAbstractClass(tstate, called_type);
1110 obj = called_type->tp_alloc(called_type, 0);
1113 obj = called_type->tp_new(called_type, pos_args, NULL);
1116 if (likely(obj != NULL)) {
1117 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
1122 type = Py_TYPE(obj);
1124 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
1125 if (type->tp_init == default_tp_init_wrapper) {
1127 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
1130 assert(init_method != NULL);
1132 bool is_compiled_function =
false;
1133 bool init_method_needs_release =
false;
1135 if (likely(init_method != NULL)) {
1136 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
1138 if (func == Nuitka_Function_Type.tp_descr_get) {
1139 is_compiled_function =
true;
1140 }
else if (func != NULL) {
1141 init_method = func(init_method, obj, (PyObject *)(type));
1142 init_method_needs_release =
true;
1146 if (unlikely(init_method == NULL)) {
1147 if (!HAS_ERROR_OCCURRED(tstate)) {
1148 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
1149 const_str_plain___init__);
1156 if (is_compiled_function) {
1157 result = Nuitka_CallMethodFunctionPosArgs(
1160 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
1162 if (init_method_needs_release) {
1163 Py_DECREF(init_method);
1167 if (unlikely(result == NULL)) {
1174 if (unlikely(result != Py_None)) {
1177 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
1182 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
1190 CHECK_OBJECT_X(obj);
1195#if PYTHON_VERSION < 0x300
1196 }
else if (PyClass_Check(called)) {
1197 PyObject *obj = PyInstance_NewRaw(called, NULL);
1199 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
1201 if (unlikely(init_method == NULL)) {
1202 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
1209 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
1213 bool is_compiled_function =
false;
1215 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
1217 if (descr_get == NULL) {
1218 Py_INCREF(init_method);
1219 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
1220 is_compiled_function =
true;
1221 }
else if (descr_get != NULL) {
1222 PyObject *descr_method = descr_get(init_method, obj, called);
1224 if (unlikely(descr_method == NULL)) {
1228 init_method = descr_method;
1232 if (is_compiled_function) {
1233 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
1236 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
1237 Py_DECREF(init_method);
1239 if (unlikely(result == NULL)) {
1245 if (unlikely(result != Py_None)) {
1246 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
1250 CHECK_OBJECT_X(obj);
1254#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
1255 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
1256 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1258 if (likely(func != NULL)) {
1259 PyObject *result = func(called, args, 1, NULL);
1261 CHECK_OBJECT_X(result);
1263 return Nuitka_CheckFunctionResult(tstate, called, result);
1270 PRINT_STRING(
"FALLBACK");
1275 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
1277 CHECK_OBJECT_X(result);
1281PyObject *CALL_FUNCTION_WITH_ARGS2(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
1282 CHECK_OBJECT(called);
1283 CHECK_OBJECTS(args, 2);
1285 if (Nuitka_Function_Check(called)) {
1286 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1293 if (function->m_args_simple && 2 == function->m_args_positional_count) {
1294 for (Py_ssize_t i = 0; i < 2; i++) {
1297 result = function->m_c_code(tstate, function, (PyObject **)args);
1298 }
else if (function->m_args_simple && 2 + function->m_defaults_given == function->m_args_positional_count) {
1299 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1301 memcpy(python_pars, args, 2 *
sizeof(PyObject *));
1302 memcpy(python_pars + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1303 function->m_defaults_given *
sizeof(PyObject *));
1305 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
1306 Py_INCREF(python_pars[i]);
1309 result = function->m_c_code(tstate, function, python_pars);
1311 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 2);
1314 Py_LeaveRecursiveCall();
1316 CHECK_OBJECT_X(result);
1319 }
else if (Nuitka_Method_Check(called)) {
1322 if (method->m_object == NULL) {
1323 PyObject *self = args[0];
1325 int res = PyObject_IsInstance(self, method->m_class);
1327 if (unlikely(res < 0)) {
1329 }
else if (unlikely(res == 0)) {
1330 PyErr_Format(PyExc_TypeError,
1331 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
1332 "instance instead)",
1333 GET_CALLABLE_NAME((PyObject *)method->m_function),
1334 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
1335 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
1340 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 2);
1342 CHECK_OBJECT_X(result);
1346 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1354 if (function->m_args_simple && 2 + 1 == function->m_args_positional_count) {
1355 PyObject *python_pars[2 + 1];
1357 python_pars[0] = method->m_object;
1358 Py_INCREF(method->m_object);
1360 for (Py_ssize_t i = 0; i < 2; i++) {
1361 python_pars[i + 1] = args[i];
1364 result = function->m_c_code(tstate, function, python_pars);
1365 }
else if (function->m_args_simple &&
1366 2 + 1 + function->m_defaults_given == function->m_args_positional_count) {
1367 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1369 python_pars[0] = method->m_object;
1370 Py_INCREF(method->m_object);
1372 memcpy(python_pars + 1, args, 2 *
sizeof(PyObject *));
1373 memcpy(python_pars + 1 + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1374 function->m_defaults_given *
sizeof(PyObject *));
1376 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
1377 Py_INCREF(python_pars[i]);
1380 result = function->m_c_code(tstate, function, python_pars);
1382 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 2);
1385 Py_LeaveRecursiveCall();
1387 CHECK_OBJECT_X(result);
1391#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
1392 }
else if (PyCFunction_CheckExact(called)) {
1393#if PYTHON_VERSION >= 0x380
1394#ifdef _NUITKA_FULL_COMPAT
1395 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1400 int flags = PyCFunction_GET_FLAGS(called);
1404 if (!(flags & METH_VARARGS)) {
1405 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1407 assert(func != NULL);
1408 result = func(called, args, 2, NULL);
1410 CHECK_OBJECT_X(result);
1412 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1413 PyObject *self = PyCFunction_GET_SELF(called);
1415 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1417 if (flags & METH_KEYWORDS) {
1418 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
1420 result = (*method)(self, pos_args);
1423 Py_DECREF(pos_args);
1426#ifdef _NUITKA_FULL_COMPAT
1427 Py_LeaveRecursiveCall();
1429 CHECK_OBJECT_X(result);
1431 return Nuitka_CheckFunctionResult(tstate, called, result);
1434 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
1436 if (unlikely(flags & METH_NOARGS)) {
1437 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (2 given)",
1438 ((PyCFunctionObject *)called)->m_ml->ml_name);
1440 }
else if (unlikely(flags & METH_O)) {
1441 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (2 given)",
1442 ((PyCFunctionObject *)called)->m_ml->ml_name);
1444 }
else if (flags & METH_VARARGS) {
1447#ifdef _NUITKA_FULL_COMPAT
1448 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1452 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1453 PyObject *self = PyCFunction_GET_SELF(called);
1457#if PYTHON_VERSION < 0x360
1458 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1459 if (flags & METH_KEYWORDS) {
1460 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1462 result = (*method)(self, pos_args);
1465 Py_DECREF(pos_args);
1467 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
1468 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1469 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1470 Py_DECREF(pos_args);
1471 }
else if (flags == METH_FASTCALL) {
1472#if PYTHON_VERSION < 0x370
1473 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 2, NULL);
1475 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1476 result = (*(_PyCFunctionFast)method)(self, &pos_args, 2);
1477 Py_DECREF(pos_args);
1480 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1481 result = (*method)(self, pos_args);
1482 Py_DECREF(pos_args);
1486#ifdef _NUITKA_FULL_COMPAT
1487 Py_LeaveRecursiveCall();
1490 CHECK_OBJECT_X(result);
1492 return Nuitka_CheckFunctionResult(tstate, called, result);
1496#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
1497 }
else if (PyFunction_Check(called)) {
1498#if PYTHON_VERSION < 0x3b0
1499 PyObject *result = callPythonFunction(called, args, 2);
1501 PyObject *result = _PyFunction_Vectorcall(called, args, 2, NULL);
1503 CHECK_OBJECT_X(result);
1507#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
1508 }
else if (PyType_Check(called)) {
1509 PyTypeObject *type = Py_TYPE(called);
1511 if (type->tp_call == PyType_Type.tp_call) {
1512 PyTypeObject *called_type = (PyTypeObject *)(called);
1514 if (unlikely(called_type->tp_new == NULL)) {
1515 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
1519 PyObject *pos_args = NULL;
1522 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
1523 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
1524 formatCannotInstantiateAbstractClass(tstate, called_type);
1528 obj = called_type->tp_alloc(called_type, 0);
1531 pos_args = MAKE_TUPLE(tstate, args, 2);
1532 obj = called_type->tp_new(called_type, pos_args, NULL);
1535 if (likely(obj != NULL)) {
1536 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
1537 Py_DECREF(pos_args);
1542 type = Py_TYPE(obj);
1544 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
1545 if (type->tp_init == default_tp_init_wrapper) {
1546 Py_XDECREF(pos_args);
1549 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
1552 assert(init_method != NULL);
1554 bool is_compiled_function =
false;
1555 bool init_method_needs_release =
false;
1557 if (likely(init_method != NULL)) {
1558 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
1560 if (func == Nuitka_Function_Type.tp_descr_get) {
1561 is_compiled_function =
true;
1562 }
else if (func != NULL) {
1563 init_method = func(init_method, obj, (PyObject *)(type));
1564 init_method_needs_release =
true;
1568 if (unlikely(init_method == NULL)) {
1569 if (!HAS_ERROR_OCCURRED(tstate)) {
1570 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
1571 const_str_plain___init__);
1578 if (is_compiled_function) {
1579 result = Nuitka_CallMethodFunctionPosArgs(
1582 result = CALL_FUNCTION_WITH_ARGS2(tstate, init_method, args);
1583 if (init_method_needs_release) {
1584 Py_DECREF(init_method);
1588 if (unlikely(result == NULL)) {
1595 if (unlikely(result != Py_None)) {
1598 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
1602 if (pos_args == NULL) {
1603 pos_args = MAKE_TUPLE(tstate, args, 2);
1606 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
1608 Py_XDECREF(pos_args);
1615 Py_XDECREF(pos_args);
1617 CHECK_OBJECT_X(obj);
1622#if PYTHON_VERSION < 0x300
1623 }
else if (PyClass_Check(called)) {
1624 PyObject *obj = PyInstance_NewRaw(called, NULL);
1626 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
1628 if (unlikely(init_method == NULL)) {
1629 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
1636 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
1640 bool is_compiled_function =
false;
1642 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
1644 if (descr_get == NULL) {
1645 Py_INCREF(init_method);
1646 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
1647 is_compiled_function =
true;
1648 }
else if (descr_get != NULL) {
1649 PyObject *descr_method = descr_get(init_method, obj, called);
1651 if (unlikely(descr_method == NULL)) {
1655 init_method = descr_method;
1659 if (is_compiled_function) {
1660 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
1663 result = CALL_FUNCTION_WITH_ARGS2(tstate, init_method, args);
1664 Py_DECREF(init_method);
1666 if (unlikely(result == NULL)) {
1672 if (unlikely(result != Py_None)) {
1673 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
1677 CHECK_OBJECT_X(obj);
1681#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
1682 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
1683 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1685 if (likely(func != NULL)) {
1686 PyObject *result = func(called, args, 2, NULL);
1688 CHECK_OBJECT_X(result);
1690 return Nuitka_CheckFunctionResult(tstate, called, result);
1697 PRINT_STRING(
"FALLBACK");
1702 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1704 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
1706 Py_DECREF(pos_args);
1708 CHECK_OBJECT_X(result);
1712PyObject *CALL_FUNCTION_WITH_POS_ARGS2(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
1713 assert(PyTuple_CheckExact(pos_args));
1714 assert(PyTuple_GET_SIZE(pos_args) == 2);
1715 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
1716 CHECK_OBJECT(called);
1717 CHECK_OBJECTS(args, 2);
1719 if (Nuitka_Function_Check(called)) {
1720 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1727 if (function->m_args_simple && 2 == function->m_args_positional_count) {
1728 for (Py_ssize_t i = 0; i < 2; i++) {
1731 result = function->m_c_code(tstate, function, (PyObject **)args);
1732 }
else if (function->m_args_simple && 2 + function->m_defaults_given == function->m_args_positional_count) {
1733 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1735 memcpy(python_pars, args, 2 *
sizeof(PyObject *));
1736 memcpy(python_pars + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1737 function->m_defaults_given *
sizeof(PyObject *));
1739 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
1740 Py_INCREF(python_pars[i]);
1743 result = function->m_c_code(tstate, function, python_pars);
1745 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 2);
1748 Py_LeaveRecursiveCall();
1750 CHECK_OBJECT_X(result);
1753 }
else if (Nuitka_Method_Check(called)) {
1756 if (method->m_object == NULL) {
1757 PyObject *self = args[0];
1759 int res = PyObject_IsInstance(self, method->m_class);
1761 if (unlikely(res < 0)) {
1763 }
else if (unlikely(res == 0)) {
1764 PyErr_Format(PyExc_TypeError,
1765 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
1766 "instance instead)",
1767 GET_CALLABLE_NAME((PyObject *)method->m_function),
1768 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
1769 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
1774 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 2);
1776 CHECK_OBJECT_X(result);
1780 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1788 if (function->m_args_simple && 2 + 1 == function->m_args_positional_count) {
1789 PyObject *python_pars[2 + 1];
1791 python_pars[0] = method->m_object;
1792 Py_INCREF(method->m_object);
1794 for (Py_ssize_t i = 0; i < 2; i++) {
1795 python_pars[i + 1] = args[i];
1798 result = function->m_c_code(tstate, function, python_pars);
1799 }
else if (function->m_args_simple &&
1800 2 + 1 + function->m_defaults_given == function->m_args_positional_count) {
1801 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1803 python_pars[0] = method->m_object;
1804 Py_INCREF(method->m_object);
1806 memcpy(python_pars + 1, args, 2 *
sizeof(PyObject *));
1807 memcpy(python_pars + 1 + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1808 function->m_defaults_given *
sizeof(PyObject *));
1810 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
1811 Py_INCREF(python_pars[i]);
1814 result = function->m_c_code(tstate, function, python_pars);
1816 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 2);
1819 Py_LeaveRecursiveCall();
1821 CHECK_OBJECT_X(result);
1825#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
1826 }
else if (PyCFunction_CheckExact(called)) {
1827#if PYTHON_VERSION >= 0x380
1828#ifdef _NUITKA_FULL_COMPAT
1829 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1834 int flags = PyCFunction_GET_FLAGS(called);
1838 if (!(flags & METH_VARARGS)) {
1839 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1841 assert(func != NULL);
1842 result = func(called, args, 2, NULL);
1844 CHECK_OBJECT_X(result);
1846 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1847 PyObject *self = PyCFunction_GET_SELF(called);
1849 if (flags & METH_KEYWORDS) {
1850 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
1852 result = (*method)(self, pos_args);
1856#ifdef _NUITKA_FULL_COMPAT
1857 Py_LeaveRecursiveCall();
1859 CHECK_OBJECT_X(result);
1861 return Nuitka_CheckFunctionResult(tstate, called, result);
1864 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
1866 if (unlikely(flags & METH_NOARGS)) {
1867 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (2 given)",
1868 ((PyCFunctionObject *)called)->m_ml->ml_name);
1870 }
else if (unlikely(flags & METH_O)) {
1871 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (2 given)",
1872 ((PyCFunctionObject *)called)->m_ml->ml_name);
1874 }
else if (flags & METH_VARARGS) {
1877#ifdef _NUITKA_FULL_COMPAT
1878 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1882 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1883 PyObject *self = PyCFunction_GET_SELF(called);
1887#if PYTHON_VERSION < 0x360
1888 if (flags & METH_KEYWORDS) {
1889 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1891 result = (*method)(self, pos_args);
1895 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
1896 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1897 }
else if (flags == METH_FASTCALL) {
1898#if PYTHON_VERSION < 0x370
1899 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 2, NULL);
1901 result = (*(_PyCFunctionFast)method)(self, &pos_args, 2);
1904 result = (*method)(self, pos_args);
1908#ifdef _NUITKA_FULL_COMPAT
1909 Py_LeaveRecursiveCall();
1912 CHECK_OBJECT_X(result);
1914 return Nuitka_CheckFunctionResult(tstate, called, result);
1918#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
1919 }
else if (PyFunction_Check(called)) {
1920#if PYTHON_VERSION < 0x3b0
1921 PyObject *result = callPythonFunction(called, args, 2);
1923 PyObject *result = _PyFunction_Vectorcall(called, args, 2, NULL);
1925 CHECK_OBJECT_X(result);
1929#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
1930 }
else if (PyType_Check(called)) {
1931 PyTypeObject *type = Py_TYPE(called);
1933 if (type->tp_call == PyType_Type.tp_call) {
1934 PyTypeObject *called_type = (PyTypeObject *)(called);
1936 if (unlikely(called_type->tp_new == NULL)) {
1937 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
1943 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
1944 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
1945 formatCannotInstantiateAbstractClass(tstate, called_type);
1949 obj = called_type->tp_alloc(called_type, 0);
1952 obj = called_type->tp_new(called_type, pos_args, NULL);
1955 if (likely(obj != NULL)) {
1956 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
1961 type = Py_TYPE(obj);
1963 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
1964 if (type->tp_init == default_tp_init_wrapper) {
1966 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
1969 assert(init_method != NULL);
1971 bool is_compiled_function =
false;
1972 bool init_method_needs_release =
false;
1974 if (likely(init_method != NULL)) {
1975 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
1977 if (func == Nuitka_Function_Type.tp_descr_get) {
1978 is_compiled_function =
true;
1979 }
else if (func != NULL) {
1980 init_method = func(init_method, obj, (PyObject *)(type));
1981 init_method_needs_release =
true;
1985 if (unlikely(init_method == NULL)) {
1986 if (!HAS_ERROR_OCCURRED(tstate)) {
1987 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
1988 const_str_plain___init__);
1995 if (is_compiled_function) {
1996 result = Nuitka_CallMethodFunctionPosArgs(
1999 result = CALL_FUNCTION_WITH_POS_ARGS2(tstate, init_method, pos_args);
2000 if (init_method_needs_release) {
2001 Py_DECREF(init_method);
2005 if (unlikely(result == NULL)) {
2012 if (unlikely(result != Py_None)) {
2015 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2020 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
2028 CHECK_OBJECT_X(obj);
2033#if PYTHON_VERSION < 0x300
2034 }
else if (PyClass_Check(called)) {
2035 PyObject *obj = PyInstance_NewRaw(called, NULL);
2037 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
2039 if (unlikely(init_method == NULL)) {
2040 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
2047 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
2051 bool is_compiled_function =
false;
2053 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
2055 if (descr_get == NULL) {
2056 Py_INCREF(init_method);
2057 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
2058 is_compiled_function =
true;
2059 }
else if (descr_get != NULL) {
2060 PyObject *descr_method = descr_get(init_method, obj, called);
2062 if (unlikely(descr_method == NULL)) {
2066 init_method = descr_method;
2070 if (is_compiled_function) {
2071 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
2074 result = CALL_FUNCTION_WITH_POS_ARGS2(tstate, init_method, pos_args);
2075 Py_DECREF(init_method);
2077 if (unlikely(result == NULL)) {
2083 if (unlikely(result != Py_None)) {
2084 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2088 CHECK_OBJECT_X(obj);
2092#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
2093 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
2094 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2096 if (likely(func != NULL)) {
2097 PyObject *result = func(called, args, 2, NULL);
2099 CHECK_OBJECT_X(result);
2101 return Nuitka_CheckFunctionResult(tstate, called, result);
2108 PRINT_STRING(
"FALLBACK");
2113 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
2115 CHECK_OBJECT_X(result);
2119PyObject *CALL_FUNCTION_WITH_ARGS3(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
2120 CHECK_OBJECT(called);
2121 CHECK_OBJECTS(args, 3);
2123 if (Nuitka_Function_Check(called)) {
2124 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2131 if (function->m_args_simple && 3 == function->m_args_positional_count) {
2132 for (Py_ssize_t i = 0; i < 3; i++) {
2135 result = function->m_c_code(tstate, function, (PyObject **)args);
2136 }
else if (function->m_args_simple && 3 + function->m_defaults_given == function->m_args_positional_count) {
2137 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2139 memcpy(python_pars, args, 3 *
sizeof(PyObject *));
2140 memcpy(python_pars + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2141 function->m_defaults_given *
sizeof(PyObject *));
2143 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
2144 Py_INCREF(python_pars[i]);
2147 result = function->m_c_code(tstate, function, python_pars);
2149 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 3);
2152 Py_LeaveRecursiveCall();
2154 CHECK_OBJECT_X(result);
2157 }
else if (Nuitka_Method_Check(called)) {
2160 if (method->m_object == NULL) {
2161 PyObject *self = args[0];
2163 int res = PyObject_IsInstance(self, method->m_class);
2165 if (unlikely(res < 0)) {
2167 }
else if (unlikely(res == 0)) {
2168 PyErr_Format(PyExc_TypeError,
2169 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
2170 "instance instead)",
2171 GET_CALLABLE_NAME((PyObject *)method->m_function),
2172 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
2173 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
2178 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 3);
2180 CHECK_OBJECT_X(result);
2184 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2192 if (function->m_args_simple && 3 + 1 == function->m_args_positional_count) {
2193 PyObject *python_pars[3 + 1];
2195 python_pars[0] = method->m_object;
2196 Py_INCREF(method->m_object);
2198 for (Py_ssize_t i = 0; i < 3; i++) {
2199 python_pars[i + 1] = args[i];
2202 result = function->m_c_code(tstate, function, python_pars);
2203 }
else if (function->m_args_simple &&
2204 3 + 1 + function->m_defaults_given == function->m_args_positional_count) {
2205 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2207 python_pars[0] = method->m_object;
2208 Py_INCREF(method->m_object);
2210 memcpy(python_pars + 1, args, 3 *
sizeof(PyObject *));
2211 memcpy(python_pars + 1 + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2212 function->m_defaults_given *
sizeof(PyObject *));
2214 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
2215 Py_INCREF(python_pars[i]);
2218 result = function->m_c_code(tstate, function, python_pars);
2220 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 3);
2223 Py_LeaveRecursiveCall();
2225 CHECK_OBJECT_X(result);
2229#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
2230 }
else if (PyCFunction_CheckExact(called)) {
2231#if PYTHON_VERSION >= 0x380
2232#ifdef _NUITKA_FULL_COMPAT
2233 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2238 int flags = PyCFunction_GET_FLAGS(called);
2242 if (!(flags & METH_VARARGS)) {
2243 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2245 assert(func != NULL);
2246 result = func(called, args, 3, NULL);
2248 CHECK_OBJECT_X(result);
2250 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2251 PyObject *self = PyCFunction_GET_SELF(called);
2253 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2255 if (flags & METH_KEYWORDS) {
2256 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
2258 result = (*method)(self, pos_args);
2261 Py_DECREF(pos_args);
2264#ifdef _NUITKA_FULL_COMPAT
2265 Py_LeaveRecursiveCall();
2267 CHECK_OBJECT_X(result);
2269 return Nuitka_CheckFunctionResult(tstate, called, result);
2272 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
2274 if (unlikely(flags & METH_NOARGS)) {
2275 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (3 given)",
2276 ((PyCFunctionObject *)called)->m_ml->ml_name);
2278 }
else if (unlikely(flags & METH_O)) {
2279 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (3 given)",
2280 ((PyCFunctionObject *)called)->m_ml->ml_name);
2282 }
else if (flags & METH_VARARGS) {
2285#ifdef _NUITKA_FULL_COMPAT
2286 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2290 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2291 PyObject *self = PyCFunction_GET_SELF(called);
2295#if PYTHON_VERSION < 0x360
2296 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2297 if (flags & METH_KEYWORDS) {
2298 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2300 result = (*method)(self, pos_args);
2303 Py_DECREF(pos_args);
2305 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
2306 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2307 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2308 Py_DECREF(pos_args);
2309 }
else if (flags == METH_FASTCALL) {
2310#if PYTHON_VERSION < 0x370
2311 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 3, NULL);
2313 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2314 result = (*(_PyCFunctionFast)method)(self, &pos_args, 3);
2315 Py_DECREF(pos_args);
2318 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2319 result = (*method)(self, pos_args);
2320 Py_DECREF(pos_args);
2324#ifdef _NUITKA_FULL_COMPAT
2325 Py_LeaveRecursiveCall();
2328 CHECK_OBJECT_X(result);
2330 return Nuitka_CheckFunctionResult(tstate, called, result);
2334#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
2335 }
else if (PyFunction_Check(called)) {
2336#if PYTHON_VERSION < 0x3b0
2337 PyObject *result = callPythonFunction(called, args, 3);
2339 PyObject *result = _PyFunction_Vectorcall(called, args, 3, NULL);
2341 CHECK_OBJECT_X(result);
2345#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
2346 }
else if (PyType_Check(called)) {
2347 PyTypeObject *type = Py_TYPE(called);
2349 if (type->tp_call == PyType_Type.tp_call) {
2350 PyTypeObject *called_type = (PyTypeObject *)(called);
2352 if (unlikely(called_type->tp_new == NULL)) {
2353 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
2357 PyObject *pos_args = NULL;
2360 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
2361 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
2362 formatCannotInstantiateAbstractClass(tstate, called_type);
2366 obj = called_type->tp_alloc(called_type, 0);
2369 pos_args = MAKE_TUPLE(tstate, args, 3);
2370 obj = called_type->tp_new(called_type, pos_args, NULL);
2373 if (likely(obj != NULL)) {
2374 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
2375 Py_DECREF(pos_args);
2380 type = Py_TYPE(obj);
2382 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
2383 if (type->tp_init == default_tp_init_wrapper) {
2384 Py_XDECREF(pos_args);
2387 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
2390 assert(init_method != NULL);
2392 bool is_compiled_function =
false;
2393 bool init_method_needs_release =
false;
2395 if (likely(init_method != NULL)) {
2396 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
2398 if (func == Nuitka_Function_Type.tp_descr_get) {
2399 is_compiled_function =
true;
2400 }
else if (func != NULL) {
2401 init_method = func(init_method, obj, (PyObject *)(type));
2402 init_method_needs_release =
true;
2406 if (unlikely(init_method == NULL)) {
2407 if (!HAS_ERROR_OCCURRED(tstate)) {
2408 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
2409 const_str_plain___init__);
2416 if (is_compiled_function) {
2417 result = Nuitka_CallMethodFunctionPosArgs(
2420 result = CALL_FUNCTION_WITH_ARGS3(tstate, init_method, args);
2421 if (init_method_needs_release) {
2422 Py_DECREF(init_method);
2426 if (unlikely(result == NULL)) {
2433 if (unlikely(result != Py_None)) {
2436 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2440 if (pos_args == NULL) {
2441 pos_args = MAKE_TUPLE(tstate, args, 3);
2444 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
2446 Py_XDECREF(pos_args);
2453 Py_XDECREF(pos_args);
2455 CHECK_OBJECT_X(obj);
2460#if PYTHON_VERSION < 0x300
2461 }
else if (PyClass_Check(called)) {
2462 PyObject *obj = PyInstance_NewRaw(called, NULL);
2464 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
2466 if (unlikely(init_method == NULL)) {
2467 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
2474 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
2478 bool is_compiled_function =
false;
2480 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
2482 if (descr_get == NULL) {
2483 Py_INCREF(init_method);
2484 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
2485 is_compiled_function =
true;
2486 }
else if (descr_get != NULL) {
2487 PyObject *descr_method = descr_get(init_method, obj, called);
2489 if (unlikely(descr_method == NULL)) {
2493 init_method = descr_method;
2497 if (is_compiled_function) {
2498 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
2501 result = CALL_FUNCTION_WITH_ARGS3(tstate, init_method, args);
2502 Py_DECREF(init_method);
2504 if (unlikely(result == NULL)) {
2510 if (unlikely(result != Py_None)) {
2511 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2515 CHECK_OBJECT_X(obj);
2519#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
2520 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
2521 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2523 if (likely(func != NULL)) {
2524 PyObject *result = func(called, args, 3, NULL);
2526 CHECK_OBJECT_X(result);
2528 return Nuitka_CheckFunctionResult(tstate, called, result);
2535 PRINT_STRING(
"FALLBACK");
2540 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2542 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
2544 Py_DECREF(pos_args);
2546 CHECK_OBJECT_X(result);
2550PyObject *CALL_FUNCTION_WITH_POS_ARGS3(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
2551 assert(PyTuple_CheckExact(pos_args));
2552 assert(PyTuple_GET_SIZE(pos_args) == 3);
2553 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
2554 CHECK_OBJECT(called);
2555 CHECK_OBJECTS(args, 3);
2557 if (Nuitka_Function_Check(called)) {
2558 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2565 if (function->m_args_simple && 3 == function->m_args_positional_count) {
2566 for (Py_ssize_t i = 0; i < 3; i++) {
2569 result = function->m_c_code(tstate, function, (PyObject **)args);
2570 }
else if (function->m_args_simple && 3 + function->m_defaults_given == function->m_args_positional_count) {
2571 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2573 memcpy(python_pars, args, 3 *
sizeof(PyObject *));
2574 memcpy(python_pars + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2575 function->m_defaults_given *
sizeof(PyObject *));
2577 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
2578 Py_INCREF(python_pars[i]);
2581 result = function->m_c_code(tstate, function, python_pars);
2583 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 3);
2586 Py_LeaveRecursiveCall();
2588 CHECK_OBJECT_X(result);
2591 }
else if (Nuitka_Method_Check(called)) {
2594 if (method->m_object == NULL) {
2595 PyObject *self = args[0];
2597 int res = PyObject_IsInstance(self, method->m_class);
2599 if (unlikely(res < 0)) {
2601 }
else if (unlikely(res == 0)) {
2602 PyErr_Format(PyExc_TypeError,
2603 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
2604 "instance instead)",
2605 GET_CALLABLE_NAME((PyObject *)method->m_function),
2606 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
2607 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
2612 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 3);
2614 CHECK_OBJECT_X(result);
2618 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2626 if (function->m_args_simple && 3 + 1 == function->m_args_positional_count) {
2627 PyObject *python_pars[3 + 1];
2629 python_pars[0] = method->m_object;
2630 Py_INCREF(method->m_object);
2632 for (Py_ssize_t i = 0; i < 3; i++) {
2633 python_pars[i + 1] = args[i];
2636 result = function->m_c_code(tstate, function, python_pars);
2637 }
else if (function->m_args_simple &&
2638 3 + 1 + function->m_defaults_given == function->m_args_positional_count) {
2639 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2641 python_pars[0] = method->m_object;
2642 Py_INCREF(method->m_object);
2644 memcpy(python_pars + 1, args, 3 *
sizeof(PyObject *));
2645 memcpy(python_pars + 1 + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2646 function->m_defaults_given *
sizeof(PyObject *));
2648 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
2649 Py_INCREF(python_pars[i]);
2652 result = function->m_c_code(tstate, function, python_pars);
2654 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 3);
2657 Py_LeaveRecursiveCall();
2659 CHECK_OBJECT_X(result);
2663#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
2664 }
else if (PyCFunction_CheckExact(called)) {
2665#if PYTHON_VERSION >= 0x380
2666#ifdef _NUITKA_FULL_COMPAT
2667 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2672 int flags = PyCFunction_GET_FLAGS(called);
2676 if (!(flags & METH_VARARGS)) {
2677 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2679 assert(func != NULL);
2680 result = func(called, args, 3, NULL);
2682 CHECK_OBJECT_X(result);
2684 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2685 PyObject *self = PyCFunction_GET_SELF(called);
2687 if (flags & METH_KEYWORDS) {
2688 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
2690 result = (*method)(self, pos_args);
2694#ifdef _NUITKA_FULL_COMPAT
2695 Py_LeaveRecursiveCall();
2697 CHECK_OBJECT_X(result);
2699 return Nuitka_CheckFunctionResult(tstate, called, result);
2702 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
2704 if (unlikely(flags & METH_NOARGS)) {
2705 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (3 given)",
2706 ((PyCFunctionObject *)called)->m_ml->ml_name);
2708 }
else if (unlikely(flags & METH_O)) {
2709 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (3 given)",
2710 ((PyCFunctionObject *)called)->m_ml->ml_name);
2712 }
else if (flags & METH_VARARGS) {
2715#ifdef _NUITKA_FULL_COMPAT
2716 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2720 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2721 PyObject *self = PyCFunction_GET_SELF(called);
2725#if PYTHON_VERSION < 0x360
2726 if (flags & METH_KEYWORDS) {
2727 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2729 result = (*method)(self, pos_args);
2733 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
2734 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2735 }
else if (flags == METH_FASTCALL) {
2736#if PYTHON_VERSION < 0x370
2737 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 3, NULL);
2739 result = (*(_PyCFunctionFast)method)(self, &pos_args, 3);
2742 result = (*method)(self, pos_args);
2746#ifdef _NUITKA_FULL_COMPAT
2747 Py_LeaveRecursiveCall();
2750 CHECK_OBJECT_X(result);
2752 return Nuitka_CheckFunctionResult(tstate, called, result);
2756#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
2757 }
else if (PyFunction_Check(called)) {
2758#if PYTHON_VERSION < 0x3b0
2759 PyObject *result = callPythonFunction(called, args, 3);
2761 PyObject *result = _PyFunction_Vectorcall(called, args, 3, NULL);
2763 CHECK_OBJECT_X(result);
2767#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
2768 }
else if (PyType_Check(called)) {
2769 PyTypeObject *type = Py_TYPE(called);
2771 if (type->tp_call == PyType_Type.tp_call) {
2772 PyTypeObject *called_type = (PyTypeObject *)(called);
2774 if (unlikely(called_type->tp_new == NULL)) {
2775 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
2781 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
2782 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
2783 formatCannotInstantiateAbstractClass(tstate, called_type);
2787 obj = called_type->tp_alloc(called_type, 0);
2790 obj = called_type->tp_new(called_type, pos_args, NULL);
2793 if (likely(obj != NULL)) {
2794 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
2799 type = Py_TYPE(obj);
2801 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
2802 if (type->tp_init == default_tp_init_wrapper) {
2804 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
2807 assert(init_method != NULL);
2809 bool is_compiled_function =
false;
2810 bool init_method_needs_release =
false;
2812 if (likely(init_method != NULL)) {
2813 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
2815 if (func == Nuitka_Function_Type.tp_descr_get) {
2816 is_compiled_function =
true;
2817 }
else if (func != NULL) {
2818 init_method = func(init_method, obj, (PyObject *)(type));
2819 init_method_needs_release =
true;
2823 if (unlikely(init_method == NULL)) {
2824 if (!HAS_ERROR_OCCURRED(tstate)) {
2825 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
2826 const_str_plain___init__);
2833 if (is_compiled_function) {
2834 result = Nuitka_CallMethodFunctionPosArgs(
2837 result = CALL_FUNCTION_WITH_POS_ARGS3(tstate, init_method, pos_args);
2838 if (init_method_needs_release) {
2839 Py_DECREF(init_method);
2843 if (unlikely(result == NULL)) {
2850 if (unlikely(result != Py_None)) {
2853 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2858 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
2866 CHECK_OBJECT_X(obj);
2871#if PYTHON_VERSION < 0x300
2872 }
else if (PyClass_Check(called)) {
2873 PyObject *obj = PyInstance_NewRaw(called, NULL);
2875 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
2877 if (unlikely(init_method == NULL)) {
2878 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
2885 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
2889 bool is_compiled_function =
false;
2891 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
2893 if (descr_get == NULL) {
2894 Py_INCREF(init_method);
2895 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
2896 is_compiled_function =
true;
2897 }
else if (descr_get != NULL) {
2898 PyObject *descr_method = descr_get(init_method, obj, called);
2900 if (unlikely(descr_method == NULL)) {
2904 init_method = descr_method;
2908 if (is_compiled_function) {
2909 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
2912 result = CALL_FUNCTION_WITH_POS_ARGS3(tstate, init_method, pos_args);
2913 Py_DECREF(init_method);
2915 if (unlikely(result == NULL)) {
2921 if (unlikely(result != Py_None)) {
2922 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2926 CHECK_OBJECT_X(obj);
2930#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
2931 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
2932 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2934 if (likely(func != NULL)) {
2935 PyObject *result = func(called, args, 3, NULL);
2937 CHECK_OBJECT_X(result);
2939 return Nuitka_CheckFunctionResult(tstate, called, result);
2946 PRINT_STRING(
"FALLBACK");
2951 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
2953 CHECK_OBJECT_X(result);
2957PyObject *CALL_FUNCTION_WITH_ARGS4(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
2958 CHECK_OBJECT(called);
2959 CHECK_OBJECTS(args, 4);
2961 if (Nuitka_Function_Check(called)) {
2962 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2969 if (function->m_args_simple && 4 == function->m_args_positional_count) {
2970 for (Py_ssize_t i = 0; i < 4; i++) {
2973 result = function->m_c_code(tstate, function, (PyObject **)args);
2974 }
else if (function->m_args_simple && 4 + function->m_defaults_given == function->m_args_positional_count) {
2975 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2977 memcpy(python_pars, args, 4 *
sizeof(PyObject *));
2978 memcpy(python_pars + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
2979 function->m_defaults_given *
sizeof(PyObject *));
2981 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
2982 Py_INCREF(python_pars[i]);
2985 result = function->m_c_code(tstate, function, python_pars);
2987 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 4);
2990 Py_LeaveRecursiveCall();
2992 CHECK_OBJECT_X(result);
2995 }
else if (Nuitka_Method_Check(called)) {
2998 if (method->m_object == NULL) {
2999 PyObject *self = args[0];
3001 int res = PyObject_IsInstance(self, method->m_class);
3003 if (unlikely(res < 0)) {
3005 }
else if (unlikely(res == 0)) {
3006 PyErr_Format(PyExc_TypeError,
3007 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
3008 "instance instead)",
3009 GET_CALLABLE_NAME((PyObject *)method->m_function),
3010 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
3011 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
3016 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 4);
3018 CHECK_OBJECT_X(result);
3022 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3030 if (function->m_args_simple && 4 + 1 == function->m_args_positional_count) {
3031 PyObject *python_pars[4 + 1];
3033 python_pars[0] = method->m_object;
3034 Py_INCREF(method->m_object);
3036 for (Py_ssize_t i = 0; i < 4; i++) {
3037 python_pars[i + 1] = args[i];
3040 result = function->m_c_code(tstate, function, python_pars);
3041 }
else if (function->m_args_simple &&
3042 4 + 1 + function->m_defaults_given == function->m_args_positional_count) {
3043 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3045 python_pars[0] = method->m_object;
3046 Py_INCREF(method->m_object);
3048 memcpy(python_pars + 1, args, 4 *
sizeof(PyObject *));
3049 memcpy(python_pars + 1 + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
3050 function->m_defaults_given *
sizeof(PyObject *));
3052 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
3053 Py_INCREF(python_pars[i]);
3056 result = function->m_c_code(tstate, function, python_pars);
3058 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 4);
3061 Py_LeaveRecursiveCall();
3063 CHECK_OBJECT_X(result);
3067#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
3068 }
else if (PyCFunction_CheckExact(called)) {
3069#if PYTHON_VERSION >= 0x380
3070#ifdef _NUITKA_FULL_COMPAT
3071 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3076 int flags = PyCFunction_GET_FLAGS(called);
3080 if (!(flags & METH_VARARGS)) {
3081 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3083 assert(func != NULL);
3084 result = func(called, args, 4, NULL);
3086 CHECK_OBJECT_X(result);
3088 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3089 PyObject *self = PyCFunction_GET_SELF(called);
3091 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3093 if (flags & METH_KEYWORDS) {
3094 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
3096 result = (*method)(self, pos_args);
3099 Py_DECREF(pos_args);
3102#ifdef _NUITKA_FULL_COMPAT
3103 Py_LeaveRecursiveCall();
3105 CHECK_OBJECT_X(result);
3107 return Nuitka_CheckFunctionResult(tstate, called, result);
3110 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
3112 if (unlikely(flags & METH_NOARGS)) {
3113 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (4 given)",
3114 ((PyCFunctionObject *)called)->m_ml->ml_name);
3116 }
else if (unlikely(flags & METH_O)) {
3117 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (4 given)",
3118 ((PyCFunctionObject *)called)->m_ml->ml_name);
3120 }
else if (flags & METH_VARARGS) {
3123#ifdef _NUITKA_FULL_COMPAT
3124 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3128 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3129 PyObject *self = PyCFunction_GET_SELF(called);
3133#if PYTHON_VERSION < 0x360
3134 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3135 if (flags & METH_KEYWORDS) {
3136 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3138 result = (*method)(self, pos_args);
3141 Py_DECREF(pos_args);
3143 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
3144 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3145 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3146 Py_DECREF(pos_args);
3147 }
else if (flags == METH_FASTCALL) {
3148#if PYTHON_VERSION < 0x370
3149 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 4, NULL);
3151 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3152 result = (*(_PyCFunctionFast)method)(self, &pos_args, 4);
3153 Py_DECREF(pos_args);
3156 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3157 result = (*method)(self, pos_args);
3158 Py_DECREF(pos_args);
3162#ifdef _NUITKA_FULL_COMPAT
3163 Py_LeaveRecursiveCall();
3166 CHECK_OBJECT_X(result);
3168 return Nuitka_CheckFunctionResult(tstate, called, result);
3172#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
3173 }
else if (PyFunction_Check(called)) {
3174#if PYTHON_VERSION < 0x3b0
3175 PyObject *result = callPythonFunction(called, args, 4);
3177 PyObject *result = _PyFunction_Vectorcall(called, args, 4, NULL);
3179 CHECK_OBJECT_X(result);
3183#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
3184 }
else if (PyType_Check(called)) {
3185 PyTypeObject *type = Py_TYPE(called);
3187 if (type->tp_call == PyType_Type.tp_call) {
3188 PyTypeObject *called_type = (PyTypeObject *)(called);
3190 if (unlikely(called_type->tp_new == NULL)) {
3191 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
3195 PyObject *pos_args = NULL;
3198 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
3199 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
3200 formatCannotInstantiateAbstractClass(tstate, called_type);
3204 obj = called_type->tp_alloc(called_type, 0);
3207 pos_args = MAKE_TUPLE(tstate, args, 4);
3208 obj = called_type->tp_new(called_type, pos_args, NULL);
3211 if (likely(obj != NULL)) {
3212 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
3213 Py_DECREF(pos_args);
3218 type = Py_TYPE(obj);
3220 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
3221 if (type->tp_init == default_tp_init_wrapper) {
3222 Py_XDECREF(pos_args);
3225 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
3228 assert(init_method != NULL);
3230 bool is_compiled_function =
false;
3231 bool init_method_needs_release =
false;
3233 if (likely(init_method != NULL)) {
3234 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
3236 if (func == Nuitka_Function_Type.tp_descr_get) {
3237 is_compiled_function =
true;
3238 }
else if (func != NULL) {
3239 init_method = func(init_method, obj, (PyObject *)(type));
3240 init_method_needs_release =
true;
3244 if (unlikely(init_method == NULL)) {
3245 if (!HAS_ERROR_OCCURRED(tstate)) {
3246 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
3247 const_str_plain___init__);
3254 if (is_compiled_function) {
3255 result = Nuitka_CallMethodFunctionPosArgs(
3258 result = CALL_FUNCTION_WITH_ARGS4(tstate, init_method, args);
3259 if (init_method_needs_release) {
3260 Py_DECREF(init_method);
3264 if (unlikely(result == NULL)) {
3271 if (unlikely(result != Py_None)) {
3274 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
3278 if (pos_args == NULL) {
3279 pos_args = MAKE_TUPLE(tstate, args, 4);
3282 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
3284 Py_XDECREF(pos_args);
3291 Py_XDECREF(pos_args);
3293 CHECK_OBJECT_X(obj);
3298#if PYTHON_VERSION < 0x300
3299 }
else if (PyClass_Check(called)) {
3300 PyObject *obj = PyInstance_NewRaw(called, NULL);
3302 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
3304 if (unlikely(init_method == NULL)) {
3305 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
3312 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
3316 bool is_compiled_function =
false;
3318 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
3320 if (descr_get == NULL) {
3321 Py_INCREF(init_method);
3322 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
3323 is_compiled_function =
true;
3324 }
else if (descr_get != NULL) {
3325 PyObject *descr_method = descr_get(init_method, obj, called);
3327 if (unlikely(descr_method == NULL)) {
3331 init_method = descr_method;
3335 if (is_compiled_function) {
3336 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
3339 result = CALL_FUNCTION_WITH_ARGS4(tstate, init_method, args);
3340 Py_DECREF(init_method);
3342 if (unlikely(result == NULL)) {
3348 if (unlikely(result != Py_None)) {
3349 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
3353 CHECK_OBJECT_X(obj);
3357#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
3358 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
3359 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3361 if (likely(func != NULL)) {
3362 PyObject *result = func(called, args, 4, NULL);
3364 CHECK_OBJECT_X(result);
3366 return Nuitka_CheckFunctionResult(tstate, called, result);
3373 PRINT_STRING(
"FALLBACK");
3378 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3380 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
3382 Py_DECREF(pos_args);
3384 CHECK_OBJECT_X(result);
3388PyObject *CALL_FUNCTION_WITH_POS_ARGS4(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
3389 assert(PyTuple_CheckExact(pos_args));
3390 assert(PyTuple_GET_SIZE(pos_args) == 4);
3391 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
3392 CHECK_OBJECT(called);
3393 CHECK_OBJECTS(args, 4);
3395 if (Nuitka_Function_Check(called)) {
3396 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3403 if (function->m_args_simple && 4 == function->m_args_positional_count) {
3404 for (Py_ssize_t i = 0; i < 4; i++) {
3407 result = function->m_c_code(tstate, function, (PyObject **)args);
3408 }
else if (function->m_args_simple && 4 + function->m_defaults_given == function->m_args_positional_count) {
3409 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3411 memcpy(python_pars, args, 4 *
sizeof(PyObject *));
3412 memcpy(python_pars + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
3413 function->m_defaults_given *
sizeof(PyObject *));
3415 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
3416 Py_INCREF(python_pars[i]);
3419 result = function->m_c_code(tstate, function, python_pars);
3421 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 4);
3424 Py_LeaveRecursiveCall();
3426 CHECK_OBJECT_X(result);
3429 }
else if (Nuitka_Method_Check(called)) {
3432 if (method->m_object == NULL) {
3433 PyObject *self = args[0];
3435 int res = PyObject_IsInstance(self, method->m_class);
3437 if (unlikely(res < 0)) {
3439 }
else if (unlikely(res == 0)) {
3440 PyErr_Format(PyExc_TypeError,
3441 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
3442 "instance instead)",
3443 GET_CALLABLE_NAME((PyObject *)method->m_function),
3444 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
3445 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
3450 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 4);
3452 CHECK_OBJECT_X(result);
3456 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3464 if (function->m_args_simple && 4 + 1 == function->m_args_positional_count) {
3465 PyObject *python_pars[4 + 1];
3467 python_pars[0] = method->m_object;
3468 Py_INCREF(method->m_object);
3470 for (Py_ssize_t i = 0; i < 4; i++) {
3471 python_pars[i + 1] = args[i];
3474 result = function->m_c_code(tstate, function, python_pars);
3475 }
else if (function->m_args_simple &&
3476 4 + 1 + function->m_defaults_given == function->m_args_positional_count) {
3477 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3479 python_pars[0] = method->m_object;
3480 Py_INCREF(method->m_object);
3482 memcpy(python_pars + 1, args, 4 *
sizeof(PyObject *));
3483 memcpy(python_pars + 1 + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
3484 function->m_defaults_given *
sizeof(PyObject *));
3486 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
3487 Py_INCREF(python_pars[i]);
3490 result = function->m_c_code(tstate, function, python_pars);
3492 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 4);
3495 Py_LeaveRecursiveCall();
3497 CHECK_OBJECT_X(result);
3501#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
3502 }
else if (PyCFunction_CheckExact(called)) {
3503#if PYTHON_VERSION >= 0x380
3504#ifdef _NUITKA_FULL_COMPAT
3505 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3510 int flags = PyCFunction_GET_FLAGS(called);
3514 if (!(flags & METH_VARARGS)) {
3515 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3517 assert(func != NULL);
3518 result = func(called, args, 4, NULL);
3520 CHECK_OBJECT_X(result);
3522 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3523 PyObject *self = PyCFunction_GET_SELF(called);
3525 if (flags & METH_KEYWORDS) {
3526 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
3528 result = (*method)(self, pos_args);
3532#ifdef _NUITKA_FULL_COMPAT
3533 Py_LeaveRecursiveCall();
3535 CHECK_OBJECT_X(result);
3537 return Nuitka_CheckFunctionResult(tstate, called, result);
3540 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
3542 if (unlikely(flags & METH_NOARGS)) {
3543 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (4 given)",
3544 ((PyCFunctionObject *)called)->m_ml->ml_name);
3546 }
else if (unlikely(flags & METH_O)) {
3547 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (4 given)",
3548 ((PyCFunctionObject *)called)->m_ml->ml_name);
3550 }
else if (flags & METH_VARARGS) {
3553#ifdef _NUITKA_FULL_COMPAT
3554 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3558 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3559 PyObject *self = PyCFunction_GET_SELF(called);
3563#if PYTHON_VERSION < 0x360
3564 if (flags & METH_KEYWORDS) {
3565 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3567 result = (*method)(self, pos_args);
3571 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
3572 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3573 }
else if (flags == METH_FASTCALL) {
3574#if PYTHON_VERSION < 0x370
3575 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 4, NULL);
3577 result = (*(_PyCFunctionFast)method)(self, &pos_args, 4);
3580 result = (*method)(self, pos_args);
3584#ifdef _NUITKA_FULL_COMPAT
3585 Py_LeaveRecursiveCall();
3588 CHECK_OBJECT_X(result);
3590 return Nuitka_CheckFunctionResult(tstate, called, result);
3594#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
3595 }
else if (PyFunction_Check(called)) {
3596#if PYTHON_VERSION < 0x3b0
3597 PyObject *result = callPythonFunction(called, args, 4);
3599 PyObject *result = _PyFunction_Vectorcall(called, args, 4, NULL);
3601 CHECK_OBJECT_X(result);
3605#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
3606 }
else if (PyType_Check(called)) {
3607 PyTypeObject *type = Py_TYPE(called);
3609 if (type->tp_call == PyType_Type.tp_call) {
3610 PyTypeObject *called_type = (PyTypeObject *)(called);
3612 if (unlikely(called_type->tp_new == NULL)) {
3613 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
3619 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
3620 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
3621 formatCannotInstantiateAbstractClass(tstate, called_type);
3625 obj = called_type->tp_alloc(called_type, 0);
3628 obj = called_type->tp_new(called_type, pos_args, NULL);
3631 if (likely(obj != NULL)) {
3632 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
3637 type = Py_TYPE(obj);
3639 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
3640 if (type->tp_init == default_tp_init_wrapper) {
3642 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
3645 assert(init_method != NULL);
3647 bool is_compiled_function =
false;
3648 bool init_method_needs_release =
false;
3650 if (likely(init_method != NULL)) {
3651 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
3653 if (func == Nuitka_Function_Type.tp_descr_get) {
3654 is_compiled_function =
true;
3655 }
else if (func != NULL) {
3656 init_method = func(init_method, obj, (PyObject *)(type));
3657 init_method_needs_release =
true;
3661 if (unlikely(init_method == NULL)) {
3662 if (!HAS_ERROR_OCCURRED(tstate)) {
3663 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
3664 const_str_plain___init__);
3671 if (is_compiled_function) {
3672 result = Nuitka_CallMethodFunctionPosArgs(
3675 result = CALL_FUNCTION_WITH_POS_ARGS4(tstate, init_method, pos_args);
3676 if (init_method_needs_release) {
3677 Py_DECREF(init_method);
3681 if (unlikely(result == NULL)) {
3688 if (unlikely(result != Py_None)) {
3691 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
3696 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
3704 CHECK_OBJECT_X(obj);
3709#if PYTHON_VERSION < 0x300
3710 }
else if (PyClass_Check(called)) {
3711 PyObject *obj = PyInstance_NewRaw(called, NULL);
3713 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
3715 if (unlikely(init_method == NULL)) {
3716 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
3723 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
3727 bool is_compiled_function =
false;
3729 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
3731 if (descr_get == NULL) {
3732 Py_INCREF(init_method);
3733 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
3734 is_compiled_function =
true;
3735 }
else if (descr_get != NULL) {
3736 PyObject *descr_method = descr_get(init_method, obj, called);
3738 if (unlikely(descr_method == NULL)) {
3742 init_method = descr_method;
3746 if (is_compiled_function) {
3747 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
3750 result = CALL_FUNCTION_WITH_POS_ARGS4(tstate, init_method, pos_args);
3751 Py_DECREF(init_method);
3753 if (unlikely(result == NULL)) {
3759 if (unlikely(result != Py_None)) {
3760 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
3764 CHECK_OBJECT_X(obj);
3768#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
3769 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
3770 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3772 if (likely(func != NULL)) {
3773 PyObject *result = func(called, args, 4, NULL);
3775 CHECK_OBJECT_X(result);
3777 return Nuitka_CheckFunctionResult(tstate, called, result);
3784 PRINT_STRING(
"FALLBACK");
3789 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
3791 CHECK_OBJECT_X(result);
3795PyObject *CALL_FUNCTION_WITH_ARGS5(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
3796 CHECK_OBJECT(called);
3797 CHECK_OBJECTS(args, 5);
3799 if (Nuitka_Function_Check(called)) {
3800 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3807 if (function->m_args_simple && 5 == function->m_args_positional_count) {
3808 for (Py_ssize_t i = 0; i < 5; i++) {
3811 result = function->m_c_code(tstate, function, (PyObject **)args);
3812 }
else if (function->m_args_simple && 5 + function->m_defaults_given == function->m_args_positional_count) {
3813 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3815 memcpy(python_pars, args, 5 *
sizeof(PyObject *));
3816 memcpy(python_pars + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
3817 function->m_defaults_given *
sizeof(PyObject *));
3819 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
3820 Py_INCREF(python_pars[i]);
3823 result = function->m_c_code(tstate, function, python_pars);
3825 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 5);
3828 Py_LeaveRecursiveCall();
3830 CHECK_OBJECT_X(result);
3833 }
else if (Nuitka_Method_Check(called)) {
3836 if (method->m_object == NULL) {
3837 PyObject *self = args[0];
3839 int res = PyObject_IsInstance(self, method->m_class);
3841 if (unlikely(res < 0)) {
3843 }
else if (unlikely(res == 0)) {
3844 PyErr_Format(PyExc_TypeError,
3845 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
3846 "instance instead)",
3847 GET_CALLABLE_NAME((PyObject *)method->m_function),
3848 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
3849 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
3854 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 5);
3856 CHECK_OBJECT_X(result);
3860 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3868 if (function->m_args_simple && 5 + 1 == function->m_args_positional_count) {
3869 PyObject *python_pars[5 + 1];
3871 python_pars[0] = method->m_object;
3872 Py_INCREF(method->m_object);
3874 for (Py_ssize_t i = 0; i < 5; i++) {
3875 python_pars[i + 1] = args[i];
3878 result = function->m_c_code(tstate, function, python_pars);
3879 }
else if (function->m_args_simple &&
3880 5 + 1 + function->m_defaults_given == function->m_args_positional_count) {
3881 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3883 python_pars[0] = method->m_object;
3884 Py_INCREF(method->m_object);
3886 memcpy(python_pars + 1, args, 5 *
sizeof(PyObject *));
3887 memcpy(python_pars + 1 + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
3888 function->m_defaults_given *
sizeof(PyObject *));
3890 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
3891 Py_INCREF(python_pars[i]);
3894 result = function->m_c_code(tstate, function, python_pars);
3896 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 5);
3899 Py_LeaveRecursiveCall();
3901 CHECK_OBJECT_X(result);
3905#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
3906 }
else if (PyCFunction_CheckExact(called)) {
3907#if PYTHON_VERSION >= 0x380
3908#ifdef _NUITKA_FULL_COMPAT
3909 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3914 int flags = PyCFunction_GET_FLAGS(called);
3918 if (!(flags & METH_VARARGS)) {
3919 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3921 assert(func != NULL);
3922 result = func(called, args, 5, NULL);
3924 CHECK_OBJECT_X(result);
3926 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3927 PyObject *self = PyCFunction_GET_SELF(called);
3929 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3931 if (flags & METH_KEYWORDS) {
3932 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
3934 result = (*method)(self, pos_args);
3937 Py_DECREF(pos_args);
3940#ifdef _NUITKA_FULL_COMPAT
3941 Py_LeaveRecursiveCall();
3943 CHECK_OBJECT_X(result);
3945 return Nuitka_CheckFunctionResult(tstate, called, result);
3948 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
3950 if (unlikely(flags & METH_NOARGS)) {
3951 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (5 given)",
3952 ((PyCFunctionObject *)called)->m_ml->ml_name);
3954 }
else if (unlikely(flags & METH_O)) {
3955 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (5 given)",
3956 ((PyCFunctionObject *)called)->m_ml->ml_name);
3958 }
else if (flags & METH_VARARGS) {
3961#ifdef _NUITKA_FULL_COMPAT
3962 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3966 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3967 PyObject *self = PyCFunction_GET_SELF(called);
3971#if PYTHON_VERSION < 0x360
3972 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3973 if (flags & METH_KEYWORDS) {
3974 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3976 result = (*method)(self, pos_args);
3979 Py_DECREF(pos_args);
3981 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
3982 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3983 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3984 Py_DECREF(pos_args);
3985 }
else if (flags == METH_FASTCALL) {
3986#if PYTHON_VERSION < 0x370
3987 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 5, NULL);
3989 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3990 result = (*(_PyCFunctionFast)method)(self, &pos_args, 5);
3991 Py_DECREF(pos_args);
3994 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3995 result = (*method)(self, pos_args);
3996 Py_DECREF(pos_args);
4000#ifdef _NUITKA_FULL_COMPAT
4001 Py_LeaveRecursiveCall();
4004 CHECK_OBJECT_X(result);
4006 return Nuitka_CheckFunctionResult(tstate, called, result);
4010#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
4011 }
else if (PyFunction_Check(called)) {
4012#if PYTHON_VERSION < 0x3b0
4013 PyObject *result = callPythonFunction(called, args, 5);
4015 PyObject *result = _PyFunction_Vectorcall(called, args, 5, NULL);
4017 CHECK_OBJECT_X(result);
4021#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
4022 }
else if (PyType_Check(called)) {
4023 PyTypeObject *type = Py_TYPE(called);
4025 if (type->tp_call == PyType_Type.tp_call) {
4026 PyTypeObject *called_type = (PyTypeObject *)(called);
4028 if (unlikely(called_type->tp_new == NULL)) {
4029 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
4033 PyObject *pos_args = NULL;
4036 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
4037 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
4038 formatCannotInstantiateAbstractClass(tstate, called_type);
4042 obj = called_type->tp_alloc(called_type, 0);
4045 pos_args = MAKE_TUPLE(tstate, args, 5);
4046 obj = called_type->tp_new(called_type, pos_args, NULL);
4049 if (likely(obj != NULL)) {
4050 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
4051 Py_DECREF(pos_args);
4056 type = Py_TYPE(obj);
4058 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
4059 if (type->tp_init == default_tp_init_wrapper) {
4060 Py_XDECREF(pos_args);
4063 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
4066 assert(init_method != NULL);
4068 bool is_compiled_function =
false;
4069 bool init_method_needs_release =
false;
4071 if (likely(init_method != NULL)) {
4072 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
4074 if (func == Nuitka_Function_Type.tp_descr_get) {
4075 is_compiled_function =
true;
4076 }
else if (func != NULL) {
4077 init_method = func(init_method, obj, (PyObject *)(type));
4078 init_method_needs_release =
true;
4082 if (unlikely(init_method == NULL)) {
4083 if (!HAS_ERROR_OCCURRED(tstate)) {
4084 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
4085 const_str_plain___init__);
4092 if (is_compiled_function) {
4093 result = Nuitka_CallMethodFunctionPosArgs(
4096 result = CALL_FUNCTION_WITH_ARGS5(tstate, init_method, args);
4097 if (init_method_needs_release) {
4098 Py_DECREF(init_method);
4102 if (unlikely(result == NULL)) {
4109 if (unlikely(result != Py_None)) {
4112 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4116 if (pos_args == NULL) {
4117 pos_args = MAKE_TUPLE(tstate, args, 5);
4120 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
4122 Py_XDECREF(pos_args);
4129 Py_XDECREF(pos_args);
4131 CHECK_OBJECT_X(obj);
4136#if PYTHON_VERSION < 0x300
4137 }
else if (PyClass_Check(called)) {
4138 PyObject *obj = PyInstance_NewRaw(called, NULL);
4140 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
4142 if (unlikely(init_method == NULL)) {
4143 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
4150 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
4154 bool is_compiled_function =
false;
4156 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
4158 if (descr_get == NULL) {
4159 Py_INCREF(init_method);
4160 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
4161 is_compiled_function =
true;
4162 }
else if (descr_get != NULL) {
4163 PyObject *descr_method = descr_get(init_method, obj, called);
4165 if (unlikely(descr_method == NULL)) {
4169 init_method = descr_method;
4173 if (is_compiled_function) {
4174 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
4177 result = CALL_FUNCTION_WITH_ARGS5(tstate, init_method, args);
4178 Py_DECREF(init_method);
4180 if (unlikely(result == NULL)) {
4186 if (unlikely(result != Py_None)) {
4187 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4191 CHECK_OBJECT_X(obj);
4195#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
4196 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
4197 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4199 if (likely(func != NULL)) {
4200 PyObject *result = func(called, args, 5, NULL);
4202 CHECK_OBJECT_X(result);
4204 return Nuitka_CheckFunctionResult(tstate, called, result);
4211 PRINT_STRING(
"FALLBACK");
4216 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
4218 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
4220 Py_DECREF(pos_args);
4222 CHECK_OBJECT_X(result);
4226PyObject *CALL_FUNCTION_WITH_POS_ARGS5(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
4227 assert(PyTuple_CheckExact(pos_args));
4228 assert(PyTuple_GET_SIZE(pos_args) == 5);
4229 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
4230 CHECK_OBJECT(called);
4231 CHECK_OBJECTS(args, 5);
4233 if (Nuitka_Function_Check(called)) {
4234 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4241 if (function->m_args_simple && 5 == function->m_args_positional_count) {
4242 for (Py_ssize_t i = 0; i < 5; i++) {
4245 result = function->m_c_code(tstate, function, (PyObject **)args);
4246 }
else if (function->m_args_simple && 5 + function->m_defaults_given == function->m_args_positional_count) {
4247 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4249 memcpy(python_pars, args, 5 *
sizeof(PyObject *));
4250 memcpy(python_pars + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
4251 function->m_defaults_given *
sizeof(PyObject *));
4253 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
4254 Py_INCREF(python_pars[i]);
4257 result = function->m_c_code(tstate, function, python_pars);
4259 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 5);
4262 Py_LeaveRecursiveCall();
4264 CHECK_OBJECT_X(result);
4267 }
else if (Nuitka_Method_Check(called)) {
4270 if (method->m_object == NULL) {
4271 PyObject *self = args[0];
4273 int res = PyObject_IsInstance(self, method->m_class);
4275 if (unlikely(res < 0)) {
4277 }
else if (unlikely(res == 0)) {
4278 PyErr_Format(PyExc_TypeError,
4279 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
4280 "instance instead)",
4281 GET_CALLABLE_NAME((PyObject *)method->m_function),
4282 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
4283 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
4288 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 5);
4290 CHECK_OBJECT_X(result);
4294 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4302 if (function->m_args_simple && 5 + 1 == function->m_args_positional_count) {
4303 PyObject *python_pars[5 + 1];
4305 python_pars[0] = method->m_object;
4306 Py_INCREF(method->m_object);
4308 for (Py_ssize_t i = 0; i < 5; i++) {
4309 python_pars[i + 1] = args[i];
4312 result = function->m_c_code(tstate, function, python_pars);
4313 }
else if (function->m_args_simple &&
4314 5 + 1 + function->m_defaults_given == function->m_args_positional_count) {
4315 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4317 python_pars[0] = method->m_object;
4318 Py_INCREF(method->m_object);
4320 memcpy(python_pars + 1, args, 5 *
sizeof(PyObject *));
4321 memcpy(python_pars + 1 + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
4322 function->m_defaults_given *
sizeof(PyObject *));
4324 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
4325 Py_INCREF(python_pars[i]);
4328 result = function->m_c_code(tstate, function, python_pars);
4330 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 5);
4333 Py_LeaveRecursiveCall();
4335 CHECK_OBJECT_X(result);
4339#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
4340 }
else if (PyCFunction_CheckExact(called)) {
4341#if PYTHON_VERSION >= 0x380
4342#ifdef _NUITKA_FULL_COMPAT
4343 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4348 int flags = PyCFunction_GET_FLAGS(called);
4352 if (!(flags & METH_VARARGS)) {
4353 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4355 assert(func != NULL);
4356 result = func(called, args, 5, NULL);
4358 CHECK_OBJECT_X(result);
4360 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4361 PyObject *self = PyCFunction_GET_SELF(called);
4363 if (flags & METH_KEYWORDS) {
4364 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
4366 result = (*method)(self, pos_args);
4370#ifdef _NUITKA_FULL_COMPAT
4371 Py_LeaveRecursiveCall();
4373 CHECK_OBJECT_X(result);
4375 return Nuitka_CheckFunctionResult(tstate, called, result);
4378 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
4380 if (unlikely(flags & METH_NOARGS)) {
4381 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (5 given)",
4382 ((PyCFunctionObject *)called)->m_ml->ml_name);
4384 }
else if (unlikely(flags & METH_O)) {
4385 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (5 given)",
4386 ((PyCFunctionObject *)called)->m_ml->ml_name);
4388 }
else if (flags & METH_VARARGS) {
4391#ifdef _NUITKA_FULL_COMPAT
4392 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4396 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4397 PyObject *self = PyCFunction_GET_SELF(called);
4401#if PYTHON_VERSION < 0x360
4402 if (flags & METH_KEYWORDS) {
4403 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4405 result = (*method)(self, pos_args);
4409 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
4410 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4411 }
else if (flags == METH_FASTCALL) {
4412#if PYTHON_VERSION < 0x370
4413 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 5, NULL);
4415 result = (*(_PyCFunctionFast)method)(self, &pos_args, 5);
4418 result = (*method)(self, pos_args);
4422#ifdef _NUITKA_FULL_COMPAT
4423 Py_LeaveRecursiveCall();
4426 CHECK_OBJECT_X(result);
4428 return Nuitka_CheckFunctionResult(tstate, called, result);
4432#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
4433 }
else if (PyFunction_Check(called)) {
4434#if PYTHON_VERSION < 0x3b0
4435 PyObject *result = callPythonFunction(called, args, 5);
4437 PyObject *result = _PyFunction_Vectorcall(called, args, 5, NULL);
4439 CHECK_OBJECT_X(result);
4443#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
4444 }
else if (PyType_Check(called)) {
4445 PyTypeObject *type = Py_TYPE(called);
4447 if (type->tp_call == PyType_Type.tp_call) {
4448 PyTypeObject *called_type = (PyTypeObject *)(called);
4450 if (unlikely(called_type->tp_new == NULL)) {
4451 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
4457 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
4458 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
4459 formatCannotInstantiateAbstractClass(tstate, called_type);
4463 obj = called_type->tp_alloc(called_type, 0);
4466 obj = called_type->tp_new(called_type, pos_args, NULL);
4469 if (likely(obj != NULL)) {
4470 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
4475 type = Py_TYPE(obj);
4477 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
4478 if (type->tp_init == default_tp_init_wrapper) {
4480 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
4483 assert(init_method != NULL);
4485 bool is_compiled_function =
false;
4486 bool init_method_needs_release =
false;
4488 if (likely(init_method != NULL)) {
4489 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
4491 if (func == Nuitka_Function_Type.tp_descr_get) {
4492 is_compiled_function =
true;
4493 }
else if (func != NULL) {
4494 init_method = func(init_method, obj, (PyObject *)(type));
4495 init_method_needs_release =
true;
4499 if (unlikely(init_method == NULL)) {
4500 if (!HAS_ERROR_OCCURRED(tstate)) {
4501 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
4502 const_str_plain___init__);
4509 if (is_compiled_function) {
4510 result = Nuitka_CallMethodFunctionPosArgs(
4513 result = CALL_FUNCTION_WITH_POS_ARGS5(tstate, init_method, pos_args);
4514 if (init_method_needs_release) {
4515 Py_DECREF(init_method);
4519 if (unlikely(result == NULL)) {
4526 if (unlikely(result != Py_None)) {
4529 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4534 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
4542 CHECK_OBJECT_X(obj);
4547#if PYTHON_VERSION < 0x300
4548 }
else if (PyClass_Check(called)) {
4549 PyObject *obj = PyInstance_NewRaw(called, NULL);
4551 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
4553 if (unlikely(init_method == NULL)) {
4554 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
4561 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
4565 bool is_compiled_function =
false;
4567 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
4569 if (descr_get == NULL) {
4570 Py_INCREF(init_method);
4571 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
4572 is_compiled_function =
true;
4573 }
else if (descr_get != NULL) {
4574 PyObject *descr_method = descr_get(init_method, obj, called);
4576 if (unlikely(descr_method == NULL)) {
4580 init_method = descr_method;
4584 if (is_compiled_function) {
4585 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
4588 result = CALL_FUNCTION_WITH_POS_ARGS5(tstate, init_method, pos_args);
4589 Py_DECREF(init_method);
4591 if (unlikely(result == NULL)) {
4597 if (unlikely(result != Py_None)) {
4598 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4602 CHECK_OBJECT_X(obj);
4606#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
4607 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
4608 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4610 if (likely(func != NULL)) {
4611 PyObject *result = func(called, args, 5, NULL);
4613 CHECK_OBJECT_X(result);
4615 return Nuitka_CheckFunctionResult(tstate, called, result);
4622 PRINT_STRING(
"FALLBACK");
4627 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
4629 CHECK_OBJECT_X(result);
4633PyObject *CALL_FUNCTION_WITH_ARGS6(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
4634 CHECK_OBJECT(called);
4635 CHECK_OBJECTS(args, 6);
4637 if (Nuitka_Function_Check(called)) {
4638 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4645 if (function->m_args_simple && 6 == function->m_args_positional_count) {
4646 for (Py_ssize_t i = 0; i < 6; i++) {
4649 result = function->m_c_code(tstate, function, (PyObject **)args);
4650 }
else if (function->m_args_simple && 6 + function->m_defaults_given == function->m_args_positional_count) {
4651 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4653 memcpy(python_pars, args, 6 *
sizeof(PyObject *));
4654 memcpy(python_pars + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
4655 function->m_defaults_given *
sizeof(PyObject *));
4657 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
4658 Py_INCREF(python_pars[i]);
4661 result = function->m_c_code(tstate, function, python_pars);
4663 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 6);
4666 Py_LeaveRecursiveCall();
4668 CHECK_OBJECT_X(result);
4671 }
else if (Nuitka_Method_Check(called)) {
4674 if (method->m_object == NULL) {
4675 PyObject *self = args[0];
4677 int res = PyObject_IsInstance(self, method->m_class);
4679 if (unlikely(res < 0)) {
4681 }
else if (unlikely(res == 0)) {
4682 PyErr_Format(PyExc_TypeError,
4683 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
4684 "instance instead)",
4685 GET_CALLABLE_NAME((PyObject *)method->m_function),
4686 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
4687 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
4692 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 6);
4694 CHECK_OBJECT_X(result);
4698 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4706 if (function->m_args_simple && 6 + 1 == function->m_args_positional_count) {
4707 PyObject *python_pars[6 + 1];
4709 python_pars[0] = method->m_object;
4710 Py_INCREF(method->m_object);
4712 for (Py_ssize_t i = 0; i < 6; i++) {
4713 python_pars[i + 1] = args[i];
4716 result = function->m_c_code(tstate, function, python_pars);
4717 }
else if (function->m_args_simple &&
4718 6 + 1 + function->m_defaults_given == function->m_args_positional_count) {
4719 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4721 python_pars[0] = method->m_object;
4722 Py_INCREF(method->m_object);
4724 memcpy(python_pars + 1, args, 6 *
sizeof(PyObject *));
4725 memcpy(python_pars + 1 + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
4726 function->m_defaults_given *
sizeof(PyObject *));
4728 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
4729 Py_INCREF(python_pars[i]);
4732 result = function->m_c_code(tstate, function, python_pars);
4734 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 6);
4737 Py_LeaveRecursiveCall();
4739 CHECK_OBJECT_X(result);
4743#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
4744 }
else if (PyCFunction_CheckExact(called)) {
4745#if PYTHON_VERSION >= 0x380
4746#ifdef _NUITKA_FULL_COMPAT
4747 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4752 int flags = PyCFunction_GET_FLAGS(called);
4756 if (!(flags & METH_VARARGS)) {
4757 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4759 assert(func != NULL);
4760 result = func(called, args, 6, NULL);
4762 CHECK_OBJECT_X(result);
4764 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4765 PyObject *self = PyCFunction_GET_SELF(called);
4767 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4769 if (flags & METH_KEYWORDS) {
4770 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
4772 result = (*method)(self, pos_args);
4775 Py_DECREF(pos_args);
4778#ifdef _NUITKA_FULL_COMPAT
4779 Py_LeaveRecursiveCall();
4781 CHECK_OBJECT_X(result);
4783 return Nuitka_CheckFunctionResult(tstate, called, result);
4786 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
4788 if (unlikely(flags & METH_NOARGS)) {
4789 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (6 given)",
4790 ((PyCFunctionObject *)called)->m_ml->ml_name);
4792 }
else if (unlikely(flags & METH_O)) {
4793 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (6 given)",
4794 ((PyCFunctionObject *)called)->m_ml->ml_name);
4796 }
else if (flags & METH_VARARGS) {
4799#ifdef _NUITKA_FULL_COMPAT
4800 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4804 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4805 PyObject *self = PyCFunction_GET_SELF(called);
4809#if PYTHON_VERSION < 0x360
4810 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4811 if (flags & METH_KEYWORDS) {
4812 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4814 result = (*method)(self, pos_args);
4817 Py_DECREF(pos_args);
4819 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
4820 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4821 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4822 Py_DECREF(pos_args);
4823 }
else if (flags == METH_FASTCALL) {
4824#if PYTHON_VERSION < 0x370
4825 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 6, NULL);
4827 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4828 result = (*(_PyCFunctionFast)method)(self, &pos_args, 6);
4829 Py_DECREF(pos_args);
4832 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4833 result = (*method)(self, pos_args);
4834 Py_DECREF(pos_args);
4838#ifdef _NUITKA_FULL_COMPAT
4839 Py_LeaveRecursiveCall();
4842 CHECK_OBJECT_X(result);
4844 return Nuitka_CheckFunctionResult(tstate, called, result);
4848#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
4849 }
else if (PyFunction_Check(called)) {
4850#if PYTHON_VERSION < 0x3b0
4851 PyObject *result = callPythonFunction(called, args, 6);
4853 PyObject *result = _PyFunction_Vectorcall(called, args, 6, NULL);
4855 CHECK_OBJECT_X(result);
4859#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
4860 }
else if (PyType_Check(called)) {
4861 PyTypeObject *type = Py_TYPE(called);
4863 if (type->tp_call == PyType_Type.tp_call) {
4864 PyTypeObject *called_type = (PyTypeObject *)(called);
4866 if (unlikely(called_type->tp_new == NULL)) {
4867 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
4871 PyObject *pos_args = NULL;
4874 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
4875 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
4876 formatCannotInstantiateAbstractClass(tstate, called_type);
4880 obj = called_type->tp_alloc(called_type, 0);
4883 pos_args = MAKE_TUPLE(tstate, args, 6);
4884 obj = called_type->tp_new(called_type, pos_args, NULL);
4887 if (likely(obj != NULL)) {
4888 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
4889 Py_DECREF(pos_args);
4894 type = Py_TYPE(obj);
4896 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
4897 if (type->tp_init == default_tp_init_wrapper) {
4898 Py_XDECREF(pos_args);
4901 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
4904 assert(init_method != NULL);
4906 bool is_compiled_function =
false;
4907 bool init_method_needs_release =
false;
4909 if (likely(init_method != NULL)) {
4910 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
4912 if (func == Nuitka_Function_Type.tp_descr_get) {
4913 is_compiled_function =
true;
4914 }
else if (func != NULL) {
4915 init_method = func(init_method, obj, (PyObject *)(type));
4916 init_method_needs_release =
true;
4920 if (unlikely(init_method == NULL)) {
4921 if (!HAS_ERROR_OCCURRED(tstate)) {
4922 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
4923 const_str_plain___init__);
4930 if (is_compiled_function) {
4931 result = Nuitka_CallMethodFunctionPosArgs(
4934 result = CALL_FUNCTION_WITH_ARGS6(tstate, init_method, args);
4935 if (init_method_needs_release) {
4936 Py_DECREF(init_method);
4940 if (unlikely(result == NULL)) {
4947 if (unlikely(result != Py_None)) {
4950 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4954 if (pos_args == NULL) {
4955 pos_args = MAKE_TUPLE(tstate, args, 6);
4958 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
4960 Py_XDECREF(pos_args);
4967 Py_XDECREF(pos_args);
4969 CHECK_OBJECT_X(obj);
4974#if PYTHON_VERSION < 0x300
4975 }
else if (PyClass_Check(called)) {
4976 PyObject *obj = PyInstance_NewRaw(called, NULL);
4978 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
4980 if (unlikely(init_method == NULL)) {
4981 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
4988 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
4992 bool is_compiled_function =
false;
4994 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
4996 if (descr_get == NULL) {
4997 Py_INCREF(init_method);
4998 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
4999 is_compiled_function =
true;
5000 }
else if (descr_get != NULL) {
5001 PyObject *descr_method = descr_get(init_method, obj, called);
5003 if (unlikely(descr_method == NULL)) {
5007 init_method = descr_method;
5011 if (is_compiled_function) {
5012 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
5015 result = CALL_FUNCTION_WITH_ARGS6(tstate, init_method, args);
5016 Py_DECREF(init_method);
5018 if (unlikely(result == NULL)) {
5024 if (unlikely(result != Py_None)) {
5025 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5029 CHECK_OBJECT_X(obj);
5033#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
5034 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
5035 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5037 if (likely(func != NULL)) {
5038 PyObject *result = func(called, args, 6, NULL);
5040 CHECK_OBJECT_X(result);
5042 return Nuitka_CheckFunctionResult(tstate, called, result);
5049 PRINT_STRING(
"FALLBACK");
5054 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
5056 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
5058 Py_DECREF(pos_args);
5060 CHECK_OBJECT_X(result);
5064PyObject *CALL_FUNCTION_WITH_POS_ARGS6(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
5065 assert(PyTuple_CheckExact(pos_args));
5066 assert(PyTuple_GET_SIZE(pos_args) == 6);
5067 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
5068 CHECK_OBJECT(called);
5069 CHECK_OBJECTS(args, 6);
5071 if (Nuitka_Function_Check(called)) {
5072 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5079 if (function->m_args_simple && 6 == function->m_args_positional_count) {
5080 for (Py_ssize_t i = 0; i < 6; i++) {
5083 result = function->m_c_code(tstate, function, (PyObject **)args);
5084 }
else if (function->m_args_simple && 6 + function->m_defaults_given == function->m_args_positional_count) {
5085 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5087 memcpy(python_pars, args, 6 *
sizeof(PyObject *));
5088 memcpy(python_pars + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
5089 function->m_defaults_given *
sizeof(PyObject *));
5091 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
5092 Py_INCREF(python_pars[i]);
5095 result = function->m_c_code(tstate, function, python_pars);
5097 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 6);
5100 Py_LeaveRecursiveCall();
5102 CHECK_OBJECT_X(result);
5105 }
else if (Nuitka_Method_Check(called)) {
5108 if (method->m_object == NULL) {
5109 PyObject *self = args[0];
5111 int res = PyObject_IsInstance(self, method->m_class);
5113 if (unlikely(res < 0)) {
5115 }
else if (unlikely(res == 0)) {
5116 PyErr_Format(PyExc_TypeError,
5117 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
5118 "instance instead)",
5119 GET_CALLABLE_NAME((PyObject *)method->m_function),
5120 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
5121 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
5126 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 6);
5128 CHECK_OBJECT_X(result);
5132 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5140 if (function->m_args_simple && 6 + 1 == function->m_args_positional_count) {
5141 PyObject *python_pars[6 + 1];
5143 python_pars[0] = method->m_object;
5144 Py_INCREF(method->m_object);
5146 for (Py_ssize_t i = 0; i < 6; i++) {
5147 python_pars[i + 1] = args[i];
5150 result = function->m_c_code(tstate, function, python_pars);
5151 }
else if (function->m_args_simple &&
5152 6 + 1 + function->m_defaults_given == function->m_args_positional_count) {
5153 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5155 python_pars[0] = method->m_object;
5156 Py_INCREF(method->m_object);
5158 memcpy(python_pars + 1, args, 6 *
sizeof(PyObject *));
5159 memcpy(python_pars + 1 + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
5160 function->m_defaults_given *
sizeof(PyObject *));
5162 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
5163 Py_INCREF(python_pars[i]);
5166 result = function->m_c_code(tstate, function, python_pars);
5168 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 6);
5171 Py_LeaveRecursiveCall();
5173 CHECK_OBJECT_X(result);
5177#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
5178 }
else if (PyCFunction_CheckExact(called)) {
5179#if PYTHON_VERSION >= 0x380
5180#ifdef _NUITKA_FULL_COMPAT
5181 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5186 int flags = PyCFunction_GET_FLAGS(called);
5190 if (!(flags & METH_VARARGS)) {
5191 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5193 assert(func != NULL);
5194 result = func(called, args, 6, NULL);
5196 CHECK_OBJECT_X(result);
5198 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5199 PyObject *self = PyCFunction_GET_SELF(called);
5201 if (flags & METH_KEYWORDS) {
5202 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
5204 result = (*method)(self, pos_args);
5208#ifdef _NUITKA_FULL_COMPAT
5209 Py_LeaveRecursiveCall();
5211 CHECK_OBJECT_X(result);
5213 return Nuitka_CheckFunctionResult(tstate, called, result);
5216 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
5218 if (unlikely(flags & METH_NOARGS)) {
5219 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (6 given)",
5220 ((PyCFunctionObject *)called)->m_ml->ml_name);
5222 }
else if (unlikely(flags & METH_O)) {
5223 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (6 given)",
5224 ((PyCFunctionObject *)called)->m_ml->ml_name);
5226 }
else if (flags & METH_VARARGS) {
5229#ifdef _NUITKA_FULL_COMPAT
5230 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5234 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5235 PyObject *self = PyCFunction_GET_SELF(called);
5239#if PYTHON_VERSION < 0x360
5240 if (flags & METH_KEYWORDS) {
5241 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5243 result = (*method)(self, pos_args);
5247 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
5248 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5249 }
else if (flags == METH_FASTCALL) {
5250#if PYTHON_VERSION < 0x370
5251 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 6, NULL);
5253 result = (*(_PyCFunctionFast)method)(self, &pos_args, 6);
5256 result = (*method)(self, pos_args);
5260#ifdef _NUITKA_FULL_COMPAT
5261 Py_LeaveRecursiveCall();
5264 CHECK_OBJECT_X(result);
5266 return Nuitka_CheckFunctionResult(tstate, called, result);
5270#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
5271 }
else if (PyFunction_Check(called)) {
5272#if PYTHON_VERSION < 0x3b0
5273 PyObject *result = callPythonFunction(called, args, 6);
5275 PyObject *result = _PyFunction_Vectorcall(called, args, 6, NULL);
5277 CHECK_OBJECT_X(result);
5281#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
5282 }
else if (PyType_Check(called)) {
5283 PyTypeObject *type = Py_TYPE(called);
5285 if (type->tp_call == PyType_Type.tp_call) {
5286 PyTypeObject *called_type = (PyTypeObject *)(called);
5288 if (unlikely(called_type->tp_new == NULL)) {
5289 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
5295 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
5296 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
5297 formatCannotInstantiateAbstractClass(tstate, called_type);
5301 obj = called_type->tp_alloc(called_type, 0);
5304 obj = called_type->tp_new(called_type, pos_args, NULL);
5307 if (likely(obj != NULL)) {
5308 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
5313 type = Py_TYPE(obj);
5315 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
5316 if (type->tp_init == default_tp_init_wrapper) {
5318 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
5321 assert(init_method != NULL);
5323 bool is_compiled_function =
false;
5324 bool init_method_needs_release =
false;
5326 if (likely(init_method != NULL)) {
5327 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
5329 if (func == Nuitka_Function_Type.tp_descr_get) {
5330 is_compiled_function =
true;
5331 }
else if (func != NULL) {
5332 init_method = func(init_method, obj, (PyObject *)(type));
5333 init_method_needs_release =
true;
5337 if (unlikely(init_method == NULL)) {
5338 if (!HAS_ERROR_OCCURRED(tstate)) {
5339 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
5340 const_str_plain___init__);
5347 if (is_compiled_function) {
5348 result = Nuitka_CallMethodFunctionPosArgs(
5351 result = CALL_FUNCTION_WITH_POS_ARGS6(tstate, init_method, pos_args);
5352 if (init_method_needs_release) {
5353 Py_DECREF(init_method);
5357 if (unlikely(result == NULL)) {
5364 if (unlikely(result != Py_None)) {
5367 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5372 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
5380 CHECK_OBJECT_X(obj);
5385#if PYTHON_VERSION < 0x300
5386 }
else if (PyClass_Check(called)) {
5387 PyObject *obj = PyInstance_NewRaw(called, NULL);
5389 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
5391 if (unlikely(init_method == NULL)) {
5392 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
5399 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
5403 bool is_compiled_function =
false;
5405 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
5407 if (descr_get == NULL) {
5408 Py_INCREF(init_method);
5409 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
5410 is_compiled_function =
true;
5411 }
else if (descr_get != NULL) {
5412 PyObject *descr_method = descr_get(init_method, obj, called);
5414 if (unlikely(descr_method == NULL)) {
5418 init_method = descr_method;
5422 if (is_compiled_function) {
5423 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
5426 result = CALL_FUNCTION_WITH_POS_ARGS6(tstate, init_method, pos_args);
5427 Py_DECREF(init_method);
5429 if (unlikely(result == NULL)) {
5435 if (unlikely(result != Py_None)) {
5436 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5440 CHECK_OBJECT_X(obj);
5444#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
5445 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
5446 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5448 if (likely(func != NULL)) {
5449 PyObject *result = func(called, args, 6, NULL);
5451 CHECK_OBJECT_X(result);
5453 return Nuitka_CheckFunctionResult(tstate, called, result);
5460 PRINT_STRING(
"FALLBACK");
5465 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
5467 CHECK_OBJECT_X(result);
5471PyObject *CALL_FUNCTION_WITH_ARGS7(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
5472 CHECK_OBJECT(called);
5473 CHECK_OBJECTS(args, 7);
5475 if (Nuitka_Function_Check(called)) {
5476 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5483 if (function->m_args_simple && 7 == function->m_args_positional_count) {
5484 for (Py_ssize_t i = 0; i < 7; i++) {
5487 result = function->m_c_code(tstate, function, (PyObject **)args);
5488 }
else if (function->m_args_simple && 7 + function->m_defaults_given == function->m_args_positional_count) {
5489 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5491 memcpy(python_pars, args, 7 *
sizeof(PyObject *));
5492 memcpy(python_pars + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
5493 function->m_defaults_given *
sizeof(PyObject *));
5495 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
5496 Py_INCREF(python_pars[i]);
5499 result = function->m_c_code(tstate, function, python_pars);
5501 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 7);
5504 Py_LeaveRecursiveCall();
5506 CHECK_OBJECT_X(result);
5509 }
else if (Nuitka_Method_Check(called)) {
5512 if (method->m_object == NULL) {
5513 PyObject *self = args[0];
5515 int res = PyObject_IsInstance(self, method->m_class);
5517 if (unlikely(res < 0)) {
5519 }
else if (unlikely(res == 0)) {
5520 PyErr_Format(PyExc_TypeError,
5521 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
5522 "instance instead)",
5523 GET_CALLABLE_NAME((PyObject *)method->m_function),
5524 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
5525 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
5530 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 7);
5532 CHECK_OBJECT_X(result);
5536 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5544 if (function->m_args_simple && 7 + 1 == function->m_args_positional_count) {
5545 PyObject *python_pars[7 + 1];
5547 python_pars[0] = method->m_object;
5548 Py_INCREF(method->m_object);
5550 for (Py_ssize_t i = 0; i < 7; i++) {
5551 python_pars[i + 1] = args[i];
5554 result = function->m_c_code(tstate, function, python_pars);
5555 }
else if (function->m_args_simple &&
5556 7 + 1 + function->m_defaults_given == function->m_args_positional_count) {
5557 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5559 python_pars[0] = method->m_object;
5560 Py_INCREF(method->m_object);
5562 memcpy(python_pars + 1, args, 7 *
sizeof(PyObject *));
5563 memcpy(python_pars + 1 + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
5564 function->m_defaults_given *
sizeof(PyObject *));
5566 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
5567 Py_INCREF(python_pars[i]);
5570 result = function->m_c_code(tstate, function, python_pars);
5572 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 7);
5575 Py_LeaveRecursiveCall();
5577 CHECK_OBJECT_X(result);
5581#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
5582 }
else if (PyCFunction_CheckExact(called)) {
5583#if PYTHON_VERSION >= 0x380
5584#ifdef _NUITKA_FULL_COMPAT
5585 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5590 int flags = PyCFunction_GET_FLAGS(called);
5594 if (!(flags & METH_VARARGS)) {
5595 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5597 assert(func != NULL);
5598 result = func(called, args, 7, NULL);
5600 CHECK_OBJECT_X(result);
5602 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5603 PyObject *self = PyCFunction_GET_SELF(called);
5605 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5607 if (flags & METH_KEYWORDS) {
5608 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
5610 result = (*method)(self, pos_args);
5613 Py_DECREF(pos_args);
5616#ifdef _NUITKA_FULL_COMPAT
5617 Py_LeaveRecursiveCall();
5619 CHECK_OBJECT_X(result);
5621 return Nuitka_CheckFunctionResult(tstate, called, result);
5624 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
5626 if (unlikely(flags & METH_NOARGS)) {
5627 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (7 given)",
5628 ((PyCFunctionObject *)called)->m_ml->ml_name);
5630 }
else if (unlikely(flags & METH_O)) {
5631 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (7 given)",
5632 ((PyCFunctionObject *)called)->m_ml->ml_name);
5634 }
else if (flags & METH_VARARGS) {
5637#ifdef _NUITKA_FULL_COMPAT
5638 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5642 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5643 PyObject *self = PyCFunction_GET_SELF(called);
5647#if PYTHON_VERSION < 0x360
5648 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5649 if (flags & METH_KEYWORDS) {
5650 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5652 result = (*method)(self, pos_args);
5655 Py_DECREF(pos_args);
5657 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
5658 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5659 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5660 Py_DECREF(pos_args);
5661 }
else if (flags == METH_FASTCALL) {
5662#if PYTHON_VERSION < 0x370
5663 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 7, NULL);
5665 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5666 result = (*(_PyCFunctionFast)method)(self, &pos_args, 7);
5667 Py_DECREF(pos_args);
5670 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5671 result = (*method)(self, pos_args);
5672 Py_DECREF(pos_args);
5676#ifdef _NUITKA_FULL_COMPAT
5677 Py_LeaveRecursiveCall();
5680 CHECK_OBJECT_X(result);
5682 return Nuitka_CheckFunctionResult(tstate, called, result);
5686#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
5687 }
else if (PyFunction_Check(called)) {
5688#if PYTHON_VERSION < 0x3b0
5689 PyObject *result = callPythonFunction(called, args, 7);
5691 PyObject *result = _PyFunction_Vectorcall(called, args, 7, NULL);
5693 CHECK_OBJECT_X(result);
5697#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
5698 }
else if (PyType_Check(called)) {
5699 PyTypeObject *type = Py_TYPE(called);
5701 if (type->tp_call == PyType_Type.tp_call) {
5702 PyTypeObject *called_type = (PyTypeObject *)(called);
5704 if (unlikely(called_type->tp_new == NULL)) {
5705 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
5709 PyObject *pos_args = NULL;
5712 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
5713 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
5714 formatCannotInstantiateAbstractClass(tstate, called_type);
5718 obj = called_type->tp_alloc(called_type, 0);
5721 pos_args = MAKE_TUPLE(tstate, args, 7);
5722 obj = called_type->tp_new(called_type, pos_args, NULL);
5725 if (likely(obj != NULL)) {
5726 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
5727 Py_DECREF(pos_args);
5732 type = Py_TYPE(obj);
5734 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
5735 if (type->tp_init == default_tp_init_wrapper) {
5736 Py_XDECREF(pos_args);
5739 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
5742 assert(init_method != NULL);
5744 bool is_compiled_function =
false;
5745 bool init_method_needs_release =
false;
5747 if (likely(init_method != NULL)) {
5748 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
5750 if (func == Nuitka_Function_Type.tp_descr_get) {
5751 is_compiled_function =
true;
5752 }
else if (func != NULL) {
5753 init_method = func(init_method, obj, (PyObject *)(type));
5754 init_method_needs_release =
true;
5758 if (unlikely(init_method == NULL)) {
5759 if (!HAS_ERROR_OCCURRED(tstate)) {
5760 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
5761 const_str_plain___init__);
5768 if (is_compiled_function) {
5769 result = Nuitka_CallMethodFunctionPosArgs(
5772 result = CALL_FUNCTION_WITH_ARGS7(tstate, init_method, args);
5773 if (init_method_needs_release) {
5774 Py_DECREF(init_method);
5778 if (unlikely(result == NULL)) {
5785 if (unlikely(result != Py_None)) {
5788 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5792 if (pos_args == NULL) {
5793 pos_args = MAKE_TUPLE(tstate, args, 7);
5796 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
5798 Py_XDECREF(pos_args);
5805 Py_XDECREF(pos_args);
5807 CHECK_OBJECT_X(obj);
5812#if PYTHON_VERSION < 0x300
5813 }
else if (PyClass_Check(called)) {
5814 PyObject *obj = PyInstance_NewRaw(called, NULL);
5816 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
5818 if (unlikely(init_method == NULL)) {
5819 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
5826 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
5830 bool is_compiled_function =
false;
5832 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
5834 if (descr_get == NULL) {
5835 Py_INCREF(init_method);
5836 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
5837 is_compiled_function =
true;
5838 }
else if (descr_get != NULL) {
5839 PyObject *descr_method = descr_get(init_method, obj, called);
5841 if (unlikely(descr_method == NULL)) {
5845 init_method = descr_method;
5849 if (is_compiled_function) {
5850 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
5853 result = CALL_FUNCTION_WITH_ARGS7(tstate, init_method, args);
5854 Py_DECREF(init_method);
5856 if (unlikely(result == NULL)) {
5862 if (unlikely(result != Py_None)) {
5863 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5867 CHECK_OBJECT_X(obj);
5871#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
5872 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
5873 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5875 if (likely(func != NULL)) {
5876 PyObject *result = func(called, args, 7, NULL);
5878 CHECK_OBJECT_X(result);
5880 return Nuitka_CheckFunctionResult(tstate, called, result);
5887 PRINT_STRING(
"FALLBACK");
5892 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5894 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
5896 Py_DECREF(pos_args);
5898 CHECK_OBJECT_X(result);
5902PyObject *CALL_FUNCTION_WITH_POS_ARGS7(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
5903 assert(PyTuple_CheckExact(pos_args));
5904 assert(PyTuple_GET_SIZE(pos_args) == 7);
5905 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
5906 CHECK_OBJECT(called);
5907 CHECK_OBJECTS(args, 7);
5909 if (Nuitka_Function_Check(called)) {
5910 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5917 if (function->m_args_simple && 7 == function->m_args_positional_count) {
5918 for (Py_ssize_t i = 0; i < 7; i++) {
5921 result = function->m_c_code(tstate, function, (PyObject **)args);
5922 }
else if (function->m_args_simple && 7 + function->m_defaults_given == function->m_args_positional_count) {
5923 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5925 memcpy(python_pars, args, 7 *
sizeof(PyObject *));
5926 memcpy(python_pars + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
5927 function->m_defaults_given *
sizeof(PyObject *));
5929 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
5930 Py_INCREF(python_pars[i]);
5933 result = function->m_c_code(tstate, function, python_pars);
5935 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 7);
5938 Py_LeaveRecursiveCall();
5940 CHECK_OBJECT_X(result);
5943 }
else if (Nuitka_Method_Check(called)) {
5946 if (method->m_object == NULL) {
5947 PyObject *self = args[0];
5949 int res = PyObject_IsInstance(self, method->m_class);
5951 if (unlikely(res < 0)) {
5953 }
else if (unlikely(res == 0)) {
5954 PyErr_Format(PyExc_TypeError,
5955 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
5956 "instance instead)",
5957 GET_CALLABLE_NAME((PyObject *)method->m_function),
5958 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
5959 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
5964 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 7);
5966 CHECK_OBJECT_X(result);
5970 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5978 if (function->m_args_simple && 7 + 1 == function->m_args_positional_count) {
5979 PyObject *python_pars[7 + 1];
5981 python_pars[0] = method->m_object;
5982 Py_INCREF(method->m_object);
5984 for (Py_ssize_t i = 0; i < 7; i++) {
5985 python_pars[i + 1] = args[i];
5988 result = function->m_c_code(tstate, function, python_pars);
5989 }
else if (function->m_args_simple &&
5990 7 + 1 + function->m_defaults_given == function->m_args_positional_count) {
5991 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5993 python_pars[0] = method->m_object;
5994 Py_INCREF(method->m_object);
5996 memcpy(python_pars + 1, args, 7 *
sizeof(PyObject *));
5997 memcpy(python_pars + 1 + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
5998 function->m_defaults_given *
sizeof(PyObject *));
6000 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
6001 Py_INCREF(python_pars[i]);
6004 result = function->m_c_code(tstate, function, python_pars);
6006 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 7);
6009 Py_LeaveRecursiveCall();
6011 CHECK_OBJECT_X(result);
6015#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
6016 }
else if (PyCFunction_CheckExact(called)) {
6017#if PYTHON_VERSION >= 0x380
6018#ifdef _NUITKA_FULL_COMPAT
6019 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6024 int flags = PyCFunction_GET_FLAGS(called);
6028 if (!(flags & METH_VARARGS)) {
6029 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6031 assert(func != NULL);
6032 result = func(called, args, 7, NULL);
6034 CHECK_OBJECT_X(result);
6036 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6037 PyObject *self = PyCFunction_GET_SELF(called);
6039 if (flags & METH_KEYWORDS) {
6040 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
6042 result = (*method)(self, pos_args);
6046#ifdef _NUITKA_FULL_COMPAT
6047 Py_LeaveRecursiveCall();
6049 CHECK_OBJECT_X(result);
6051 return Nuitka_CheckFunctionResult(tstate, called, result);
6054 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
6056 if (unlikely(flags & METH_NOARGS)) {
6057 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (7 given)",
6058 ((PyCFunctionObject *)called)->m_ml->ml_name);
6060 }
else if (unlikely(flags & METH_O)) {
6061 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (7 given)",
6062 ((PyCFunctionObject *)called)->m_ml->ml_name);
6064 }
else if (flags & METH_VARARGS) {
6067#ifdef _NUITKA_FULL_COMPAT
6068 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6072 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6073 PyObject *self = PyCFunction_GET_SELF(called);
6077#if PYTHON_VERSION < 0x360
6078 if (flags & METH_KEYWORDS) {
6079 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6081 result = (*method)(self, pos_args);
6085 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
6086 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6087 }
else if (flags == METH_FASTCALL) {
6088#if PYTHON_VERSION < 0x370
6089 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 7, NULL);
6091 result = (*(_PyCFunctionFast)method)(self, &pos_args, 7);
6094 result = (*method)(self, pos_args);
6098#ifdef _NUITKA_FULL_COMPAT
6099 Py_LeaveRecursiveCall();
6102 CHECK_OBJECT_X(result);
6104 return Nuitka_CheckFunctionResult(tstate, called, result);
6108#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
6109 }
else if (PyFunction_Check(called)) {
6110#if PYTHON_VERSION < 0x3b0
6111 PyObject *result = callPythonFunction(called, args, 7);
6113 PyObject *result = _PyFunction_Vectorcall(called, args, 7, NULL);
6115 CHECK_OBJECT_X(result);
6119#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
6120 }
else if (PyType_Check(called)) {
6121 PyTypeObject *type = Py_TYPE(called);
6123 if (type->tp_call == PyType_Type.tp_call) {
6124 PyTypeObject *called_type = (PyTypeObject *)(called);
6126 if (unlikely(called_type->tp_new == NULL)) {
6127 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
6133 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
6134 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
6135 formatCannotInstantiateAbstractClass(tstate, called_type);
6139 obj = called_type->tp_alloc(called_type, 0);
6142 obj = called_type->tp_new(called_type, pos_args, NULL);
6145 if (likely(obj != NULL)) {
6146 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
6151 type = Py_TYPE(obj);
6153 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
6154 if (type->tp_init == default_tp_init_wrapper) {
6156 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
6159 assert(init_method != NULL);
6161 bool is_compiled_function =
false;
6162 bool init_method_needs_release =
false;
6164 if (likely(init_method != NULL)) {
6165 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
6167 if (func == Nuitka_Function_Type.tp_descr_get) {
6168 is_compiled_function =
true;
6169 }
else if (func != NULL) {
6170 init_method = func(init_method, obj, (PyObject *)(type));
6171 init_method_needs_release =
true;
6175 if (unlikely(init_method == NULL)) {
6176 if (!HAS_ERROR_OCCURRED(tstate)) {
6177 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
6178 const_str_plain___init__);
6185 if (is_compiled_function) {
6186 result = Nuitka_CallMethodFunctionPosArgs(
6189 result = CALL_FUNCTION_WITH_POS_ARGS7(tstate, init_method, pos_args);
6190 if (init_method_needs_release) {
6191 Py_DECREF(init_method);
6195 if (unlikely(result == NULL)) {
6202 if (unlikely(result != Py_None)) {
6205 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
6210 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
6218 CHECK_OBJECT_X(obj);
6223#if PYTHON_VERSION < 0x300
6224 }
else if (PyClass_Check(called)) {
6225 PyObject *obj = PyInstance_NewRaw(called, NULL);
6227 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
6229 if (unlikely(init_method == NULL)) {
6230 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
6237 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
6241 bool is_compiled_function =
false;
6243 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
6245 if (descr_get == NULL) {
6246 Py_INCREF(init_method);
6247 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
6248 is_compiled_function =
true;
6249 }
else if (descr_get != NULL) {
6250 PyObject *descr_method = descr_get(init_method, obj, called);
6252 if (unlikely(descr_method == NULL)) {
6256 init_method = descr_method;
6260 if (is_compiled_function) {
6261 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
6264 result = CALL_FUNCTION_WITH_POS_ARGS7(tstate, init_method, pos_args);
6265 Py_DECREF(init_method);
6267 if (unlikely(result == NULL)) {
6273 if (unlikely(result != Py_None)) {
6274 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
6278 CHECK_OBJECT_X(obj);
6282#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
6283 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
6284 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6286 if (likely(func != NULL)) {
6287 PyObject *result = func(called, args, 7, NULL);
6289 CHECK_OBJECT_X(result);
6291 return Nuitka_CheckFunctionResult(tstate, called, result);
6298 PRINT_STRING(
"FALLBACK");
6303 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
6305 CHECK_OBJECT_X(result);
6309PyObject *CALL_FUNCTION_WITH_ARGS8(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
6310 CHECK_OBJECT(called);
6311 CHECK_OBJECTS(args, 8);
6313 if (Nuitka_Function_Check(called)) {
6314 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6321 if (function->m_args_simple && 8 == function->m_args_positional_count) {
6322 for (Py_ssize_t i = 0; i < 8; i++) {
6325 result = function->m_c_code(tstate, function, (PyObject **)args);
6326 }
else if (function->m_args_simple && 8 + function->m_defaults_given == function->m_args_positional_count) {
6327 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6329 memcpy(python_pars, args, 8 *
sizeof(PyObject *));
6330 memcpy(python_pars + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6331 function->m_defaults_given *
sizeof(PyObject *));
6333 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
6334 Py_INCREF(python_pars[i]);
6337 result = function->m_c_code(tstate, function, python_pars);
6339 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 8);
6342 Py_LeaveRecursiveCall();
6344 CHECK_OBJECT_X(result);
6347 }
else if (Nuitka_Method_Check(called)) {
6350 if (method->m_object == NULL) {
6351 PyObject *self = args[0];
6353 int res = PyObject_IsInstance(self, method->m_class);
6355 if (unlikely(res < 0)) {
6357 }
else if (unlikely(res == 0)) {
6358 PyErr_Format(PyExc_TypeError,
6359 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
6360 "instance instead)",
6361 GET_CALLABLE_NAME((PyObject *)method->m_function),
6362 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
6363 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
6368 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 8);
6370 CHECK_OBJECT_X(result);
6374 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6382 if (function->m_args_simple && 8 + 1 == function->m_args_positional_count) {
6383 PyObject *python_pars[8 + 1];
6385 python_pars[0] = method->m_object;
6386 Py_INCREF(method->m_object);
6388 for (Py_ssize_t i = 0; i < 8; i++) {
6389 python_pars[i + 1] = args[i];
6392 result = function->m_c_code(tstate, function, python_pars);
6393 }
else if (function->m_args_simple &&
6394 8 + 1 + function->m_defaults_given == function->m_args_positional_count) {
6395 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6397 python_pars[0] = method->m_object;
6398 Py_INCREF(method->m_object);
6400 memcpy(python_pars + 1, args, 8 *
sizeof(PyObject *));
6401 memcpy(python_pars + 1 + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6402 function->m_defaults_given *
sizeof(PyObject *));
6404 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
6405 Py_INCREF(python_pars[i]);
6408 result = function->m_c_code(tstate, function, python_pars);
6410 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 8);
6413 Py_LeaveRecursiveCall();
6415 CHECK_OBJECT_X(result);
6419#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
6420 }
else if (PyCFunction_CheckExact(called)) {
6421#if PYTHON_VERSION >= 0x380
6422#ifdef _NUITKA_FULL_COMPAT
6423 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6428 int flags = PyCFunction_GET_FLAGS(called);
6432 if (!(flags & METH_VARARGS)) {
6433 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6435 assert(func != NULL);
6436 result = func(called, args, 8, NULL);
6438 CHECK_OBJECT_X(result);
6440 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6441 PyObject *self = PyCFunction_GET_SELF(called);
6443 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6445 if (flags & METH_KEYWORDS) {
6446 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
6448 result = (*method)(self, pos_args);
6451 Py_DECREF(pos_args);
6454#ifdef _NUITKA_FULL_COMPAT
6455 Py_LeaveRecursiveCall();
6457 CHECK_OBJECT_X(result);
6459 return Nuitka_CheckFunctionResult(tstate, called, result);
6462 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
6464 if (unlikely(flags & METH_NOARGS)) {
6465 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (8 given)",
6466 ((PyCFunctionObject *)called)->m_ml->ml_name);
6468 }
else if (unlikely(flags & METH_O)) {
6469 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (8 given)",
6470 ((PyCFunctionObject *)called)->m_ml->ml_name);
6472 }
else if (flags & METH_VARARGS) {
6475#ifdef _NUITKA_FULL_COMPAT
6476 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6480 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6481 PyObject *self = PyCFunction_GET_SELF(called);
6485#if PYTHON_VERSION < 0x360
6486 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6487 if (flags & METH_KEYWORDS) {
6488 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6490 result = (*method)(self, pos_args);
6493 Py_DECREF(pos_args);
6495 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
6496 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6497 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6498 Py_DECREF(pos_args);
6499 }
else if (flags == METH_FASTCALL) {
6500#if PYTHON_VERSION < 0x370
6501 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 8, NULL);
6503 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6504 result = (*(_PyCFunctionFast)method)(self, &pos_args, 8);
6505 Py_DECREF(pos_args);
6508 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6509 result = (*method)(self, pos_args);
6510 Py_DECREF(pos_args);
6514#ifdef _NUITKA_FULL_COMPAT
6515 Py_LeaveRecursiveCall();
6518 CHECK_OBJECT_X(result);
6520 return Nuitka_CheckFunctionResult(tstate, called, result);
6524#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
6525 }
else if (PyFunction_Check(called)) {
6526#if PYTHON_VERSION < 0x3b0
6527 PyObject *result = callPythonFunction(called, args, 8);
6529 PyObject *result = _PyFunction_Vectorcall(called, args, 8, NULL);
6531 CHECK_OBJECT_X(result);
6535#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
6536 }
else if (PyType_Check(called)) {
6537 PyTypeObject *type = Py_TYPE(called);
6539 if (type->tp_call == PyType_Type.tp_call) {
6540 PyTypeObject *called_type = (PyTypeObject *)(called);
6542 if (unlikely(called_type->tp_new == NULL)) {
6543 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
6547 PyObject *pos_args = NULL;
6550 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
6551 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
6552 formatCannotInstantiateAbstractClass(tstate, called_type);
6556 obj = called_type->tp_alloc(called_type, 0);
6559 pos_args = MAKE_TUPLE(tstate, args, 8);
6560 obj = called_type->tp_new(called_type, pos_args, NULL);
6563 if (likely(obj != NULL)) {
6564 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
6565 Py_DECREF(pos_args);
6570 type = Py_TYPE(obj);
6572 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
6573 if (type->tp_init == default_tp_init_wrapper) {
6574 Py_XDECREF(pos_args);
6577 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
6580 assert(init_method != NULL);
6582 bool is_compiled_function =
false;
6583 bool init_method_needs_release =
false;
6585 if (likely(init_method != NULL)) {
6586 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
6588 if (func == Nuitka_Function_Type.tp_descr_get) {
6589 is_compiled_function =
true;
6590 }
else if (func != NULL) {
6591 init_method = func(init_method, obj, (PyObject *)(type));
6592 init_method_needs_release =
true;
6596 if (unlikely(init_method == NULL)) {
6597 if (!HAS_ERROR_OCCURRED(tstate)) {
6598 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
6599 const_str_plain___init__);
6606 if (is_compiled_function) {
6607 result = Nuitka_CallMethodFunctionPosArgs(
6610 result = CALL_FUNCTION_WITH_ARGS8(tstate, init_method, args);
6611 if (init_method_needs_release) {
6612 Py_DECREF(init_method);
6616 if (unlikely(result == NULL)) {
6623 if (unlikely(result != Py_None)) {
6626 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
6630 if (pos_args == NULL) {
6631 pos_args = MAKE_TUPLE(tstate, args, 8);
6634 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
6636 Py_XDECREF(pos_args);
6643 Py_XDECREF(pos_args);
6645 CHECK_OBJECT_X(obj);
6650#if PYTHON_VERSION < 0x300
6651 }
else if (PyClass_Check(called)) {
6652 PyObject *obj = PyInstance_NewRaw(called, NULL);
6654 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
6656 if (unlikely(init_method == NULL)) {
6657 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
6664 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
6668 bool is_compiled_function =
false;
6670 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
6672 if (descr_get == NULL) {
6673 Py_INCREF(init_method);
6674 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
6675 is_compiled_function =
true;
6676 }
else if (descr_get != NULL) {
6677 PyObject *descr_method = descr_get(init_method, obj, called);
6679 if (unlikely(descr_method == NULL)) {
6683 init_method = descr_method;
6687 if (is_compiled_function) {
6688 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
6691 result = CALL_FUNCTION_WITH_ARGS8(tstate, init_method, args);
6692 Py_DECREF(init_method);
6694 if (unlikely(result == NULL)) {
6700 if (unlikely(result != Py_None)) {
6701 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
6705 CHECK_OBJECT_X(obj);
6709#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
6710 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
6711 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6713 if (likely(func != NULL)) {
6714 PyObject *result = func(called, args, 8, NULL);
6716 CHECK_OBJECT_X(result);
6718 return Nuitka_CheckFunctionResult(tstate, called, result);
6725 PRINT_STRING(
"FALLBACK");
6730 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6732 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
6734 Py_DECREF(pos_args);
6736 CHECK_OBJECT_X(result);
6740PyObject *CALL_FUNCTION_WITH_POS_ARGS8(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
6741 assert(PyTuple_CheckExact(pos_args));
6742 assert(PyTuple_GET_SIZE(pos_args) == 8);
6743 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
6744 CHECK_OBJECT(called);
6745 CHECK_OBJECTS(args, 8);
6747 if (Nuitka_Function_Check(called)) {
6748 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6755 if (function->m_args_simple && 8 == function->m_args_positional_count) {
6756 for (Py_ssize_t i = 0; i < 8; i++) {
6759 result = function->m_c_code(tstate, function, (PyObject **)args);
6760 }
else if (function->m_args_simple && 8 + function->m_defaults_given == function->m_args_positional_count) {
6761 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6763 memcpy(python_pars, args, 8 *
sizeof(PyObject *));
6764 memcpy(python_pars + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6765 function->m_defaults_given *
sizeof(PyObject *));
6767 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
6768 Py_INCREF(python_pars[i]);
6771 result = function->m_c_code(tstate, function, python_pars);
6773 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 8);
6776 Py_LeaveRecursiveCall();
6778 CHECK_OBJECT_X(result);
6781 }
else if (Nuitka_Method_Check(called)) {
6784 if (method->m_object == NULL) {
6785 PyObject *self = args[0];
6787 int res = PyObject_IsInstance(self, method->m_class);
6789 if (unlikely(res < 0)) {
6791 }
else if (unlikely(res == 0)) {
6792 PyErr_Format(PyExc_TypeError,
6793 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
6794 "instance instead)",
6795 GET_CALLABLE_NAME((PyObject *)method->m_function),
6796 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
6797 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
6802 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 8);
6804 CHECK_OBJECT_X(result);
6808 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6816 if (function->m_args_simple && 8 + 1 == function->m_args_positional_count) {
6817 PyObject *python_pars[8 + 1];
6819 python_pars[0] = method->m_object;
6820 Py_INCREF(method->m_object);
6822 for (Py_ssize_t i = 0; i < 8; i++) {
6823 python_pars[i + 1] = args[i];
6826 result = function->m_c_code(tstate, function, python_pars);
6827 }
else if (function->m_args_simple &&
6828 8 + 1 + function->m_defaults_given == function->m_args_positional_count) {
6829 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6831 python_pars[0] = method->m_object;
6832 Py_INCREF(method->m_object);
6834 memcpy(python_pars + 1, args, 8 *
sizeof(PyObject *));
6835 memcpy(python_pars + 1 + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6836 function->m_defaults_given *
sizeof(PyObject *));
6838 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
6839 Py_INCREF(python_pars[i]);
6842 result = function->m_c_code(tstate, function, python_pars);
6844 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 8);
6847 Py_LeaveRecursiveCall();
6849 CHECK_OBJECT_X(result);
6853#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
6854 }
else if (PyCFunction_CheckExact(called)) {
6855#if PYTHON_VERSION >= 0x380
6856#ifdef _NUITKA_FULL_COMPAT
6857 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6862 int flags = PyCFunction_GET_FLAGS(called);
6866 if (!(flags & METH_VARARGS)) {
6867 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6869 assert(func != NULL);
6870 result = func(called, args, 8, NULL);
6872 CHECK_OBJECT_X(result);
6874 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6875 PyObject *self = PyCFunction_GET_SELF(called);
6877 if (flags & METH_KEYWORDS) {
6878 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
6880 result = (*method)(self, pos_args);
6884#ifdef _NUITKA_FULL_COMPAT
6885 Py_LeaveRecursiveCall();
6887 CHECK_OBJECT_X(result);
6889 return Nuitka_CheckFunctionResult(tstate, called, result);
6892 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
6894 if (unlikely(flags & METH_NOARGS)) {
6895 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (8 given)",
6896 ((PyCFunctionObject *)called)->m_ml->ml_name);
6898 }
else if (unlikely(flags & METH_O)) {
6899 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (8 given)",
6900 ((PyCFunctionObject *)called)->m_ml->ml_name);
6902 }
else if (flags & METH_VARARGS) {
6905#ifdef _NUITKA_FULL_COMPAT
6906 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6910 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6911 PyObject *self = PyCFunction_GET_SELF(called);
6915#if PYTHON_VERSION < 0x360
6916 if (flags & METH_KEYWORDS) {
6917 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6919 result = (*method)(self, pos_args);
6923 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
6924 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6925 }
else if (flags == METH_FASTCALL) {
6926#if PYTHON_VERSION < 0x370
6927 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 8, NULL);
6929 result = (*(_PyCFunctionFast)method)(self, &pos_args, 8);
6932 result = (*method)(self, pos_args);
6936#ifdef _NUITKA_FULL_COMPAT
6937 Py_LeaveRecursiveCall();
6940 CHECK_OBJECT_X(result);
6942 return Nuitka_CheckFunctionResult(tstate, called, result);
6946#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
6947 }
else if (PyFunction_Check(called)) {
6948#if PYTHON_VERSION < 0x3b0
6949 PyObject *result = callPythonFunction(called, args, 8);
6951 PyObject *result = _PyFunction_Vectorcall(called, args, 8, NULL);
6953 CHECK_OBJECT_X(result);
6957#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
6958 }
else if (PyType_Check(called)) {
6959 PyTypeObject *type = Py_TYPE(called);
6961 if (type->tp_call == PyType_Type.tp_call) {
6962 PyTypeObject *called_type = (PyTypeObject *)(called);
6964 if (unlikely(called_type->tp_new == NULL)) {
6965 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
6971 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
6972 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
6973 formatCannotInstantiateAbstractClass(tstate, called_type);
6977 obj = called_type->tp_alloc(called_type, 0);
6980 obj = called_type->tp_new(called_type, pos_args, NULL);
6983 if (likely(obj != NULL)) {
6984 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
6989 type = Py_TYPE(obj);
6991 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
6992 if (type->tp_init == default_tp_init_wrapper) {
6994 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
6997 assert(init_method != NULL);
6999 bool is_compiled_function =
false;
7000 bool init_method_needs_release =
false;
7002 if (likely(init_method != NULL)) {
7003 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
7005 if (func == Nuitka_Function_Type.tp_descr_get) {
7006 is_compiled_function =
true;
7007 }
else if (func != NULL) {
7008 init_method = func(init_method, obj, (PyObject *)(type));
7009 init_method_needs_release =
true;
7013 if (unlikely(init_method == NULL)) {
7014 if (!HAS_ERROR_OCCURRED(tstate)) {
7015 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
7016 const_str_plain___init__);
7023 if (is_compiled_function) {
7024 result = Nuitka_CallMethodFunctionPosArgs(
7027 result = CALL_FUNCTION_WITH_POS_ARGS8(tstate, init_method, pos_args);
7028 if (init_method_needs_release) {
7029 Py_DECREF(init_method);
7033 if (unlikely(result == NULL)) {
7040 if (unlikely(result != Py_None)) {
7043 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7048 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
7056 CHECK_OBJECT_X(obj);
7061#if PYTHON_VERSION < 0x300
7062 }
else if (PyClass_Check(called)) {
7063 PyObject *obj = PyInstance_NewRaw(called, NULL);
7065 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
7067 if (unlikely(init_method == NULL)) {
7068 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
7075 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
7079 bool is_compiled_function =
false;
7081 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
7083 if (descr_get == NULL) {
7084 Py_INCREF(init_method);
7085 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
7086 is_compiled_function =
true;
7087 }
else if (descr_get != NULL) {
7088 PyObject *descr_method = descr_get(init_method, obj, called);
7090 if (unlikely(descr_method == NULL)) {
7094 init_method = descr_method;
7098 if (is_compiled_function) {
7099 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
7102 result = CALL_FUNCTION_WITH_POS_ARGS8(tstate, init_method, pos_args);
7103 Py_DECREF(init_method);
7105 if (unlikely(result == NULL)) {
7111 if (unlikely(result != Py_None)) {
7112 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7116 CHECK_OBJECT_X(obj);
7120#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
7121 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
7122 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7124 if (likely(func != NULL)) {
7125 PyObject *result = func(called, args, 8, NULL);
7127 CHECK_OBJECT_X(result);
7129 return Nuitka_CheckFunctionResult(tstate, called, result);
7136 PRINT_STRING(
"FALLBACK");
7141 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
7143 CHECK_OBJECT_X(result);
7147PyObject *CALL_FUNCTION_WITH_ARGS9(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
7148 CHECK_OBJECT(called);
7149 CHECK_OBJECTS(args, 9);
7151 if (Nuitka_Function_Check(called)) {
7152 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7159 if (function->m_args_simple && 9 == function->m_args_positional_count) {
7160 for (Py_ssize_t i = 0; i < 9; i++) {
7163 result = function->m_c_code(tstate, function, (PyObject **)args);
7164 }
else if (function->m_args_simple && 9 + function->m_defaults_given == function->m_args_positional_count) {
7165 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7167 memcpy(python_pars, args, 9 *
sizeof(PyObject *));
7168 memcpy(python_pars + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7169 function->m_defaults_given *
sizeof(PyObject *));
7171 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
7172 Py_INCREF(python_pars[i]);
7175 result = function->m_c_code(tstate, function, python_pars);
7177 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 9);
7180 Py_LeaveRecursiveCall();
7182 CHECK_OBJECT_X(result);
7185 }
else if (Nuitka_Method_Check(called)) {
7188 if (method->m_object == NULL) {
7189 PyObject *self = args[0];
7191 int res = PyObject_IsInstance(self, method->m_class);
7193 if (unlikely(res < 0)) {
7195 }
else if (unlikely(res == 0)) {
7196 PyErr_Format(PyExc_TypeError,
7197 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
7198 "instance instead)",
7199 GET_CALLABLE_NAME((PyObject *)method->m_function),
7200 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
7201 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
7206 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 9);
7208 CHECK_OBJECT_X(result);
7212 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7220 if (function->m_args_simple && 9 + 1 == function->m_args_positional_count) {
7221 PyObject *python_pars[9 + 1];
7223 python_pars[0] = method->m_object;
7224 Py_INCREF(method->m_object);
7226 for (Py_ssize_t i = 0; i < 9; i++) {
7227 python_pars[i + 1] = args[i];
7230 result = function->m_c_code(tstate, function, python_pars);
7231 }
else if (function->m_args_simple &&
7232 9 + 1 + function->m_defaults_given == function->m_args_positional_count) {
7233 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7235 python_pars[0] = method->m_object;
7236 Py_INCREF(method->m_object);
7238 memcpy(python_pars + 1, args, 9 *
sizeof(PyObject *));
7239 memcpy(python_pars + 1 + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7240 function->m_defaults_given *
sizeof(PyObject *));
7242 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
7243 Py_INCREF(python_pars[i]);
7246 result = function->m_c_code(tstate, function, python_pars);
7248 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 9);
7251 Py_LeaveRecursiveCall();
7253 CHECK_OBJECT_X(result);
7257#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
7258 }
else if (PyCFunction_CheckExact(called)) {
7259#if PYTHON_VERSION >= 0x380
7260#ifdef _NUITKA_FULL_COMPAT
7261 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7266 int flags = PyCFunction_GET_FLAGS(called);
7270 if (!(flags & METH_VARARGS)) {
7271 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7273 assert(func != NULL);
7274 result = func(called, args, 9, NULL);
7276 CHECK_OBJECT_X(result);
7278 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7279 PyObject *self = PyCFunction_GET_SELF(called);
7281 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7283 if (flags & METH_KEYWORDS) {
7284 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
7286 result = (*method)(self, pos_args);
7289 Py_DECREF(pos_args);
7292#ifdef _NUITKA_FULL_COMPAT
7293 Py_LeaveRecursiveCall();
7295 CHECK_OBJECT_X(result);
7297 return Nuitka_CheckFunctionResult(tstate, called, result);
7300 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
7302 if (unlikely(flags & METH_NOARGS)) {
7303 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (9 given)",
7304 ((PyCFunctionObject *)called)->m_ml->ml_name);
7306 }
else if (unlikely(flags & METH_O)) {
7307 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (9 given)",
7308 ((PyCFunctionObject *)called)->m_ml->ml_name);
7310 }
else if (flags & METH_VARARGS) {
7313#ifdef _NUITKA_FULL_COMPAT
7314 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7318 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7319 PyObject *self = PyCFunction_GET_SELF(called);
7323#if PYTHON_VERSION < 0x360
7324 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7325 if (flags & METH_KEYWORDS) {
7326 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7328 result = (*method)(self, pos_args);
7331 Py_DECREF(pos_args);
7333 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
7334 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7335 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7336 Py_DECREF(pos_args);
7337 }
else if (flags == METH_FASTCALL) {
7338#if PYTHON_VERSION < 0x370
7339 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 9, NULL);
7341 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7342 result = (*(_PyCFunctionFast)method)(self, &pos_args, 9);
7343 Py_DECREF(pos_args);
7346 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7347 result = (*method)(self, pos_args);
7348 Py_DECREF(pos_args);
7352#ifdef _NUITKA_FULL_COMPAT
7353 Py_LeaveRecursiveCall();
7356 CHECK_OBJECT_X(result);
7358 return Nuitka_CheckFunctionResult(tstate, called, result);
7362#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
7363 }
else if (PyFunction_Check(called)) {
7364#if PYTHON_VERSION < 0x3b0
7365 PyObject *result = callPythonFunction(called, args, 9);
7367 PyObject *result = _PyFunction_Vectorcall(called, args, 9, NULL);
7369 CHECK_OBJECT_X(result);
7373#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
7374 }
else if (PyType_Check(called)) {
7375 PyTypeObject *type = Py_TYPE(called);
7377 if (type->tp_call == PyType_Type.tp_call) {
7378 PyTypeObject *called_type = (PyTypeObject *)(called);
7380 if (unlikely(called_type->tp_new == NULL)) {
7381 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
7385 PyObject *pos_args = NULL;
7388 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
7389 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
7390 formatCannotInstantiateAbstractClass(tstate, called_type);
7394 obj = called_type->tp_alloc(called_type, 0);
7397 pos_args = MAKE_TUPLE(tstate, args, 9);
7398 obj = called_type->tp_new(called_type, pos_args, NULL);
7401 if (likely(obj != NULL)) {
7402 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
7403 Py_DECREF(pos_args);
7408 type = Py_TYPE(obj);
7410 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
7411 if (type->tp_init == default_tp_init_wrapper) {
7412 Py_XDECREF(pos_args);
7415 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
7418 assert(init_method != NULL);
7420 bool is_compiled_function =
false;
7421 bool init_method_needs_release =
false;
7423 if (likely(init_method != NULL)) {
7424 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
7426 if (func == Nuitka_Function_Type.tp_descr_get) {
7427 is_compiled_function =
true;
7428 }
else if (func != NULL) {
7429 init_method = func(init_method, obj, (PyObject *)(type));
7430 init_method_needs_release =
true;
7434 if (unlikely(init_method == NULL)) {
7435 if (!HAS_ERROR_OCCURRED(tstate)) {
7436 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
7437 const_str_plain___init__);
7444 if (is_compiled_function) {
7445 result = Nuitka_CallMethodFunctionPosArgs(
7448 result = CALL_FUNCTION_WITH_ARGS9(tstate, init_method, args);
7449 if (init_method_needs_release) {
7450 Py_DECREF(init_method);
7454 if (unlikely(result == NULL)) {
7461 if (unlikely(result != Py_None)) {
7464 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7468 if (pos_args == NULL) {
7469 pos_args = MAKE_TUPLE(tstate, args, 9);
7472 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
7474 Py_XDECREF(pos_args);
7481 Py_XDECREF(pos_args);
7483 CHECK_OBJECT_X(obj);
7488#if PYTHON_VERSION < 0x300
7489 }
else if (PyClass_Check(called)) {
7490 PyObject *obj = PyInstance_NewRaw(called, NULL);
7492 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
7494 if (unlikely(init_method == NULL)) {
7495 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
7502 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
7506 bool is_compiled_function =
false;
7508 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
7510 if (descr_get == NULL) {
7511 Py_INCREF(init_method);
7512 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
7513 is_compiled_function =
true;
7514 }
else if (descr_get != NULL) {
7515 PyObject *descr_method = descr_get(init_method, obj, called);
7517 if (unlikely(descr_method == NULL)) {
7521 init_method = descr_method;
7525 if (is_compiled_function) {
7526 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
7529 result = CALL_FUNCTION_WITH_ARGS9(tstate, init_method, args);
7530 Py_DECREF(init_method);
7532 if (unlikely(result == NULL)) {
7538 if (unlikely(result != Py_None)) {
7539 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7543 CHECK_OBJECT_X(obj);
7547#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
7548 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
7549 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7551 if (likely(func != NULL)) {
7552 PyObject *result = func(called, args, 9, NULL);
7554 CHECK_OBJECT_X(result);
7556 return Nuitka_CheckFunctionResult(tstate, called, result);
7563 PRINT_STRING(
"FALLBACK");
7568 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7570 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
7572 Py_DECREF(pos_args);
7574 CHECK_OBJECT_X(result);
7578PyObject *CALL_FUNCTION_WITH_POS_ARGS9(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
7579 assert(PyTuple_CheckExact(pos_args));
7580 assert(PyTuple_GET_SIZE(pos_args) == 9);
7581 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
7582 CHECK_OBJECT(called);
7583 CHECK_OBJECTS(args, 9);
7585 if (Nuitka_Function_Check(called)) {
7586 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7593 if (function->m_args_simple && 9 == function->m_args_positional_count) {
7594 for (Py_ssize_t i = 0; i < 9; i++) {
7597 result = function->m_c_code(tstate, function, (PyObject **)args);
7598 }
else if (function->m_args_simple && 9 + function->m_defaults_given == function->m_args_positional_count) {
7599 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7601 memcpy(python_pars, args, 9 *
sizeof(PyObject *));
7602 memcpy(python_pars + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7603 function->m_defaults_given *
sizeof(PyObject *));
7605 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
7606 Py_INCREF(python_pars[i]);
7609 result = function->m_c_code(tstate, function, python_pars);
7611 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 9);
7614 Py_LeaveRecursiveCall();
7616 CHECK_OBJECT_X(result);
7619 }
else if (Nuitka_Method_Check(called)) {
7622 if (method->m_object == NULL) {
7623 PyObject *self = args[0];
7625 int res = PyObject_IsInstance(self, method->m_class);
7627 if (unlikely(res < 0)) {
7629 }
else if (unlikely(res == 0)) {
7630 PyErr_Format(PyExc_TypeError,
7631 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
7632 "instance instead)",
7633 GET_CALLABLE_NAME((PyObject *)method->m_function),
7634 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
7635 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
7640 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 9);
7642 CHECK_OBJECT_X(result);
7646 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7654 if (function->m_args_simple && 9 + 1 == function->m_args_positional_count) {
7655 PyObject *python_pars[9 + 1];
7657 python_pars[0] = method->m_object;
7658 Py_INCREF(method->m_object);
7660 for (Py_ssize_t i = 0; i < 9; i++) {
7661 python_pars[i + 1] = args[i];
7664 result = function->m_c_code(tstate, function, python_pars);
7665 }
else if (function->m_args_simple &&
7666 9 + 1 + function->m_defaults_given == function->m_args_positional_count) {
7667 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7669 python_pars[0] = method->m_object;
7670 Py_INCREF(method->m_object);
7672 memcpy(python_pars + 1, args, 9 *
sizeof(PyObject *));
7673 memcpy(python_pars + 1 + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7674 function->m_defaults_given *
sizeof(PyObject *));
7676 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
7677 Py_INCREF(python_pars[i]);
7680 result = function->m_c_code(tstate, function, python_pars);
7682 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 9);
7685 Py_LeaveRecursiveCall();
7687 CHECK_OBJECT_X(result);
7691#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
7692 }
else if (PyCFunction_CheckExact(called)) {
7693#if PYTHON_VERSION >= 0x380
7694#ifdef _NUITKA_FULL_COMPAT
7695 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7700 int flags = PyCFunction_GET_FLAGS(called);
7704 if (!(flags & METH_VARARGS)) {
7705 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7707 assert(func != NULL);
7708 result = func(called, args, 9, NULL);
7710 CHECK_OBJECT_X(result);
7712 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7713 PyObject *self = PyCFunction_GET_SELF(called);
7715 if (flags & METH_KEYWORDS) {
7716 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
7718 result = (*method)(self, pos_args);
7722#ifdef _NUITKA_FULL_COMPAT
7723 Py_LeaveRecursiveCall();
7725 CHECK_OBJECT_X(result);
7727 return Nuitka_CheckFunctionResult(tstate, called, result);
7730 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
7732 if (unlikely(flags & METH_NOARGS)) {
7733 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (9 given)",
7734 ((PyCFunctionObject *)called)->m_ml->ml_name);
7736 }
else if (unlikely(flags & METH_O)) {
7737 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (9 given)",
7738 ((PyCFunctionObject *)called)->m_ml->ml_name);
7740 }
else if (flags & METH_VARARGS) {
7743#ifdef _NUITKA_FULL_COMPAT
7744 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7748 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7749 PyObject *self = PyCFunction_GET_SELF(called);
7753#if PYTHON_VERSION < 0x360
7754 if (flags & METH_KEYWORDS) {
7755 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7757 result = (*method)(self, pos_args);
7761 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
7762 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7763 }
else if (flags == METH_FASTCALL) {
7764#if PYTHON_VERSION < 0x370
7765 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 9, NULL);
7767 result = (*(_PyCFunctionFast)method)(self, &pos_args, 9);
7770 result = (*method)(self, pos_args);
7774#ifdef _NUITKA_FULL_COMPAT
7775 Py_LeaveRecursiveCall();
7778 CHECK_OBJECT_X(result);
7780 return Nuitka_CheckFunctionResult(tstate, called, result);
7784#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
7785 }
else if (PyFunction_Check(called)) {
7786#if PYTHON_VERSION < 0x3b0
7787 PyObject *result = callPythonFunction(called, args, 9);
7789 PyObject *result = _PyFunction_Vectorcall(called, args, 9, NULL);
7791 CHECK_OBJECT_X(result);
7795#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
7796 }
else if (PyType_Check(called)) {
7797 PyTypeObject *type = Py_TYPE(called);
7799 if (type->tp_call == PyType_Type.tp_call) {
7800 PyTypeObject *called_type = (PyTypeObject *)(called);
7802 if (unlikely(called_type->tp_new == NULL)) {
7803 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
7809 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
7810 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
7811 formatCannotInstantiateAbstractClass(tstate, called_type);
7815 obj = called_type->tp_alloc(called_type, 0);
7818 obj = called_type->tp_new(called_type, pos_args, NULL);
7821 if (likely(obj != NULL)) {
7822 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
7827 type = Py_TYPE(obj);
7829 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
7830 if (type->tp_init == default_tp_init_wrapper) {
7832 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
7835 assert(init_method != NULL);
7837 bool is_compiled_function =
false;
7838 bool init_method_needs_release =
false;
7840 if (likely(init_method != NULL)) {
7841 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
7843 if (func == Nuitka_Function_Type.tp_descr_get) {
7844 is_compiled_function =
true;
7845 }
else if (func != NULL) {
7846 init_method = func(init_method, obj, (PyObject *)(type));
7847 init_method_needs_release =
true;
7851 if (unlikely(init_method == NULL)) {
7852 if (!HAS_ERROR_OCCURRED(tstate)) {
7853 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
7854 const_str_plain___init__);
7861 if (is_compiled_function) {
7862 result = Nuitka_CallMethodFunctionPosArgs(
7865 result = CALL_FUNCTION_WITH_POS_ARGS9(tstate, init_method, pos_args);
7866 if (init_method_needs_release) {
7867 Py_DECREF(init_method);
7871 if (unlikely(result == NULL)) {
7878 if (unlikely(result != Py_None)) {
7881 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7886 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
7894 CHECK_OBJECT_X(obj);
7899#if PYTHON_VERSION < 0x300
7900 }
else if (PyClass_Check(called)) {
7901 PyObject *obj = PyInstance_NewRaw(called, NULL);
7903 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
7905 if (unlikely(init_method == NULL)) {
7906 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
7913 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
7917 bool is_compiled_function =
false;
7919 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
7921 if (descr_get == NULL) {
7922 Py_INCREF(init_method);
7923 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
7924 is_compiled_function =
true;
7925 }
else if (descr_get != NULL) {
7926 PyObject *descr_method = descr_get(init_method, obj, called);
7928 if (unlikely(descr_method == NULL)) {
7932 init_method = descr_method;
7936 if (is_compiled_function) {
7937 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
7940 result = CALL_FUNCTION_WITH_POS_ARGS9(tstate, init_method, pos_args);
7941 Py_DECREF(init_method);
7943 if (unlikely(result == NULL)) {
7949 if (unlikely(result != Py_None)) {
7950 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7954 CHECK_OBJECT_X(obj);
7958#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
7959 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
7960 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7962 if (likely(func != NULL)) {
7963 PyObject *result = func(called, args, 9, NULL);
7965 CHECK_OBJECT_X(result);
7967 return Nuitka_CheckFunctionResult(tstate, called, result);
7974 PRINT_STRING(
"FALLBACK");
7979 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
7981 CHECK_OBJECT_X(result);
7985PyObject *CALL_FUNCTION_WITH_ARGS10(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
7986 CHECK_OBJECT(called);
7987 CHECK_OBJECTS(args, 10);
7989 if (Nuitka_Function_Check(called)) {
7990 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7997 if (function->m_args_simple && 10 == function->m_args_positional_count) {
7998 for (Py_ssize_t i = 0; i < 10; i++) {
8001 result = function->m_c_code(tstate, function, (PyObject **)args);
8002 }
else if (function->m_args_simple && 10 + function->m_defaults_given == function->m_args_positional_count) {
8003 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8005 memcpy(python_pars, args, 10 *
sizeof(PyObject *));
8006 memcpy(python_pars + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8007 function->m_defaults_given *
sizeof(PyObject *));
8009 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
8010 Py_INCREF(python_pars[i]);
8013 result = function->m_c_code(tstate, function, python_pars);
8015 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 10);
8018 Py_LeaveRecursiveCall();
8020 CHECK_OBJECT_X(result);
8023 }
else if (Nuitka_Method_Check(called)) {
8026 if (method->m_object == NULL) {
8027 PyObject *self = args[0];
8029 int res = PyObject_IsInstance(self, method->m_class);
8031 if (unlikely(res < 0)) {
8033 }
else if (unlikely(res == 0)) {
8034 PyErr_Format(PyExc_TypeError,
8035 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
8036 "instance instead)",
8037 GET_CALLABLE_NAME((PyObject *)method->m_function),
8038 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
8039 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
8044 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 10);
8046 CHECK_OBJECT_X(result);
8050 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8058 if (function->m_args_simple && 10 + 1 == function->m_args_positional_count) {
8059 PyObject *python_pars[10 + 1];
8061 python_pars[0] = method->m_object;
8062 Py_INCREF(method->m_object);
8064 for (Py_ssize_t i = 0; i < 10; i++) {
8065 python_pars[i + 1] = args[i];
8068 result = function->m_c_code(tstate, function, python_pars);
8069 }
else if (function->m_args_simple &&
8070 10 + 1 + function->m_defaults_given == function->m_args_positional_count) {
8071 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8073 python_pars[0] = method->m_object;
8074 Py_INCREF(method->m_object);
8076 memcpy(python_pars + 1, args, 10 *
sizeof(PyObject *));
8077 memcpy(python_pars + 1 + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8078 function->m_defaults_given *
sizeof(PyObject *));
8080 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
8081 Py_INCREF(python_pars[i]);
8084 result = function->m_c_code(tstate, function, python_pars);
8086 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 10);
8089 Py_LeaveRecursiveCall();
8091 CHECK_OBJECT_X(result);
8095#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
8096 }
else if (PyCFunction_CheckExact(called)) {
8097#if PYTHON_VERSION >= 0x380
8098#ifdef _NUITKA_FULL_COMPAT
8099 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8104 int flags = PyCFunction_GET_FLAGS(called);
8108 if (!(flags & METH_VARARGS)) {
8109 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8111 assert(func != NULL);
8112 result = func(called, args, 10, NULL);
8114 CHECK_OBJECT_X(result);
8116 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8117 PyObject *self = PyCFunction_GET_SELF(called);
8119 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8121 if (flags & METH_KEYWORDS) {
8122 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
8124 result = (*method)(self, pos_args);
8127 Py_DECREF(pos_args);
8130#ifdef _NUITKA_FULL_COMPAT
8131 Py_LeaveRecursiveCall();
8133 CHECK_OBJECT_X(result);
8135 return Nuitka_CheckFunctionResult(tstate, called, result);
8138 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
8140 if (unlikely(flags & METH_NOARGS)) {
8141 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (10 given)",
8142 ((PyCFunctionObject *)called)->m_ml->ml_name);
8144 }
else if (unlikely(flags & METH_O)) {
8145 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (10 given)",
8146 ((PyCFunctionObject *)called)->m_ml->ml_name);
8148 }
else if (flags & METH_VARARGS) {
8151#ifdef _NUITKA_FULL_COMPAT
8152 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8156 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8157 PyObject *self = PyCFunction_GET_SELF(called);
8161#if PYTHON_VERSION < 0x360
8162 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8163 if (flags & METH_KEYWORDS) {
8164 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8166 result = (*method)(self, pos_args);
8169 Py_DECREF(pos_args);
8171 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
8172 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8173 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8174 Py_DECREF(pos_args);
8175 }
else if (flags == METH_FASTCALL) {
8176#if PYTHON_VERSION < 0x370
8177 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 10, NULL);
8179 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8180 result = (*(_PyCFunctionFast)method)(self, &pos_args, 10);
8181 Py_DECREF(pos_args);
8184 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8185 result = (*method)(self, pos_args);
8186 Py_DECREF(pos_args);
8190#ifdef _NUITKA_FULL_COMPAT
8191 Py_LeaveRecursiveCall();
8194 CHECK_OBJECT_X(result);
8196 return Nuitka_CheckFunctionResult(tstate, called, result);
8200#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
8201 }
else if (PyFunction_Check(called)) {
8202#if PYTHON_VERSION < 0x3b0
8203 PyObject *result = callPythonFunction(called, args, 10);
8205 PyObject *result = _PyFunction_Vectorcall(called, args, 10, NULL);
8207 CHECK_OBJECT_X(result);
8211#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
8212 }
else if (PyType_Check(called)) {
8213 PyTypeObject *type = Py_TYPE(called);
8215 if (type->tp_call == PyType_Type.tp_call) {
8216 PyTypeObject *called_type = (PyTypeObject *)(called);
8218 if (unlikely(called_type->tp_new == NULL)) {
8219 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
8223 PyObject *pos_args = NULL;
8226 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
8227 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
8228 formatCannotInstantiateAbstractClass(tstate, called_type);
8232 obj = called_type->tp_alloc(called_type, 0);
8235 pos_args = MAKE_TUPLE(tstate, args, 10);
8236 obj = called_type->tp_new(called_type, pos_args, NULL);
8239 if (likely(obj != NULL)) {
8240 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
8241 Py_DECREF(pos_args);
8246 type = Py_TYPE(obj);
8248 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
8249 if (type->tp_init == default_tp_init_wrapper) {
8250 Py_XDECREF(pos_args);
8253 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
8256 assert(init_method != NULL);
8258 bool is_compiled_function =
false;
8259 bool init_method_needs_release =
false;
8261 if (likely(init_method != NULL)) {
8262 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
8264 if (func == Nuitka_Function_Type.tp_descr_get) {
8265 is_compiled_function =
true;
8266 }
else if (func != NULL) {
8267 init_method = func(init_method, obj, (PyObject *)(type));
8268 init_method_needs_release =
true;
8272 if (unlikely(init_method == NULL)) {
8273 if (!HAS_ERROR_OCCURRED(tstate)) {
8274 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
8275 const_str_plain___init__);
8282 if (is_compiled_function) {
8283 result = Nuitka_CallMethodFunctionPosArgs(
8286 result = CALL_FUNCTION_WITH_ARGS10(tstate, init_method, args);
8287 if (init_method_needs_release) {
8288 Py_DECREF(init_method);
8292 if (unlikely(result == NULL)) {
8299 if (unlikely(result != Py_None)) {
8302 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
8306 if (pos_args == NULL) {
8307 pos_args = MAKE_TUPLE(tstate, args, 10);
8310 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
8312 Py_XDECREF(pos_args);
8319 Py_XDECREF(pos_args);
8321 CHECK_OBJECT_X(obj);
8326#if PYTHON_VERSION < 0x300
8327 }
else if (PyClass_Check(called)) {
8328 PyObject *obj = PyInstance_NewRaw(called, NULL);
8330 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
8332 if (unlikely(init_method == NULL)) {
8333 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
8340 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
8344 bool is_compiled_function =
false;
8346 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
8348 if (descr_get == NULL) {
8349 Py_INCREF(init_method);
8350 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
8351 is_compiled_function =
true;
8352 }
else if (descr_get != NULL) {
8353 PyObject *descr_method = descr_get(init_method, obj, called);
8355 if (unlikely(descr_method == NULL)) {
8359 init_method = descr_method;
8363 if (is_compiled_function) {
8364 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
8367 result = CALL_FUNCTION_WITH_ARGS10(tstate, init_method, args);
8368 Py_DECREF(init_method);
8370 if (unlikely(result == NULL)) {
8376 if (unlikely(result != Py_None)) {
8377 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
8381 CHECK_OBJECT_X(obj);
8385#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8386 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8387 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8389 if (likely(func != NULL)) {
8390 PyObject *result = func(called, args, 10, NULL);
8392 CHECK_OBJECT_X(result);
8394 return Nuitka_CheckFunctionResult(tstate, called, result);
8401 PRINT_STRING(
"FALLBACK");
8406 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8408 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
8410 Py_DECREF(pos_args);
8412 CHECK_OBJECT_X(result);
8416PyObject *CALL_FUNCTION_WITH_POS_ARGS10(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
8417 assert(PyTuple_CheckExact(pos_args));
8418 assert(PyTuple_GET_SIZE(pos_args) == 10);
8419 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
8420 CHECK_OBJECT(called);
8421 CHECK_OBJECTS(args, 10);
8423 if (Nuitka_Function_Check(called)) {
8424 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8431 if (function->m_args_simple && 10 == function->m_args_positional_count) {
8432 for (Py_ssize_t i = 0; i < 10; i++) {
8435 result = function->m_c_code(tstate, function, (PyObject **)args);
8436 }
else if (function->m_args_simple && 10 + function->m_defaults_given == function->m_args_positional_count) {
8437 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8439 memcpy(python_pars, args, 10 *
sizeof(PyObject *));
8440 memcpy(python_pars + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8441 function->m_defaults_given *
sizeof(PyObject *));
8443 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
8444 Py_INCREF(python_pars[i]);
8447 result = function->m_c_code(tstate, function, python_pars);
8449 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 10);
8452 Py_LeaveRecursiveCall();
8454 CHECK_OBJECT_X(result);
8457 }
else if (Nuitka_Method_Check(called)) {
8460 if (method->m_object == NULL) {
8461 PyObject *self = args[0];
8463 int res = PyObject_IsInstance(self, method->m_class);
8465 if (unlikely(res < 0)) {
8467 }
else if (unlikely(res == 0)) {
8468 PyErr_Format(PyExc_TypeError,
8469 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
8470 "instance instead)",
8471 GET_CALLABLE_NAME((PyObject *)method->m_function),
8472 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
8473 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
8478 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 10);
8480 CHECK_OBJECT_X(result);
8484 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8492 if (function->m_args_simple && 10 + 1 == function->m_args_positional_count) {
8493 PyObject *python_pars[10 + 1];
8495 python_pars[0] = method->m_object;
8496 Py_INCREF(method->m_object);
8498 for (Py_ssize_t i = 0; i < 10; i++) {
8499 python_pars[i + 1] = args[i];
8502 result = function->m_c_code(tstate, function, python_pars);
8503 }
else if (function->m_args_simple &&
8504 10 + 1 + function->m_defaults_given == function->m_args_positional_count) {
8505 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8507 python_pars[0] = method->m_object;
8508 Py_INCREF(method->m_object);
8510 memcpy(python_pars + 1, args, 10 *
sizeof(PyObject *));
8511 memcpy(python_pars + 1 + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8512 function->m_defaults_given *
sizeof(PyObject *));
8514 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
8515 Py_INCREF(python_pars[i]);
8518 result = function->m_c_code(tstate, function, python_pars);
8520 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 10);
8523 Py_LeaveRecursiveCall();
8525 CHECK_OBJECT_X(result);
8529#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
8530 }
else if (PyCFunction_CheckExact(called)) {
8531#if PYTHON_VERSION >= 0x380
8532#ifdef _NUITKA_FULL_COMPAT
8533 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8538 int flags = PyCFunction_GET_FLAGS(called);
8542 if (!(flags & METH_VARARGS)) {
8543 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8545 assert(func != NULL);
8546 result = func(called, args, 10, NULL);
8548 CHECK_OBJECT_X(result);
8550 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8551 PyObject *self = PyCFunction_GET_SELF(called);
8553 if (flags & METH_KEYWORDS) {
8554 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
8556 result = (*method)(self, pos_args);
8560#ifdef _NUITKA_FULL_COMPAT
8561 Py_LeaveRecursiveCall();
8563 CHECK_OBJECT_X(result);
8565 return Nuitka_CheckFunctionResult(tstate, called, result);
8568 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
8570 if (unlikely(flags & METH_NOARGS)) {
8571 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (10 given)",
8572 ((PyCFunctionObject *)called)->m_ml->ml_name);
8574 }
else if (unlikely(flags & METH_O)) {
8575 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (10 given)",
8576 ((PyCFunctionObject *)called)->m_ml->ml_name);
8578 }
else if (flags & METH_VARARGS) {
8581#ifdef _NUITKA_FULL_COMPAT
8582 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8586 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8587 PyObject *self = PyCFunction_GET_SELF(called);
8591#if PYTHON_VERSION < 0x360
8592 if (flags & METH_KEYWORDS) {
8593 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8595 result = (*method)(self, pos_args);
8599 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
8600 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8601 }
else if (flags == METH_FASTCALL) {
8602#if PYTHON_VERSION < 0x370
8603 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 10, NULL);
8605 result = (*(_PyCFunctionFast)method)(self, &pos_args, 10);
8608 result = (*method)(self, pos_args);
8612#ifdef _NUITKA_FULL_COMPAT
8613 Py_LeaveRecursiveCall();
8616 CHECK_OBJECT_X(result);
8618 return Nuitka_CheckFunctionResult(tstate, called, result);
8622#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
8623 }
else if (PyFunction_Check(called)) {
8624#if PYTHON_VERSION < 0x3b0
8625 PyObject *result = callPythonFunction(called, args, 10);
8627 PyObject *result = _PyFunction_Vectorcall(called, args, 10, NULL);
8629 CHECK_OBJECT_X(result);
8633#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
8634 }
else if (PyType_Check(called)) {
8635 PyTypeObject *type = Py_TYPE(called);
8637 if (type->tp_call == PyType_Type.tp_call) {
8638 PyTypeObject *called_type = (PyTypeObject *)(called);
8640 if (unlikely(called_type->tp_new == NULL)) {
8641 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
8647 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
8648 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
8649 formatCannotInstantiateAbstractClass(tstate, called_type);
8653 obj = called_type->tp_alloc(called_type, 0);
8656 obj = called_type->tp_new(called_type, pos_args, NULL);
8659 if (likely(obj != NULL)) {
8660 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
8665 type = Py_TYPE(obj);
8667 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
8668 if (type->tp_init == default_tp_init_wrapper) {
8670 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
8673 assert(init_method != NULL);
8675 bool is_compiled_function =
false;
8676 bool init_method_needs_release =
false;
8678 if (likely(init_method != NULL)) {
8679 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
8681 if (func == Nuitka_Function_Type.tp_descr_get) {
8682 is_compiled_function =
true;
8683 }
else if (func != NULL) {
8684 init_method = func(init_method, obj, (PyObject *)(type));
8685 init_method_needs_release =
true;
8689 if (unlikely(init_method == NULL)) {
8690 if (!HAS_ERROR_OCCURRED(tstate)) {
8691 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
8692 const_str_plain___init__);
8699 if (is_compiled_function) {
8700 result = Nuitka_CallMethodFunctionPosArgs(
8703 result = CALL_FUNCTION_WITH_POS_ARGS10(tstate, init_method, pos_args);
8704 if (init_method_needs_release) {
8705 Py_DECREF(init_method);
8709 if (unlikely(result == NULL)) {
8716 if (unlikely(result != Py_None)) {
8719 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
8724 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
8732 CHECK_OBJECT_X(obj);
8737#if PYTHON_VERSION < 0x300
8738 }
else if (PyClass_Check(called)) {
8739 PyObject *obj = PyInstance_NewRaw(called, NULL);
8741 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
8743 if (unlikely(init_method == NULL)) {
8744 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
8751 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
8755 bool is_compiled_function =
false;
8757 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
8759 if (descr_get == NULL) {
8760 Py_INCREF(init_method);
8761 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
8762 is_compiled_function =
true;
8763 }
else if (descr_get != NULL) {
8764 PyObject *descr_method = descr_get(init_method, obj, called);
8766 if (unlikely(descr_method == NULL)) {
8770 init_method = descr_method;
8774 if (is_compiled_function) {
8775 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
8778 result = CALL_FUNCTION_WITH_POS_ARGS10(tstate, init_method, pos_args);
8779 Py_DECREF(init_method);
8781 if (unlikely(result == NULL)) {
8787 if (unlikely(result != Py_None)) {
8788 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
8792 CHECK_OBJECT_X(obj);
8796#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8797 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8798 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8800 if (likely(func != NULL)) {
8801 PyObject *result = func(called, args, 10, NULL);
8803 CHECK_OBJECT_X(result);
8805 return Nuitka_CheckFunctionResult(tstate, called, result);
8812 PRINT_STRING(
"FALLBACK");
8817 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
8819 CHECK_OBJECT_X(result);
8823PyObject *CALL_FUNCTION_WITH_NO_ARGS_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *kw_values,
8824 PyObject *kw_names) {
8826 CHECK_OBJECT(kw_names);
8827 assert(PyTuple_CheckExact(kw_names));
8828 CHECK_OBJECT(called);
8830 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
8832 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
8834 if (Nuitka_Function_Check(called)) {
8835 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8841 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, NULL, 0, kw_values, kw_names);
8843 Py_LeaveRecursiveCall();
8845 CHECK_OBJECT_X(result);
8848#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8849 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8850 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8852 if (likely(func != NULL)) {
8853 PyObject *result = func(called, kw_values, 0, kw_names);
8855 CHECK_OBJECT_X(result);
8857 return Nuitka_CheckFunctionResult(tstate, called, result);
8863 PRINT_STRING(
"FALLBACK");
8868 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
8870 if (unlikely(call_slot == NULL)) {
8871 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
8876 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8880 PyObject *pos_args = const_tuple_empty;
8882 PyObject *named_args = _PyDict_NewPresized(nkwargs);
8884 for (Py_ssize_t i = 0; i < nkwargs; i++) {
8885 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
8887 PyObject *value = kw_values[i];
8890 CHECK_OBJECT(value);
8892 DICT_SET_ITEM(named_args, key, value);
8895 PyObject *result = (*call_slot)(called, pos_args, named_args);
8897 Py_DECREF(named_args);
8899 Py_LeaveRecursiveCall();
8901 CHECK_OBJECT_X(result);
8903 return Nuitka_CheckFunctionResult(tstate, called, result);
8905PyObject *CALL_FUNCTION_WITH_ARGS1_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
8906 PyObject *kw_names) {
8907 CHECK_OBJECTS(args, 1);
8908 CHECK_OBJECT(kw_names);
8909 assert(PyTuple_CheckExact(kw_names));
8910 CHECK_OBJECT(called);
8912 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
8914 CHECK_OBJECTS(&args[1], nkwargs);
8916 if (Nuitka_Function_Check(called)) {
8917 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8924 Nuitka_CallFunctionVectorcall(tstate, function, args, 1, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
8926 Py_LeaveRecursiveCall();
8928 CHECK_OBJECT_X(result);
8931#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8932 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8933 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8935 if (likely(func != NULL)) {
8936 PyObject *result = func(called, args, 1, kw_names);
8938 CHECK_OBJECT_X(result);
8940 return Nuitka_CheckFunctionResult(tstate, called, result);
8946 PRINT_STRING(
"FALLBACK");
8951 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
8953 if (unlikely(call_slot == NULL)) {
8954 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
8959 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8963 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
8965 PyObject *named_args = _PyDict_NewPresized(nkwargs);
8967 for (Py_ssize_t i = 0; i < nkwargs; i++) {
8968 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
8970 PyObject *value = args[1 + i];
8973 CHECK_OBJECT(value);
8975 DICT_SET_ITEM(named_args, key, value);
8978 PyObject *result = (*call_slot)(called, pos_args, named_args);
8980 Py_DECREF(pos_args);
8981 Py_DECREF(named_args);
8983 Py_LeaveRecursiveCall();
8985 CHECK_OBJECT_X(result);
8987 return Nuitka_CheckFunctionResult(tstate, called, result);
8989PyObject *CALL_FUNCTION_WITH_ARGS1_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
8990 PyObject *
const *kw_values, PyObject *kw_names) {
8991 CHECK_OBJECTS(args, 1);
8992 CHECK_OBJECT(kw_names);
8993 assert(PyTuple_CheckExact(kw_names));
8994 CHECK_OBJECT(called);
8996 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
8998 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9000 if (Nuitka_Function_Check(called)) {
9001 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9007 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 1, kw_values, kw_names);
9009 Py_LeaveRecursiveCall();
9011 CHECK_OBJECT_X(result);
9014#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9015 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9016 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9018 if (likely(func != NULL)) {
9019 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 1 + nkwargs);
9021 memcpy(vectorcall_args, args, 1 *
sizeof(PyObject *));
9022 memcpy(&vectorcall_args[1], kw_values, nkwargs *
sizeof(PyObject *));
9024 PyObject *result = func(called, vectorcall_args, 1, kw_names);
9026 CHECK_OBJECT_X(result);
9028 return Nuitka_CheckFunctionResult(tstate, called, result);
9034 PRINT_STRING(
"FALLBACK");
9039 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9041 if (unlikely(call_slot == NULL)) {
9042 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9047 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9051 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
9053 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9055 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9056 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9058 PyObject *value = kw_values[i];
9061 CHECK_OBJECT(value);
9063 DICT_SET_ITEM(named_args, key, value);
9066 PyObject *result = (*call_slot)(called, pos_args, named_args);
9068 Py_DECREF(pos_args);
9069 Py_DECREF(named_args);
9071 Py_LeaveRecursiveCall();
9073 CHECK_OBJECT_X(result);
9075 return Nuitka_CheckFunctionResult(tstate, called, result);
9077PyObject *CALL_FUNCTION_WITH_POS_ARGS1_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9078 PyObject *
const *kw_values, PyObject *kw_names) {
9079 assert(PyTuple_CheckExact(pos_args));
9080 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
9081 CHECK_OBJECTS(args, 1);
9082 CHECK_OBJECT(kw_names);
9083 assert(PyTuple_CheckExact(kw_names));
9084 CHECK_OBJECT(called);
9086 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9088 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9090 if (Nuitka_Function_Check(called)) {
9091 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9097 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 1, kw_values, kw_names);
9099 Py_LeaveRecursiveCall();
9101 CHECK_OBJECT_X(result);
9104#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9105 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9106 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9108 if (likely(func != NULL)) {
9109 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 1 + nkwargs);
9111 memcpy(vectorcall_args, args, 1 *
sizeof(PyObject *));
9112 memcpy(&vectorcall_args[1], kw_values, nkwargs *
sizeof(PyObject *));
9114 PyObject *result = func(called, vectorcall_args, 1, kw_names);
9116 CHECK_OBJECT_X(result);
9118 return Nuitka_CheckFunctionResult(tstate, called, result);
9124 PRINT_STRING(
"FALLBACK");
9129 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9131 if (unlikely(call_slot == NULL)) {
9132 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9137 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9141 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9143 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9144 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9146 PyObject *value = kw_values[i];
9149 CHECK_OBJECT(value);
9151 DICT_SET_ITEM(named_args, key, value);
9154 PyObject *result = (*call_slot)(called, pos_args, named_args);
9156 Py_DECREF(named_args);
9158 Py_LeaveRecursiveCall();
9160 CHECK_OBJECT_X(result);
9162 return Nuitka_CheckFunctionResult(tstate, called, result);
9164PyObject *CALL_FUNCTION_WITH_ARGS2_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9165 PyObject *kw_names) {
9166 CHECK_OBJECTS(args, 2);
9167 CHECK_OBJECT(kw_names);
9168 assert(PyTuple_CheckExact(kw_names));
9169 CHECK_OBJECT(called);
9171 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9173 CHECK_OBJECTS(&args[2], nkwargs);
9175 if (Nuitka_Function_Check(called)) {
9176 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9183 Nuitka_CallFunctionVectorcall(tstate, function, args, 2, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
9185 Py_LeaveRecursiveCall();
9187 CHECK_OBJECT_X(result);
9190#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9191 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9192 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9194 if (likely(func != NULL)) {
9195 PyObject *result = func(called, args, 2, kw_names);
9197 CHECK_OBJECT_X(result);
9199 return Nuitka_CheckFunctionResult(tstate, called, result);
9205 PRINT_STRING(
"FALLBACK");
9210 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9212 if (unlikely(call_slot == NULL)) {
9213 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9218 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9222 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
9224 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9226 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9227 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9229 PyObject *value = args[2 + i];
9232 CHECK_OBJECT(value);
9234 DICT_SET_ITEM(named_args, key, value);
9237 PyObject *result = (*call_slot)(called, pos_args, named_args);
9239 Py_DECREF(pos_args);
9240 Py_DECREF(named_args);
9242 Py_LeaveRecursiveCall();
9244 CHECK_OBJECT_X(result);
9246 return Nuitka_CheckFunctionResult(tstate, called, result);
9248PyObject *CALL_FUNCTION_WITH_ARGS2_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9249 PyObject *
const *kw_values, PyObject *kw_names) {
9250 CHECK_OBJECTS(args, 2);
9251 CHECK_OBJECT(kw_names);
9252 assert(PyTuple_CheckExact(kw_names));
9253 CHECK_OBJECT(called);
9255 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9257 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9259 if (Nuitka_Function_Check(called)) {
9260 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9266 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 2, kw_values, kw_names);
9268 Py_LeaveRecursiveCall();
9270 CHECK_OBJECT_X(result);
9273#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9274 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9275 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9277 if (likely(func != NULL)) {
9278 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 2 + nkwargs);
9280 memcpy(vectorcall_args, args, 2 *
sizeof(PyObject *));
9281 memcpy(&vectorcall_args[2], kw_values, nkwargs *
sizeof(PyObject *));
9283 PyObject *result = func(called, vectorcall_args, 2, kw_names);
9285 CHECK_OBJECT_X(result);
9287 return Nuitka_CheckFunctionResult(tstate, called, result);
9293 PRINT_STRING(
"FALLBACK");
9298 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9300 if (unlikely(call_slot == NULL)) {
9301 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9306 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9310 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
9312 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9314 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9315 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9317 PyObject *value = kw_values[i];
9320 CHECK_OBJECT(value);
9322 DICT_SET_ITEM(named_args, key, value);
9325 PyObject *result = (*call_slot)(called, pos_args, named_args);
9327 Py_DECREF(pos_args);
9328 Py_DECREF(named_args);
9330 Py_LeaveRecursiveCall();
9332 CHECK_OBJECT_X(result);
9334 return Nuitka_CheckFunctionResult(tstate, called, result);
9336PyObject *CALL_FUNCTION_WITH_POS_ARGS2_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9337 PyObject *
const *kw_values, PyObject *kw_names) {
9338 assert(PyTuple_CheckExact(pos_args));
9339 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
9340 CHECK_OBJECTS(args, 2);
9341 CHECK_OBJECT(kw_names);
9342 assert(PyTuple_CheckExact(kw_names));
9343 CHECK_OBJECT(called);
9345 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9347 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9349 if (Nuitka_Function_Check(called)) {
9350 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9356 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 2, kw_values, kw_names);
9358 Py_LeaveRecursiveCall();
9360 CHECK_OBJECT_X(result);
9363#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9364 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9365 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9367 if (likely(func != NULL)) {
9368 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 2 + nkwargs);
9370 memcpy(vectorcall_args, args, 2 *
sizeof(PyObject *));
9371 memcpy(&vectorcall_args[2], kw_values, nkwargs *
sizeof(PyObject *));
9373 PyObject *result = func(called, vectorcall_args, 2, kw_names);
9375 CHECK_OBJECT_X(result);
9377 return Nuitka_CheckFunctionResult(tstate, called, result);
9383 PRINT_STRING(
"FALLBACK");
9388 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9390 if (unlikely(call_slot == NULL)) {
9391 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9396 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9400 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9402 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9403 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9405 PyObject *value = kw_values[i];
9408 CHECK_OBJECT(value);
9410 DICT_SET_ITEM(named_args, key, value);
9413 PyObject *result = (*call_slot)(called, pos_args, named_args);
9415 Py_DECREF(named_args);
9417 Py_LeaveRecursiveCall();
9419 CHECK_OBJECT_X(result);
9421 return Nuitka_CheckFunctionResult(tstate, called, result);
9423PyObject *CALL_FUNCTION_WITH_ARGS3_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9424 PyObject *kw_names) {
9425 CHECK_OBJECTS(args, 3);
9426 CHECK_OBJECT(kw_names);
9427 assert(PyTuple_CheckExact(kw_names));
9428 CHECK_OBJECT(called);
9430 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9432 CHECK_OBJECTS(&args[3], nkwargs);
9434 if (Nuitka_Function_Check(called)) {
9435 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9442 Nuitka_CallFunctionVectorcall(tstate, function, args, 3, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
9444 Py_LeaveRecursiveCall();
9446 CHECK_OBJECT_X(result);
9449#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9450 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9451 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9453 if (likely(func != NULL)) {
9454 PyObject *result = func(called, args, 3, kw_names);
9456 CHECK_OBJECT_X(result);
9458 return Nuitka_CheckFunctionResult(tstate, called, result);
9464 PRINT_STRING(
"FALLBACK");
9469 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9471 if (unlikely(call_slot == NULL)) {
9472 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9477 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9481 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
9483 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9485 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9486 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9488 PyObject *value = args[3 + i];
9491 CHECK_OBJECT(value);
9493 DICT_SET_ITEM(named_args, key, value);
9496 PyObject *result = (*call_slot)(called, pos_args, named_args);
9498 Py_DECREF(pos_args);
9499 Py_DECREF(named_args);
9501 Py_LeaveRecursiveCall();
9503 CHECK_OBJECT_X(result);
9505 return Nuitka_CheckFunctionResult(tstate, called, result);
9507PyObject *CALL_FUNCTION_WITH_ARGS3_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9508 PyObject *
const *kw_values, PyObject *kw_names) {
9509 CHECK_OBJECTS(args, 3);
9510 CHECK_OBJECT(kw_names);
9511 assert(PyTuple_CheckExact(kw_names));
9512 CHECK_OBJECT(called);
9514 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9516 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9518 if (Nuitka_Function_Check(called)) {
9519 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9525 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 3, kw_values, kw_names);
9527 Py_LeaveRecursiveCall();
9529 CHECK_OBJECT_X(result);
9532#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9533 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9534 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9536 if (likely(func != NULL)) {
9537 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 3 + nkwargs);
9539 memcpy(vectorcall_args, args, 3 *
sizeof(PyObject *));
9540 memcpy(&vectorcall_args[3], kw_values, nkwargs *
sizeof(PyObject *));
9542 PyObject *result = func(called, vectorcall_args, 3, kw_names);
9544 CHECK_OBJECT_X(result);
9546 return Nuitka_CheckFunctionResult(tstate, called, result);
9552 PRINT_STRING(
"FALLBACK");
9557 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9559 if (unlikely(call_slot == NULL)) {
9560 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9565 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9569 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
9571 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9573 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9574 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9576 PyObject *value = kw_values[i];
9579 CHECK_OBJECT(value);
9581 DICT_SET_ITEM(named_args, key, value);
9584 PyObject *result = (*call_slot)(called, pos_args, named_args);
9586 Py_DECREF(pos_args);
9587 Py_DECREF(named_args);
9589 Py_LeaveRecursiveCall();
9591 CHECK_OBJECT_X(result);
9593 return Nuitka_CheckFunctionResult(tstate, called, result);
9595PyObject *CALL_FUNCTION_WITH_POS_ARGS3_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9596 PyObject *
const *kw_values, PyObject *kw_names) {
9597 assert(PyTuple_CheckExact(pos_args));
9598 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
9599 CHECK_OBJECTS(args, 3);
9600 CHECK_OBJECT(kw_names);
9601 assert(PyTuple_CheckExact(kw_names));
9602 CHECK_OBJECT(called);
9604 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9606 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9608 if (Nuitka_Function_Check(called)) {
9609 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9615 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 3, kw_values, kw_names);
9617 Py_LeaveRecursiveCall();
9619 CHECK_OBJECT_X(result);
9622#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9623 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9624 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9626 if (likely(func != NULL)) {
9627 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 3 + nkwargs);
9629 memcpy(vectorcall_args, args, 3 *
sizeof(PyObject *));
9630 memcpy(&vectorcall_args[3], kw_values, nkwargs *
sizeof(PyObject *));
9632 PyObject *result = func(called, vectorcall_args, 3, kw_names);
9634 CHECK_OBJECT_X(result);
9636 return Nuitka_CheckFunctionResult(tstate, called, result);
9642 PRINT_STRING(
"FALLBACK");
9647 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9649 if (unlikely(call_slot == NULL)) {
9650 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9655 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9659 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9661 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9662 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9664 PyObject *value = kw_values[i];
9667 CHECK_OBJECT(value);
9669 DICT_SET_ITEM(named_args, key, value);
9672 PyObject *result = (*call_slot)(called, pos_args, named_args);
9674 Py_DECREF(named_args);
9676 Py_LeaveRecursiveCall();
9678 CHECK_OBJECT_X(result);
9680 return Nuitka_CheckFunctionResult(tstate, called, result);
9682PyObject *CALL_FUNCTION_WITH_ARGS4_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9683 PyObject *kw_names) {
9684 CHECK_OBJECTS(args, 4);
9685 CHECK_OBJECT(kw_names);
9686 assert(PyTuple_CheckExact(kw_names));
9687 CHECK_OBJECT(called);
9689 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9691 CHECK_OBJECTS(&args[4], nkwargs);
9693 if (Nuitka_Function_Check(called)) {
9694 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9701 Nuitka_CallFunctionVectorcall(tstate, function, args, 4, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
9703 Py_LeaveRecursiveCall();
9705 CHECK_OBJECT_X(result);
9708#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9709 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9710 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9712 if (likely(func != NULL)) {
9713 PyObject *result = func(called, args, 4, kw_names);
9715 CHECK_OBJECT_X(result);
9717 return Nuitka_CheckFunctionResult(tstate, called, result);
9723 PRINT_STRING(
"FALLBACK");
9728 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9730 if (unlikely(call_slot == NULL)) {
9731 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9736 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9740 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
9742 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9744 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9745 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9747 PyObject *value = args[4 + i];
9750 CHECK_OBJECT(value);
9752 DICT_SET_ITEM(named_args, key, value);
9755 PyObject *result = (*call_slot)(called, pos_args, named_args);
9757 Py_DECREF(pos_args);
9758 Py_DECREF(named_args);
9760 Py_LeaveRecursiveCall();
9762 CHECK_OBJECT_X(result);
9764 return Nuitka_CheckFunctionResult(tstate, called, result);
9766PyObject *CALL_FUNCTION_WITH_ARGS4_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9767 PyObject *
const *kw_values, PyObject *kw_names) {
9768 CHECK_OBJECTS(args, 4);
9769 CHECK_OBJECT(kw_names);
9770 assert(PyTuple_CheckExact(kw_names));
9771 CHECK_OBJECT(called);
9773 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9775 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9777 if (Nuitka_Function_Check(called)) {
9778 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9784 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 4, kw_values, kw_names);
9786 Py_LeaveRecursiveCall();
9788 CHECK_OBJECT_X(result);
9791#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9792 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9793 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9795 if (likely(func != NULL)) {
9796 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 4 + nkwargs);
9798 memcpy(vectorcall_args, args, 4 *
sizeof(PyObject *));
9799 memcpy(&vectorcall_args[4], kw_values, nkwargs *
sizeof(PyObject *));
9801 PyObject *result = func(called, vectorcall_args, 4, kw_names);
9803 CHECK_OBJECT_X(result);
9805 return Nuitka_CheckFunctionResult(tstate, called, result);
9811 PRINT_STRING(
"FALLBACK");
9816 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9818 if (unlikely(call_slot == NULL)) {
9819 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9824 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9828 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
9830 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9832 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9833 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9835 PyObject *value = kw_values[i];
9838 CHECK_OBJECT(value);
9840 DICT_SET_ITEM(named_args, key, value);
9843 PyObject *result = (*call_slot)(called, pos_args, named_args);
9845 Py_DECREF(pos_args);
9846 Py_DECREF(named_args);
9848 Py_LeaveRecursiveCall();
9850 CHECK_OBJECT_X(result);
9852 return Nuitka_CheckFunctionResult(tstate, called, result);
9854PyObject *CALL_FUNCTION_WITH_POS_ARGS4_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9855 PyObject *
const *kw_values, PyObject *kw_names) {
9856 assert(PyTuple_CheckExact(pos_args));
9857 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
9858 CHECK_OBJECTS(args, 4);
9859 CHECK_OBJECT(kw_names);
9860 assert(PyTuple_CheckExact(kw_names));
9861 CHECK_OBJECT(called);
9863 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9865 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9867 if (Nuitka_Function_Check(called)) {
9868 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9874 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 4, kw_values, kw_names);
9876 Py_LeaveRecursiveCall();
9878 CHECK_OBJECT_X(result);
9881#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9882 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9883 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9885 if (likely(func != NULL)) {
9886 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 4 + nkwargs);
9888 memcpy(vectorcall_args, args, 4 *
sizeof(PyObject *));
9889 memcpy(&vectorcall_args[4], kw_values, nkwargs *
sizeof(PyObject *));
9891 PyObject *result = func(called, vectorcall_args, 4, kw_names);
9893 CHECK_OBJECT_X(result);
9895 return Nuitka_CheckFunctionResult(tstate, called, result);
9901 PRINT_STRING(
"FALLBACK");
9906 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9908 if (unlikely(call_slot == NULL)) {
9909 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9914 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9918 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9920 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9921 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9923 PyObject *value = kw_values[i];
9926 CHECK_OBJECT(value);
9928 DICT_SET_ITEM(named_args, key, value);
9931 PyObject *result = (*call_slot)(called, pos_args, named_args);
9933 Py_DECREF(named_args);
9935 Py_LeaveRecursiveCall();
9937 CHECK_OBJECT_X(result);
9939 return Nuitka_CheckFunctionResult(tstate, called, result);
9941PyObject *CALL_FUNCTION_WITH_ARGS5_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9942 PyObject *kw_names) {
9943 CHECK_OBJECTS(args, 5);
9944 CHECK_OBJECT(kw_names);
9945 assert(PyTuple_CheckExact(kw_names));
9946 CHECK_OBJECT(called);
9948 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9950 CHECK_OBJECTS(&args[5], nkwargs);
9952 if (Nuitka_Function_Check(called)) {
9953 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9960 Nuitka_CallFunctionVectorcall(tstate, function, args, 5, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
9962 Py_LeaveRecursiveCall();
9964 CHECK_OBJECT_X(result);
9967#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9968 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9969 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9971 if (likely(func != NULL)) {
9972 PyObject *result = func(called, args, 5, kw_names);
9974 CHECK_OBJECT_X(result);
9976 return Nuitka_CheckFunctionResult(tstate, called, result);
9982 PRINT_STRING(
"FALLBACK");
9987 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9989 if (unlikely(call_slot == NULL)) {
9990 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9995 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9999 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
10001 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10003 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10004 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10006 PyObject *value = args[5 + i];
10009 CHECK_OBJECT(value);
10011 DICT_SET_ITEM(named_args, key, value);
10014 PyObject *result = (*call_slot)(called, pos_args, named_args);
10016 Py_DECREF(pos_args);
10017 Py_DECREF(named_args);
10019 Py_LeaveRecursiveCall();
10021 CHECK_OBJECT_X(result);
10023 return Nuitka_CheckFunctionResult(tstate, called, result);
10025PyObject *CALL_FUNCTION_WITH_ARGS5_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10026 PyObject *
const *kw_values, PyObject *kw_names) {
10027 CHECK_OBJECTS(args, 5);
10028 CHECK_OBJECT(kw_names);
10029 assert(PyTuple_CheckExact(kw_names));
10030 CHECK_OBJECT(called);
10032 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10034 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10036 if (Nuitka_Function_Check(called)) {
10037 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10043 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 5, kw_values, kw_names);
10045 Py_LeaveRecursiveCall();
10047 CHECK_OBJECT_X(result);
10050#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10051 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10052 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10054 if (likely(func != NULL)) {
10055 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 5 + nkwargs);
10057 memcpy(vectorcall_args, args, 5 *
sizeof(PyObject *));
10058 memcpy(&vectorcall_args[5], kw_values, nkwargs *
sizeof(PyObject *));
10060 PyObject *result = func(called, vectorcall_args, 5, kw_names);
10062 CHECK_OBJECT_X(result);
10064 return Nuitka_CheckFunctionResult(tstate, called, result);
10070 PRINT_STRING(
"FALLBACK");
10071 PRINT_ITEM(called);
10075 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10077 if (unlikely(call_slot == NULL)) {
10078 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10083 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10087 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
10089 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10091 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10092 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10094 PyObject *value = kw_values[i];
10097 CHECK_OBJECT(value);
10099 DICT_SET_ITEM(named_args, key, value);
10102 PyObject *result = (*call_slot)(called, pos_args, named_args);
10104 Py_DECREF(pos_args);
10105 Py_DECREF(named_args);
10107 Py_LeaveRecursiveCall();
10109 CHECK_OBJECT_X(result);
10111 return Nuitka_CheckFunctionResult(tstate, called, result);
10113PyObject *CALL_FUNCTION_WITH_POS_ARGS5_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10114 PyObject *
const *kw_values, PyObject *kw_names) {
10115 assert(PyTuple_CheckExact(pos_args));
10116 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
10117 CHECK_OBJECTS(args, 5);
10118 CHECK_OBJECT(kw_names);
10119 assert(PyTuple_CheckExact(kw_names));
10120 CHECK_OBJECT(called);
10122 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10124 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10126 if (Nuitka_Function_Check(called)) {
10127 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10133 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 5, kw_values, kw_names);
10135 Py_LeaveRecursiveCall();
10137 CHECK_OBJECT_X(result);
10140#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10141 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10142 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10144 if (likely(func != NULL)) {
10145 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 5 + nkwargs);
10147 memcpy(vectorcall_args, args, 5 *
sizeof(PyObject *));
10148 memcpy(&vectorcall_args[5], kw_values, nkwargs *
sizeof(PyObject *));
10150 PyObject *result = func(called, vectorcall_args, 5, kw_names);
10152 CHECK_OBJECT_X(result);
10154 return Nuitka_CheckFunctionResult(tstate, called, result);
10160 PRINT_STRING(
"FALLBACK");
10161 PRINT_ITEM(called);
10165 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10167 if (unlikely(call_slot == NULL)) {
10168 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10173 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10177 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10179 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10180 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10182 PyObject *value = kw_values[i];
10185 CHECK_OBJECT(value);
10187 DICT_SET_ITEM(named_args, key, value);
10190 PyObject *result = (*call_slot)(called, pos_args, named_args);
10192 Py_DECREF(named_args);
10194 Py_LeaveRecursiveCall();
10196 CHECK_OBJECT_X(result);
10198 return Nuitka_CheckFunctionResult(tstate, called, result);
10200PyObject *CALL_FUNCTION_WITH_ARGS6_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10201 PyObject *kw_names) {
10202 CHECK_OBJECTS(args, 6);
10203 CHECK_OBJECT(kw_names);
10204 assert(PyTuple_CheckExact(kw_names));
10205 CHECK_OBJECT(called);
10207 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10209 CHECK_OBJECTS(&args[6], nkwargs);
10211 if (Nuitka_Function_Check(called)) {
10212 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10219 Nuitka_CallFunctionVectorcall(tstate, function, args, 6, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
10221 Py_LeaveRecursiveCall();
10223 CHECK_OBJECT_X(result);
10226#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10227 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10228 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10230 if (likely(func != NULL)) {
10231 PyObject *result = func(called, args, 6, kw_names);
10233 CHECK_OBJECT_X(result);
10235 return Nuitka_CheckFunctionResult(tstate, called, result);
10241 PRINT_STRING(
"FALLBACK");
10242 PRINT_ITEM(called);
10246 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10248 if (unlikely(call_slot == NULL)) {
10249 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10254 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10258 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
10260 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10262 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10263 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10265 PyObject *value = args[6 + i];
10268 CHECK_OBJECT(value);
10270 DICT_SET_ITEM(named_args, key, value);
10273 PyObject *result = (*call_slot)(called, pos_args, named_args);
10275 Py_DECREF(pos_args);
10276 Py_DECREF(named_args);
10278 Py_LeaveRecursiveCall();
10280 CHECK_OBJECT_X(result);
10282 return Nuitka_CheckFunctionResult(tstate, called, result);
10284PyObject *CALL_FUNCTION_WITH_ARGS6_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10285 PyObject *
const *kw_values, PyObject *kw_names) {
10286 CHECK_OBJECTS(args, 6);
10287 CHECK_OBJECT(kw_names);
10288 assert(PyTuple_CheckExact(kw_names));
10289 CHECK_OBJECT(called);
10291 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10293 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10295 if (Nuitka_Function_Check(called)) {
10296 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10302 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 6, kw_values, kw_names);
10304 Py_LeaveRecursiveCall();
10306 CHECK_OBJECT_X(result);
10309#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10310 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10311 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10313 if (likely(func != NULL)) {
10314 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 6 + nkwargs);
10316 memcpy(vectorcall_args, args, 6 *
sizeof(PyObject *));
10317 memcpy(&vectorcall_args[6], kw_values, nkwargs *
sizeof(PyObject *));
10319 PyObject *result = func(called, vectorcall_args, 6, kw_names);
10321 CHECK_OBJECT_X(result);
10323 return Nuitka_CheckFunctionResult(tstate, called, result);
10329 PRINT_STRING(
"FALLBACK");
10330 PRINT_ITEM(called);
10334 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10336 if (unlikely(call_slot == NULL)) {
10337 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10342 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10346 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
10348 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10350 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10351 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10353 PyObject *value = kw_values[i];
10356 CHECK_OBJECT(value);
10358 DICT_SET_ITEM(named_args, key, value);
10361 PyObject *result = (*call_slot)(called, pos_args, named_args);
10363 Py_DECREF(pos_args);
10364 Py_DECREF(named_args);
10366 Py_LeaveRecursiveCall();
10368 CHECK_OBJECT_X(result);
10370 return Nuitka_CheckFunctionResult(tstate, called, result);
10372PyObject *CALL_FUNCTION_WITH_POS_ARGS6_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10373 PyObject *
const *kw_values, PyObject *kw_names) {
10374 assert(PyTuple_CheckExact(pos_args));
10375 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
10376 CHECK_OBJECTS(args, 6);
10377 CHECK_OBJECT(kw_names);
10378 assert(PyTuple_CheckExact(kw_names));
10379 CHECK_OBJECT(called);
10381 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10383 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10385 if (Nuitka_Function_Check(called)) {
10386 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10392 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 6, kw_values, kw_names);
10394 Py_LeaveRecursiveCall();
10396 CHECK_OBJECT_X(result);
10399#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10400 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10401 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10403 if (likely(func != NULL)) {
10404 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 6 + nkwargs);
10406 memcpy(vectorcall_args, args, 6 *
sizeof(PyObject *));
10407 memcpy(&vectorcall_args[6], kw_values, nkwargs *
sizeof(PyObject *));
10409 PyObject *result = func(called, vectorcall_args, 6, kw_names);
10411 CHECK_OBJECT_X(result);
10413 return Nuitka_CheckFunctionResult(tstate, called, result);
10419 PRINT_STRING(
"FALLBACK");
10420 PRINT_ITEM(called);
10424 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10426 if (unlikely(call_slot == NULL)) {
10427 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10432 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10436 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10438 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10439 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10441 PyObject *value = kw_values[i];
10444 CHECK_OBJECT(value);
10446 DICT_SET_ITEM(named_args, key, value);
10449 PyObject *result = (*call_slot)(called, pos_args, named_args);
10451 Py_DECREF(named_args);
10453 Py_LeaveRecursiveCall();
10455 CHECK_OBJECT_X(result);
10457 return Nuitka_CheckFunctionResult(tstate, called, result);
10459PyObject *CALL_FUNCTION_WITH_ARGS7_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10460 PyObject *kw_names) {
10461 CHECK_OBJECTS(args, 7);
10462 CHECK_OBJECT(kw_names);
10463 assert(PyTuple_CheckExact(kw_names));
10464 CHECK_OBJECT(called);
10466 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10468 CHECK_OBJECTS(&args[7], nkwargs);
10470 if (Nuitka_Function_Check(called)) {
10471 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10478 Nuitka_CallFunctionVectorcall(tstate, function, args, 7, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
10480 Py_LeaveRecursiveCall();
10482 CHECK_OBJECT_X(result);
10485#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10486 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10487 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10489 if (likely(func != NULL)) {
10490 PyObject *result = func(called, args, 7, kw_names);
10492 CHECK_OBJECT_X(result);
10494 return Nuitka_CheckFunctionResult(tstate, called, result);
10500 PRINT_STRING(
"FALLBACK");
10501 PRINT_ITEM(called);
10505 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10507 if (unlikely(call_slot == NULL)) {
10508 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10513 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10517 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
10519 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10521 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10522 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10524 PyObject *value = args[7 + i];
10527 CHECK_OBJECT(value);
10529 DICT_SET_ITEM(named_args, key, value);
10532 PyObject *result = (*call_slot)(called, pos_args, named_args);
10534 Py_DECREF(pos_args);
10535 Py_DECREF(named_args);
10537 Py_LeaveRecursiveCall();
10539 CHECK_OBJECT_X(result);
10541 return Nuitka_CheckFunctionResult(tstate, called, result);
10543PyObject *CALL_FUNCTION_WITH_ARGS7_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10544 PyObject *
const *kw_values, PyObject *kw_names) {
10545 CHECK_OBJECTS(args, 7);
10546 CHECK_OBJECT(kw_names);
10547 assert(PyTuple_CheckExact(kw_names));
10548 CHECK_OBJECT(called);
10550 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10552 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10554 if (Nuitka_Function_Check(called)) {
10555 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10561 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 7, kw_values, kw_names);
10563 Py_LeaveRecursiveCall();
10565 CHECK_OBJECT_X(result);
10568#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10569 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10570 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10572 if (likely(func != NULL)) {
10573 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 7 + nkwargs);
10575 memcpy(vectorcall_args, args, 7 *
sizeof(PyObject *));
10576 memcpy(&vectorcall_args[7], kw_values, nkwargs *
sizeof(PyObject *));
10578 PyObject *result = func(called, vectorcall_args, 7, kw_names);
10580 CHECK_OBJECT_X(result);
10582 return Nuitka_CheckFunctionResult(tstate, called, result);
10588 PRINT_STRING(
"FALLBACK");
10589 PRINT_ITEM(called);
10593 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10595 if (unlikely(call_slot == NULL)) {
10596 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10601 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10605 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
10607 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10609 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10610 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10612 PyObject *value = kw_values[i];
10615 CHECK_OBJECT(value);
10617 DICT_SET_ITEM(named_args, key, value);
10620 PyObject *result = (*call_slot)(called, pos_args, named_args);
10622 Py_DECREF(pos_args);
10623 Py_DECREF(named_args);
10625 Py_LeaveRecursiveCall();
10627 CHECK_OBJECT_X(result);
10629 return Nuitka_CheckFunctionResult(tstate, called, result);
10631PyObject *CALL_FUNCTION_WITH_POS_ARGS7_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10632 PyObject *
const *kw_values, PyObject *kw_names) {
10633 assert(PyTuple_CheckExact(pos_args));
10634 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
10635 CHECK_OBJECTS(args, 7);
10636 CHECK_OBJECT(kw_names);
10637 assert(PyTuple_CheckExact(kw_names));
10638 CHECK_OBJECT(called);
10640 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10642 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10644 if (Nuitka_Function_Check(called)) {
10645 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10651 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 7, kw_values, kw_names);
10653 Py_LeaveRecursiveCall();
10655 CHECK_OBJECT_X(result);
10658#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10659 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10660 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10662 if (likely(func != NULL)) {
10663 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 7 + nkwargs);
10665 memcpy(vectorcall_args, args, 7 *
sizeof(PyObject *));
10666 memcpy(&vectorcall_args[7], kw_values, nkwargs *
sizeof(PyObject *));
10668 PyObject *result = func(called, vectorcall_args, 7, kw_names);
10670 CHECK_OBJECT_X(result);
10672 return Nuitka_CheckFunctionResult(tstate, called, result);
10678 PRINT_STRING(
"FALLBACK");
10679 PRINT_ITEM(called);
10683 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10685 if (unlikely(call_slot == NULL)) {
10686 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10691 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10695 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10697 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10698 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10700 PyObject *value = kw_values[i];
10703 CHECK_OBJECT(value);
10705 DICT_SET_ITEM(named_args, key, value);
10708 PyObject *result = (*call_slot)(called, pos_args, named_args);
10710 Py_DECREF(named_args);
10712 Py_LeaveRecursiveCall();
10714 CHECK_OBJECT_X(result);
10716 return Nuitka_CheckFunctionResult(tstate, called, result);
10718PyObject *CALL_FUNCTION_WITH_ARGS8_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10719 PyObject *kw_names) {
10720 CHECK_OBJECTS(args, 8);
10721 CHECK_OBJECT(kw_names);
10722 assert(PyTuple_CheckExact(kw_names));
10723 CHECK_OBJECT(called);
10725 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10727 CHECK_OBJECTS(&args[8], nkwargs);
10729 if (Nuitka_Function_Check(called)) {
10730 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10737 Nuitka_CallFunctionVectorcall(tstate, function, args, 8, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
10739 Py_LeaveRecursiveCall();
10741 CHECK_OBJECT_X(result);
10744#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10745 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10746 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10748 if (likely(func != NULL)) {
10749 PyObject *result = func(called, args, 8, kw_names);
10751 CHECK_OBJECT_X(result);
10753 return Nuitka_CheckFunctionResult(tstate, called, result);
10759 PRINT_STRING(
"FALLBACK");
10760 PRINT_ITEM(called);
10764 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10766 if (unlikely(call_slot == NULL)) {
10767 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10772 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10776 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
10778 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10780 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10781 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10783 PyObject *value = args[8 + i];
10786 CHECK_OBJECT(value);
10788 DICT_SET_ITEM(named_args, key, value);
10791 PyObject *result = (*call_slot)(called, pos_args, named_args);
10793 Py_DECREF(pos_args);
10794 Py_DECREF(named_args);
10796 Py_LeaveRecursiveCall();
10798 CHECK_OBJECT_X(result);
10800 return Nuitka_CheckFunctionResult(tstate, called, result);
10802PyObject *CALL_FUNCTION_WITH_ARGS8_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10803 PyObject *
const *kw_values, PyObject *kw_names) {
10804 CHECK_OBJECTS(args, 8);
10805 CHECK_OBJECT(kw_names);
10806 assert(PyTuple_CheckExact(kw_names));
10807 CHECK_OBJECT(called);
10809 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10811 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10813 if (Nuitka_Function_Check(called)) {
10814 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10820 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 8, kw_values, kw_names);
10822 Py_LeaveRecursiveCall();
10824 CHECK_OBJECT_X(result);
10827#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10828 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10829 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10831 if (likely(func != NULL)) {
10832 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 8 + nkwargs);
10834 memcpy(vectorcall_args, args, 8 *
sizeof(PyObject *));
10835 memcpy(&vectorcall_args[8], kw_values, nkwargs *
sizeof(PyObject *));
10837 PyObject *result = func(called, vectorcall_args, 8, kw_names);
10839 CHECK_OBJECT_X(result);
10841 return Nuitka_CheckFunctionResult(tstate, called, result);
10847 PRINT_STRING(
"FALLBACK");
10848 PRINT_ITEM(called);
10852 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10854 if (unlikely(call_slot == NULL)) {
10855 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10860 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10864 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
10866 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10868 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10869 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10871 PyObject *value = kw_values[i];
10874 CHECK_OBJECT(value);
10876 DICT_SET_ITEM(named_args, key, value);
10879 PyObject *result = (*call_slot)(called, pos_args, named_args);
10881 Py_DECREF(pos_args);
10882 Py_DECREF(named_args);
10884 Py_LeaveRecursiveCall();
10886 CHECK_OBJECT_X(result);
10888 return Nuitka_CheckFunctionResult(tstate, called, result);
10890PyObject *CALL_FUNCTION_WITH_POS_ARGS8_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10891 PyObject *
const *kw_values, PyObject *kw_names) {
10892 assert(PyTuple_CheckExact(pos_args));
10893 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
10894 CHECK_OBJECTS(args, 8);
10895 CHECK_OBJECT(kw_names);
10896 assert(PyTuple_CheckExact(kw_names));
10897 CHECK_OBJECT(called);
10899 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10901 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10903 if (Nuitka_Function_Check(called)) {
10904 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10910 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 8, kw_values, kw_names);
10912 Py_LeaveRecursiveCall();
10914 CHECK_OBJECT_X(result);
10917#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10918 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10919 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10921 if (likely(func != NULL)) {
10922 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 8 + nkwargs);
10924 memcpy(vectorcall_args, args, 8 *
sizeof(PyObject *));
10925 memcpy(&vectorcall_args[8], kw_values, nkwargs *
sizeof(PyObject *));
10927 PyObject *result = func(called, vectorcall_args, 8, kw_names);
10929 CHECK_OBJECT_X(result);
10931 return Nuitka_CheckFunctionResult(tstate, called, result);
10937 PRINT_STRING(
"FALLBACK");
10938 PRINT_ITEM(called);
10942 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10944 if (unlikely(call_slot == NULL)) {
10945 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10950 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10954 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10956 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10957 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10959 PyObject *value = kw_values[i];
10962 CHECK_OBJECT(value);
10964 DICT_SET_ITEM(named_args, key, value);
10967 PyObject *result = (*call_slot)(called, pos_args, named_args);
10969 Py_DECREF(named_args);
10971 Py_LeaveRecursiveCall();
10973 CHECK_OBJECT_X(result);
10975 return Nuitka_CheckFunctionResult(tstate, called, result);
10977PyObject *CALL_FUNCTION_WITH_ARGS9_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10978 PyObject *kw_names) {
10979 CHECK_OBJECTS(args, 9);
10980 CHECK_OBJECT(kw_names);
10981 assert(PyTuple_CheckExact(kw_names));
10982 CHECK_OBJECT(called);
10984 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10986 CHECK_OBJECTS(&args[9], nkwargs);
10988 if (Nuitka_Function_Check(called)) {
10989 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10996 Nuitka_CallFunctionVectorcall(tstate, function, args, 9, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
10998 Py_LeaveRecursiveCall();
11000 CHECK_OBJECT_X(result);
11003#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11004 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11005 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11007 if (likely(func != NULL)) {
11008 PyObject *result = func(called, args, 9, kw_names);
11010 CHECK_OBJECT_X(result);
11012 return Nuitka_CheckFunctionResult(tstate, called, result);
11018 PRINT_STRING(
"FALLBACK");
11019 PRINT_ITEM(called);
11023 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11025 if (unlikely(call_slot == NULL)) {
11026 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11031 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11035 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
11037 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11039 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11040 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11042 PyObject *value = args[9 + i];
11045 CHECK_OBJECT(value);
11047 DICT_SET_ITEM(named_args, key, value);
11050 PyObject *result = (*call_slot)(called, pos_args, named_args);
11052 Py_DECREF(pos_args);
11053 Py_DECREF(named_args);
11055 Py_LeaveRecursiveCall();
11057 CHECK_OBJECT_X(result);
11059 return Nuitka_CheckFunctionResult(tstate, called, result);
11061PyObject *CALL_FUNCTION_WITH_ARGS9_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
11062 PyObject *
const *kw_values, PyObject *kw_names) {
11063 CHECK_OBJECTS(args, 9);
11064 CHECK_OBJECT(kw_names);
11065 assert(PyTuple_CheckExact(kw_names));
11066 CHECK_OBJECT(called);
11068 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11070 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11072 if (Nuitka_Function_Check(called)) {
11073 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11079 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 9, kw_values, kw_names);
11081 Py_LeaveRecursiveCall();
11083 CHECK_OBJECT_X(result);
11086#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11087 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11088 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11090 if (likely(func != NULL)) {
11091 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 9 + nkwargs);
11093 memcpy(vectorcall_args, args, 9 *
sizeof(PyObject *));
11094 memcpy(&vectorcall_args[9], kw_values, nkwargs *
sizeof(PyObject *));
11096 PyObject *result = func(called, vectorcall_args, 9, kw_names);
11098 CHECK_OBJECT_X(result);
11100 return Nuitka_CheckFunctionResult(tstate, called, result);
11106 PRINT_STRING(
"FALLBACK");
11107 PRINT_ITEM(called);
11111 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11113 if (unlikely(call_slot == NULL)) {
11114 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11119 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11123 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
11125 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11127 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11128 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11130 PyObject *value = kw_values[i];
11133 CHECK_OBJECT(value);
11135 DICT_SET_ITEM(named_args, key, value);
11138 PyObject *result = (*call_slot)(called, pos_args, named_args);
11140 Py_DECREF(pos_args);
11141 Py_DECREF(named_args);
11143 Py_LeaveRecursiveCall();
11145 CHECK_OBJECT_X(result);
11147 return Nuitka_CheckFunctionResult(tstate, called, result);
11149PyObject *CALL_FUNCTION_WITH_POS_ARGS9_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
11150 PyObject *
const *kw_values, PyObject *kw_names) {
11151 assert(PyTuple_CheckExact(pos_args));
11152 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
11153 CHECK_OBJECTS(args, 9);
11154 CHECK_OBJECT(kw_names);
11155 assert(PyTuple_CheckExact(kw_names));
11156 CHECK_OBJECT(called);
11158 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11160 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11162 if (Nuitka_Function_Check(called)) {
11163 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11169 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 9, kw_values, kw_names);
11171 Py_LeaveRecursiveCall();
11173 CHECK_OBJECT_X(result);
11176#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11177 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11178 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11180 if (likely(func != NULL)) {
11181 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 9 + nkwargs);
11183 memcpy(vectorcall_args, args, 9 *
sizeof(PyObject *));
11184 memcpy(&vectorcall_args[9], kw_values, nkwargs *
sizeof(PyObject *));
11186 PyObject *result = func(called, vectorcall_args, 9, kw_names);
11188 CHECK_OBJECT_X(result);
11190 return Nuitka_CheckFunctionResult(tstate, called, result);
11196 PRINT_STRING(
"FALLBACK");
11197 PRINT_ITEM(called);
11201 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11203 if (unlikely(call_slot == NULL)) {
11204 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11209 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11213 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11215 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11216 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11218 PyObject *value = kw_values[i];
11221 CHECK_OBJECT(value);
11223 DICT_SET_ITEM(named_args, key, value);
11226 PyObject *result = (*call_slot)(called, pos_args, named_args);
11228 Py_DECREF(named_args);
11230 Py_LeaveRecursiveCall();
11232 CHECK_OBJECT_X(result);
11234 return Nuitka_CheckFunctionResult(tstate, called, result);
11236PyObject *CALL_FUNCTION_WITH_ARGS10_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
11237 PyObject *kw_names) {
11238 CHECK_OBJECTS(args, 10);
11239 CHECK_OBJECT(kw_names);
11240 assert(PyTuple_CheckExact(kw_names));
11241 CHECK_OBJECT(called);
11243 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11245 CHECK_OBJECTS(&args[10], nkwargs);
11247 if (Nuitka_Function_Check(called)) {
11248 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11255 Nuitka_CallFunctionVectorcall(tstate, function, args, 10, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
11257 Py_LeaveRecursiveCall();
11259 CHECK_OBJECT_X(result);
11262#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11263 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11264 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11266 if (likely(func != NULL)) {
11267 PyObject *result = func(called, args, 10, kw_names);
11269 CHECK_OBJECT_X(result);
11271 return Nuitka_CheckFunctionResult(tstate, called, result);
11277 PRINT_STRING(
"FALLBACK");
11278 PRINT_ITEM(called);
11282 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11284 if (unlikely(call_slot == NULL)) {
11285 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11290 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11294 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
11296 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11298 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11299 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11301 PyObject *value = args[10 + i];
11304 CHECK_OBJECT(value);
11306 DICT_SET_ITEM(named_args, key, value);
11309 PyObject *result = (*call_slot)(called, pos_args, named_args);
11311 Py_DECREF(pos_args);
11312 Py_DECREF(named_args);
11314 Py_LeaveRecursiveCall();
11316 CHECK_OBJECT_X(result);
11318 return Nuitka_CheckFunctionResult(tstate, called, result);
11320PyObject *CALL_FUNCTION_WITH_ARGS10_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
11321 PyObject *
const *kw_values, PyObject *kw_names) {
11322 CHECK_OBJECTS(args, 10);
11323 CHECK_OBJECT(kw_names);
11324 assert(PyTuple_CheckExact(kw_names));
11325 CHECK_OBJECT(called);
11327 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11329 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11331 if (Nuitka_Function_Check(called)) {
11332 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11338 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 10, kw_values, kw_names);
11340 Py_LeaveRecursiveCall();
11342 CHECK_OBJECT_X(result);
11345#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11346 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11347 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11349 if (likely(func != NULL)) {
11350 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 10 + nkwargs);
11352 memcpy(vectorcall_args, args, 10 *
sizeof(PyObject *));
11353 memcpy(&vectorcall_args[10], kw_values, nkwargs *
sizeof(PyObject *));
11355 PyObject *result = func(called, vectorcall_args, 10, kw_names);
11357 CHECK_OBJECT_X(result);
11359 return Nuitka_CheckFunctionResult(tstate, called, result);
11365 PRINT_STRING(
"FALLBACK");
11366 PRINT_ITEM(called);
11370 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11372 if (unlikely(call_slot == NULL)) {
11373 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11378 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11382 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
11384 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11386 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11387 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11389 PyObject *value = kw_values[i];
11392 CHECK_OBJECT(value);
11394 DICT_SET_ITEM(named_args, key, value);
11397 PyObject *result = (*call_slot)(called, pos_args, named_args);
11399 Py_DECREF(pos_args);
11400 Py_DECREF(named_args);
11402 Py_LeaveRecursiveCall();
11404 CHECK_OBJECT_X(result);
11406 return Nuitka_CheckFunctionResult(tstate, called, result);
11408PyObject *CALL_FUNCTION_WITH_POS_ARGS10_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
11409 PyObject *
const *kw_values, PyObject *kw_names) {
11410 assert(PyTuple_CheckExact(pos_args));
11411 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
11412 CHECK_OBJECTS(args, 10);
11413 CHECK_OBJECT(kw_names);
11414 assert(PyTuple_CheckExact(kw_names));
11415 CHECK_OBJECT(called);
11417 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11419 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11421 if (Nuitka_Function_Check(called)) {
11422 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11428 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 10, kw_values, kw_names);
11430 Py_LeaveRecursiveCall();
11432 CHECK_OBJECT_X(result);
11435#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11436 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11437 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11439 if (likely(func != NULL)) {
11440 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 10 + nkwargs);
11442 memcpy(vectorcall_args, args, 10 *
sizeof(PyObject *));
11443 memcpy(&vectorcall_args[10], kw_values, nkwargs *
sizeof(PyObject *));
11445 PyObject *result = func(called, vectorcall_args, 10, kw_names);
11447 CHECK_OBJECT_X(result);
11449 return Nuitka_CheckFunctionResult(tstate, called, result);
11455 PRINT_STRING(
"FALLBACK");
11456 PRINT_ITEM(called);
11460 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11462 if (unlikely(call_slot == NULL)) {
11463 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11468 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11472 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11474 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11475 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11477 PyObject *value = kw_values[i];
11480 CHECK_OBJECT(value);
11482 DICT_SET_ITEM(named_args, key, value);
11485 PyObject *result = (*call_slot)(called, pos_args, named_args);
11487 Py_DECREF(named_args);
11489 Py_LeaveRecursiveCall();
11491 CHECK_OBJECT_X(result);
11493 return Nuitka_CheckFunctionResult(tstate, called, result);
11495PyObject *CALL_METHODDESCR_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *called, PyObject *arg) {
11496 PyObject *
const *args = &arg;
11497 CHECK_OBJECT(called);
11498 CHECK_OBJECTS(args, 1);
11500#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11501 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11502 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11503 assert(func != NULL);
11504 PyObject *result = func(called, args, 1, NULL);
11506#ifndef __NUITKA_NO_ASSERT__
11507 return Nuitka_CheckFunctionResult(tstate, called, result);
11512 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11513 PyMethodDef *method_def = called_descr->d_method;
11516 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11518 if (likely(flags & METH_NOARGS)) {
11519 PyCFunction method = method_def->ml_meth;
11520 PyObject *self = args[0];
11522 PyObject *result = (*method)(self, NULL);
11524#ifndef __NUITKA_NO_ASSERT__
11525 return Nuitka_CheckFunctionResult(tstate, called, result);
11529 }
else if ((flags & METH_O)) {
11530 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (1 given)",
11531 method_def->ml_name);
11533 }
else if (flags & METH_VARARGS) {
11534 PyCFunction method = method_def->ml_meth;
11535 PyObject *self = args[0];
11539#if PYTHON_VERSION < 0x360
11540 if (flags & METH_KEYWORDS) {
11541 result = (*(PyCFunctionWithKeywords)method)(self, const_tuple_empty, NULL);
11543 result = (*method)(self, const_tuple_empty);
11546 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11547 result = (*(PyCFunctionWithKeywords)method)(self, const_tuple_empty, NULL);
11548 }
else if (flags == METH_FASTCALL) {
11549#if PYTHON_VERSION < 0x370
11550 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 0, NULL);
11552 result = (*(_PyCFunctionFast)method)(self, &const_tuple_empty, 1);
11555 result = (*method)(self, const_tuple_empty);
11558#ifndef __NUITKA_NO_ASSERT__
11559 return Nuitka_CheckFunctionResult(tstate, called, result);
11567 PRINT_STRING(
"FALLBACK");
11568 PRINT_ITEM(called);
11572 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
11574 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11576 Py_DECREF(pos_args);
11581PyObject *CALL_METHODDESCR_WITH_ARGS2(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
11582 CHECK_OBJECT(called);
11583 CHECK_OBJECTS(args, 2);
11585#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11586 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11587 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11588 assert(func != NULL);
11589 PyObject *result = func(called, args, 2, NULL);
11591#ifndef __NUITKA_NO_ASSERT__
11592 return Nuitka_CheckFunctionResult(tstate, called, result);
11597 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11598 PyMethodDef *method_def = called_descr->d_method;
11601 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11603 if (unlikely(flags & METH_NOARGS)) {
11604 PyCFunction method = method_def->ml_meth;
11605 PyObject *self = args[0];
11607 PyObject *result = (*method)(self, NULL);
11609#ifndef __NUITKA_NO_ASSERT__
11610 return Nuitka_CheckFunctionResult(tstate, called, result);
11614 }
else if (unlikely(flags & METH_O)) {
11615 PyCFunction method = method_def->ml_meth;
11616 PyObject *self = args[0];
11618 PyObject *result = (*method)(self, args[1]);
11620#ifndef __NUITKA_NO_ASSERT__
11621 return Nuitka_CheckFunctionResult(tstate, called, result);
11625 }
else if (flags & METH_VARARGS) {
11626 PyCFunction method = method_def->ml_meth;
11627 PyObject *self = args[0];
11631#if PYTHON_VERSION < 0x360
11632 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11634 if (flags & METH_KEYWORDS) {
11635 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11637 result = (*method)(self, pos_args);
11640 Py_DECREF(pos_args);
11642 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11643 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11644 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11645 Py_DECREF(pos_args);
11646 }
else if (flags == METH_FASTCALL) {
11647#if PYTHON_VERSION < 0x370
11648 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 1, NULL);
11650 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11651 result = (*(_PyCFunctionFast)method)(self, &pos_args, 2);
11652 Py_DECREF(pos_args);
11655 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11656 result = (*method)(self, pos_args);
11657 Py_DECREF(pos_args);
11660#ifndef __NUITKA_NO_ASSERT__
11661 return Nuitka_CheckFunctionResult(tstate, called, result);
11669 PRINT_STRING(
"FALLBACK");
11670 PRINT_ITEM(called);
11674 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
11676 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11678 Py_DECREF(pos_args);
11683PyObject *CALL_METHODDESCR_WITH_ARGS3(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
11684 CHECK_OBJECT(called);
11685 CHECK_OBJECTS(args, 3);
11687#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11688 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11689 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11690 assert(func != NULL);
11691 PyObject *result = func(called, args, 3, NULL);
11693#ifndef __NUITKA_NO_ASSERT__
11694 return Nuitka_CheckFunctionResult(tstate, called, result);
11699 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11700 PyMethodDef *method_def = called_descr->d_method;
11703 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11705 if (unlikely(flags & METH_NOARGS)) {
11706 PyCFunction method = method_def->ml_meth;
11707 PyObject *self = args[0];
11709 PyObject *result = (*method)(self, NULL);
11711#ifndef __NUITKA_NO_ASSERT__
11712 return Nuitka_CheckFunctionResult(tstate, called, result);
11716 }
else if (unlikely(flags & METH_O)) {
11717 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (3 given)",
11718 method_def->ml_name);
11720 }
else if (flags & METH_VARARGS) {
11721 PyCFunction method = method_def->ml_meth;
11722 PyObject *self = args[0];
11726#if PYTHON_VERSION < 0x360
11727 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11729 if (flags & METH_KEYWORDS) {
11730 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11732 result = (*method)(self, pos_args);
11735 Py_DECREF(pos_args);
11737 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11738 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11739 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11740 Py_DECREF(pos_args);
11741 }
else if (flags == METH_FASTCALL) {
11742#if PYTHON_VERSION < 0x370
11743 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 2, NULL);
11745 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11746 result = (*(_PyCFunctionFast)method)(self, &pos_args, 3);
11747 Py_DECREF(pos_args);
11750 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11751 result = (*method)(self, pos_args);
11752 Py_DECREF(pos_args);
11755#ifndef __NUITKA_NO_ASSERT__
11756 return Nuitka_CheckFunctionResult(tstate, called, result);
11764 PRINT_STRING(
"FALLBACK");
11765 PRINT_ITEM(called);
11769 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
11771 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11773 Py_DECREF(pos_args);
11778PyObject *CALL_METHODDESCR_WITH_ARGS4(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
11779 CHECK_OBJECT(called);
11780 CHECK_OBJECTS(args, 4);
11782#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11783 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11784 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11785 assert(func != NULL);
11786 PyObject *result = func(called, args, 4, NULL);
11788#ifndef __NUITKA_NO_ASSERT__
11789 return Nuitka_CheckFunctionResult(tstate, called, result);
11794 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11795 PyMethodDef *method_def = called_descr->d_method;
11798 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11800 if (unlikely(flags & METH_NOARGS)) {
11801 PyCFunction method = method_def->ml_meth;
11802 PyObject *self = args[0];
11804 PyObject *result = (*method)(self, NULL);
11806#ifndef __NUITKA_NO_ASSERT__
11807 return Nuitka_CheckFunctionResult(tstate, called, result);
11811 }
else if (unlikely(flags & METH_O)) {
11812 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (4 given)",
11813 method_def->ml_name);
11815 }
else if (flags & METH_VARARGS) {
11816 PyCFunction method = method_def->ml_meth;
11817 PyObject *self = args[0];
11821#if PYTHON_VERSION < 0x360
11822 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11824 if (flags & METH_KEYWORDS) {
11825 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11827 result = (*method)(self, pos_args);
11830 Py_DECREF(pos_args);
11832 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11833 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11834 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11835 Py_DECREF(pos_args);
11836 }
else if (flags == METH_FASTCALL) {
11837#if PYTHON_VERSION < 0x370
11838 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 3, NULL);
11840 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11841 result = (*(_PyCFunctionFast)method)(self, &pos_args, 4);
11842 Py_DECREF(pos_args);
11845 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11846 result = (*method)(self, pos_args);
11847 Py_DECREF(pos_args);
11850#ifndef __NUITKA_NO_ASSERT__
11851 return Nuitka_CheckFunctionResult(tstate, called, result);
11859 PRINT_STRING(
"FALLBACK");
11860 PRINT_ITEM(called);
11864 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
11866 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11868 Py_DECREF(pos_args);
11873PyObject *CALL_METHOD_NO_ARGS(PyThreadState *tstate, PyObject *source, PyObject *attr_name) {
11874 CHECK_OBJECT(source);
11875 CHECK_OBJECT(attr_name);
11877 PyTypeObject *type = Py_TYPE(source);
11879 if (hasTypeGenericGetAttr(type)) {
11881 if (unlikely(type->tp_dict == NULL)) {
11882 if (unlikely(PyType_Ready(type) < 0)) {
11887 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
11888 descrgetfunc func = NULL;
11890 if (descr != NULL) {
11893 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
11894 func = Py_TYPE(descr)->tp_descr_get;
11896 if (func != NULL && Nuitka_Descr_IsData(descr)) {
11897 PyObject *called_object = func(descr, source, (PyObject *)type);
11900 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
11901 Py_DECREF(called_object);
11907 Py_ssize_t dictoffset = type->tp_dictoffset;
11908 PyObject *dict = NULL;
11910 if (dictoffset != 0) {
11912 if (dictoffset < 0) {
11916 tsize = ((PyVarObject *)source)->ob_size;
11920 size = _PyObject_VAR_SIZE(type, tsize);
11922 dictoffset += (long)size;
11925 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
11929 if (dict != NULL) {
11930 CHECK_OBJECT(dict);
11934 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
11936 if (called_object != NULL) {
11940 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
11941 Py_DECREF(called_object);
11948 if (func != NULL) {
11949 if (func == Nuitka_Function_Type.tp_descr_get) {
11956 PyObject *called_object = func(descr, source, (PyObject *)type);
11957 CHECK_OBJECT(called_object);
11961 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
11962 Py_DECREF(called_object);
11967 if (descr != NULL) {
11968 CHECK_OBJECT(descr);
11970 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, descr);
11975#if PYTHON_VERSION < 0x300
11976 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
11977 PyString_AS_STRING(attr_name));
11979 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
11983#if PYTHON_VERSION < 0x300
11984 else if (type == &PyInstance_Type) {
11985 PyInstanceObject *source_instance = (PyInstanceObject *)source;
11989 assert(attr_name != const_str_plain___dict__);
11990 assert(attr_name != const_str_plain___class__);
11993 PyObject *called_object =
11994 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
11998 if (called_object != NULL) {
11999 return CALL_FUNCTION_NO_ARGS(tstate, called_object);
12003 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12007 if (called_object != NULL) {
12008 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12010 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12011 return Nuitka_CallMethodFunctionNoArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12013 }
else if (descr_get != NULL) {
12014 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12016 if (unlikely(method == NULL)) {
12020 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, method);
12024 return CALL_FUNCTION_NO_ARGS(tstate, called_object);
12027 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12028 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12029 PyString_AS_STRING(source_instance->in_class->cl_name),
12030 PyString_AS_STRING(attr_name));
12037 PyObject *args2[] = {source, attr_name};
12039 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12041 if (unlikely(called_object == NULL)) {
12045 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
12046 Py_DECREF(called_object);
12051 else if (type->tp_getattro != NULL) {
12052 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12054 if (unlikely(descr == NULL)) {
12058 descrgetfunc func = NULL;
12059 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12060 func = Py_TYPE(descr)->tp_descr_get;
12062 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12063 PyObject *called_object = func(descr, source, (PyObject *)type);
12066 if (unlikely(called_object == NULL)) {
12070 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
12071 Py_DECREF(called_object);
12076 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, descr);
12079 }
else if (type->tp_getattr != NULL) {
12080 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12082 if (unlikely(called_object == NULL)) {
12086 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
12087 Py_DECREF(called_object);
12090 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12091 Nuitka_String_AsString_Unchecked(attr_name));
12096PyObject *CALL_METHOD_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *arg) {
12097 PyObject *
const *args = &arg;
12098 CHECK_OBJECT(source);
12099 CHECK_OBJECT(attr_name);
12101 CHECK_OBJECTS(args, 1);
12103 PyTypeObject *type = Py_TYPE(source);
12105 if (hasTypeGenericGetAttr(type)) {
12107 if (unlikely(type->tp_dict == NULL)) {
12108 if (unlikely(PyType_Ready(type) < 0)) {
12113 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12114 descrgetfunc func = NULL;
12116 if (descr != NULL) {
12119 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12120 func = Py_TYPE(descr)->tp_descr_get;
12122 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12123 PyObject *called_object = func(descr, source, (PyObject *)type);
12126 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12127 Py_DECREF(called_object);
12133 Py_ssize_t dictoffset = type->tp_dictoffset;
12134 PyObject *dict = NULL;
12136 if (dictoffset != 0) {
12138 if (dictoffset < 0) {
12142 tsize = ((PyVarObject *)source)->ob_size;
12146 size = _PyObject_VAR_SIZE(type, tsize);
12148 dictoffset += (long)size;
12151 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
12155 if (dict != NULL) {
12156 CHECK_OBJECT(dict);
12160 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12162 if (called_object != NULL) {
12166 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12167 Py_DECREF(called_object);
12174 if (func != NULL) {
12175 if (func == Nuitka_Function_Type.tp_descr_get) {
12176 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
12182 PyObject *called_object = func(descr, source, (PyObject *)type);
12183 CHECK_OBJECT(called_object);
12187 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12188 Py_DECREF(called_object);
12193 if (descr != NULL) {
12194 CHECK_OBJECT(descr);
12196 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, descr, args[0]);
12201#if PYTHON_VERSION < 0x300
12202 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12203 PyString_AS_STRING(attr_name));
12205 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
12209#if PYTHON_VERSION < 0x300
12210 else if (type == &PyInstance_Type) {
12211 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12215 assert(attr_name != const_str_plain___dict__);
12216 assert(attr_name != const_str_plain___class__);
12219 PyObject *called_object =
12220 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12224 if (called_object != NULL) {
12225 return CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12229 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12233 if (called_object != NULL) {
12234 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12236 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12237 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12239 }
else if (descr_get != NULL) {
12240 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12242 if (unlikely(method == NULL)) {
12246 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, method, args[0]);
12250 return CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12253 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12254 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12255 PyString_AS_STRING(source_instance->in_class->cl_name),
12256 PyString_AS_STRING(attr_name));
12263 PyObject *args2[] = {source, attr_name};
12265 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12267 if (unlikely(called_object == NULL)) {
12271 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12272 Py_DECREF(called_object);
12277 else if (type->tp_getattro != NULL) {
12278 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12280 if (unlikely(descr == NULL)) {
12284 descrgetfunc func = NULL;
12285 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12286 func = Py_TYPE(descr)->tp_descr_get;
12288 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12289 PyObject *called_object = func(descr, source, (PyObject *)type);
12292 if (unlikely(called_object == NULL)) {
12296 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12297 Py_DECREF(called_object);
12302 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, descr, args[0]);
12305 }
else if (type->tp_getattr != NULL) {
12306 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12308 if (unlikely(called_object == NULL)) {
12312 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12313 Py_DECREF(called_object);
12316 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12317 Nuitka_String_AsString_Unchecked(attr_name));
12322PyObject *CALL_METHOD_WITH_ARGS2(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
12323 CHECK_OBJECT(source);
12324 CHECK_OBJECT(attr_name);
12326 CHECK_OBJECTS(args, 2);
12328 PyTypeObject *type = Py_TYPE(source);
12330 if (hasTypeGenericGetAttr(type)) {
12332 if (unlikely(type->tp_dict == NULL)) {
12333 if (unlikely(PyType_Ready(type) < 0)) {
12338 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12339 descrgetfunc func = NULL;
12341 if (descr != NULL) {
12344 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12345 func = Py_TYPE(descr)->tp_descr_get;
12347 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12348 PyObject *called_object = func(descr, source, (PyObject *)type);
12351 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12352 Py_DECREF(called_object);
12358 Py_ssize_t dictoffset = type->tp_dictoffset;
12359 PyObject *dict = NULL;
12361 if (dictoffset != 0) {
12363 if (dictoffset < 0) {
12367 tsize = ((PyVarObject *)source)->ob_size;
12371 size = _PyObject_VAR_SIZE(type, tsize);
12373 dictoffset += (long)size;
12376 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
12380 if (dict != NULL) {
12381 CHECK_OBJECT(dict);
12385 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12387 if (called_object != NULL) {
12391 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12392 Py_DECREF(called_object);
12399 if (func != NULL) {
12400 if (func == Nuitka_Function_Type.tp_descr_get) {
12401 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
12407 PyObject *called_object = func(descr, source, (PyObject *)type);
12408 CHECK_OBJECT(called_object);
12412 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12413 Py_DECREF(called_object);
12418 if (descr != NULL) {
12419 CHECK_OBJECT(descr);
12421 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, descr, args);
12426#if PYTHON_VERSION < 0x300
12427 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12428 PyString_AS_STRING(attr_name));
12430 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
12434#if PYTHON_VERSION < 0x300
12435 else if (type == &PyInstance_Type) {
12436 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12440 assert(attr_name != const_str_plain___dict__);
12441 assert(attr_name != const_str_plain___class__);
12444 PyObject *called_object =
12445 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12449 if (called_object != NULL) {
12450 return CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12454 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12458 if (called_object != NULL) {
12459 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12461 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12462 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12464 }
else if (descr_get != NULL) {
12465 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12467 if (unlikely(method == NULL)) {
12471 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, method, args);
12475 return CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12478 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12479 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12480 PyString_AS_STRING(source_instance->in_class->cl_name),
12481 PyString_AS_STRING(attr_name));
12488 PyObject *args2[] = {source, attr_name};
12490 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12492 if (unlikely(called_object == NULL)) {
12496 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12497 Py_DECREF(called_object);
12502 else if (type->tp_getattro != NULL) {
12503 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12505 if (unlikely(descr == NULL)) {
12509 descrgetfunc func = NULL;
12510 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12511 func = Py_TYPE(descr)->tp_descr_get;
12513 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12514 PyObject *called_object = func(descr, source, (PyObject *)type);
12517 if (unlikely(called_object == NULL)) {
12521 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12522 Py_DECREF(called_object);
12527 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, descr, args);
12530 }
else if (type->tp_getattr != NULL) {
12531 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12533 if (unlikely(called_object == NULL)) {
12537 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12538 Py_DECREF(called_object);
12541 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12542 Nuitka_String_AsString_Unchecked(attr_name));
12547PyObject *CALL_METHOD_WITH_ARGS3(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
12548 CHECK_OBJECT(source);
12549 CHECK_OBJECT(attr_name);
12551 CHECK_OBJECTS(args, 3);
12553 PyTypeObject *type = Py_TYPE(source);
12555 if (hasTypeGenericGetAttr(type)) {
12557 if (unlikely(type->tp_dict == NULL)) {
12558 if (unlikely(PyType_Ready(type) < 0)) {
12563 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12564 descrgetfunc func = NULL;
12566 if (descr != NULL) {
12569 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12570 func = Py_TYPE(descr)->tp_descr_get;
12572 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12573 PyObject *called_object = func(descr, source, (PyObject *)type);
12576 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12577 Py_DECREF(called_object);
12583 Py_ssize_t dictoffset = type->tp_dictoffset;
12584 PyObject *dict = NULL;
12586 if (dictoffset != 0) {
12588 if (dictoffset < 0) {
12592 tsize = ((PyVarObject *)source)->ob_size;
12596 size = _PyObject_VAR_SIZE(type, tsize);
12598 dictoffset += (long)size;
12601 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
12605 if (dict != NULL) {
12606 CHECK_OBJECT(dict);
12610 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12612 if (called_object != NULL) {
12616 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12617 Py_DECREF(called_object);
12624 if (func != NULL) {
12625 if (func == Nuitka_Function_Type.tp_descr_get) {
12626 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
12632 PyObject *called_object = func(descr, source, (PyObject *)type);
12633 CHECK_OBJECT(called_object);
12637 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12638 Py_DECREF(called_object);
12643 if (descr != NULL) {
12644 CHECK_OBJECT(descr);
12646 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, descr, args);
12651#if PYTHON_VERSION < 0x300
12652 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12653 PyString_AS_STRING(attr_name));
12655 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
12659#if PYTHON_VERSION < 0x300
12660 else if (type == &PyInstance_Type) {
12661 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12665 assert(attr_name != const_str_plain___dict__);
12666 assert(attr_name != const_str_plain___class__);
12669 PyObject *called_object =
12670 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12674 if (called_object != NULL) {
12675 return CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12679 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12683 if (called_object != NULL) {
12684 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12686 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12687 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12689 }
else if (descr_get != NULL) {
12690 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12692 if (unlikely(method == NULL)) {
12696 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, method, args);
12700 return CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12703 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12704 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12705 PyString_AS_STRING(source_instance->in_class->cl_name),
12706 PyString_AS_STRING(attr_name));
12713 PyObject *args2[] = {source, attr_name};
12715 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12717 if (unlikely(called_object == NULL)) {
12721 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12722 Py_DECREF(called_object);
12727 else if (type->tp_getattro != NULL) {
12728 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12730 if (unlikely(descr == NULL)) {
12734 descrgetfunc func = NULL;
12735 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12736 func = Py_TYPE(descr)->tp_descr_get;
12738 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12739 PyObject *called_object = func(descr, source, (PyObject *)type);
12742 if (unlikely(called_object == NULL)) {
12746 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12747 Py_DECREF(called_object);
12752 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, descr, args);
12755 }
else if (type->tp_getattr != NULL) {
12756 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12758 if (unlikely(called_object == NULL)) {
12762 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12763 Py_DECREF(called_object);
12766 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12767 Nuitka_String_AsString_Unchecked(attr_name));
12772PyObject *CALL_METHOD_WITH_ARGS4(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
12773 CHECK_OBJECT(source);
12774 CHECK_OBJECT(attr_name);
12776 CHECK_OBJECTS(args, 4);
12778 PyTypeObject *type = Py_TYPE(source);
12780 if (hasTypeGenericGetAttr(type)) {
12782 if (unlikely(type->tp_dict == NULL)) {
12783 if (unlikely(PyType_Ready(type) < 0)) {
12788 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12789 descrgetfunc func = NULL;
12791 if (descr != NULL) {
12794 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12795 func = Py_TYPE(descr)->tp_descr_get;
12797 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12798 PyObject *called_object = func(descr, source, (PyObject *)type);
12801 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12802 Py_DECREF(called_object);
12808 Py_ssize_t dictoffset = type->tp_dictoffset;
12809 PyObject *dict = NULL;
12811 if (dictoffset != 0) {
12813 if (dictoffset < 0) {
12817 tsize = ((PyVarObject *)source)->ob_size;
12821 size = _PyObject_VAR_SIZE(type, tsize);
12823 dictoffset += (long)size;
12826 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
12830 if (dict != NULL) {
12831 CHECK_OBJECT(dict);
12835 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12837 if (called_object != NULL) {
12841 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12842 Py_DECREF(called_object);
12849 if (func != NULL) {
12850 if (func == Nuitka_Function_Type.tp_descr_get) {
12851 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
12857 PyObject *called_object = func(descr, source, (PyObject *)type);
12858 CHECK_OBJECT(called_object);
12862 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12863 Py_DECREF(called_object);
12868 if (descr != NULL) {
12869 CHECK_OBJECT(descr);
12871 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, descr, args);
12876#if PYTHON_VERSION < 0x300
12877 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12878 PyString_AS_STRING(attr_name));
12880 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
12884#if PYTHON_VERSION < 0x300
12885 else if (type == &PyInstance_Type) {
12886 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12890 assert(attr_name != const_str_plain___dict__);
12891 assert(attr_name != const_str_plain___class__);
12894 PyObject *called_object =
12895 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12899 if (called_object != NULL) {
12900 return CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12904 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12908 if (called_object != NULL) {
12909 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12911 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12912 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12914 }
else if (descr_get != NULL) {
12915 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12917 if (unlikely(method == NULL)) {
12921 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, method, args);
12925 return CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12928 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12929 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12930 PyString_AS_STRING(source_instance->in_class->cl_name),
12931 PyString_AS_STRING(attr_name));
12938 PyObject *args2[] = {source, attr_name};
12940 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12942 if (unlikely(called_object == NULL)) {
12946 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12947 Py_DECREF(called_object);
12952 else if (type->tp_getattro != NULL) {
12953 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12955 if (unlikely(descr == NULL)) {
12959 descrgetfunc func = NULL;
12960 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12961 func = Py_TYPE(descr)->tp_descr_get;
12963 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12964 PyObject *called_object = func(descr, source, (PyObject *)type);
12967 if (unlikely(called_object == NULL)) {
12971 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12972 Py_DECREF(called_object);
12977 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, descr, args);
12980 }
else if (type->tp_getattr != NULL) {
12981 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12983 if (unlikely(called_object == NULL)) {
12987 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12988 Py_DECREF(called_object);
12991 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12992 Nuitka_String_AsString_Unchecked(attr_name));
12997PyObject *CALL_METHOD_WITH_ARGS5(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
12998 CHECK_OBJECT(source);
12999 CHECK_OBJECT(attr_name);
13001 CHECK_OBJECTS(args, 5);
13003 PyTypeObject *type = Py_TYPE(source);
13005 if (hasTypeGenericGetAttr(type)) {
13007 if (unlikely(type->tp_dict == NULL)) {
13008 if (unlikely(PyType_Ready(type) < 0)) {
13013 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13014 descrgetfunc func = NULL;
13016 if (descr != NULL) {
13019 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13020 func = Py_TYPE(descr)->tp_descr_get;
13022 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13023 PyObject *called_object = func(descr, source, (PyObject *)type);
13026 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13027 Py_DECREF(called_object);
13033 Py_ssize_t dictoffset = type->tp_dictoffset;
13034 PyObject *dict = NULL;
13036 if (dictoffset != 0) {
13038 if (dictoffset < 0) {
13042 tsize = ((PyVarObject *)source)->ob_size;
13046 size = _PyObject_VAR_SIZE(type, tsize);
13048 dictoffset += (long)size;
13051 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13055 if (dict != NULL) {
13056 CHECK_OBJECT(dict);
13060 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13062 if (called_object != NULL) {
13066 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13067 Py_DECREF(called_object);
13074 if (func != NULL) {
13075 if (func == Nuitka_Function_Type.tp_descr_get) {
13076 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13082 PyObject *called_object = func(descr, source, (PyObject *)type);
13083 CHECK_OBJECT(called_object);
13087 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13088 Py_DECREF(called_object);
13093 if (descr != NULL) {
13094 CHECK_OBJECT(descr);
13096 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, descr, args);
13101#if PYTHON_VERSION < 0x300
13102 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13103 PyString_AS_STRING(attr_name));
13105 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
13109#if PYTHON_VERSION < 0x300
13110 else if (type == &PyInstance_Type) {
13111 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13115 assert(attr_name != const_str_plain___dict__);
13116 assert(attr_name != const_str_plain___class__);
13119 PyObject *called_object =
13120 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13124 if (called_object != NULL) {
13125 return CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13129 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13133 if (called_object != NULL) {
13134 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13136 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13137 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
13139 }
else if (descr_get != NULL) {
13140 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13142 if (unlikely(method == NULL)) {
13146 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, method, args);
13150 return CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13153 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13154 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
13155 PyString_AS_STRING(source_instance->in_class->cl_name),
13156 PyString_AS_STRING(attr_name));
13163 PyObject *args2[] = {source, attr_name};
13165 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13167 if (unlikely(called_object == NULL)) {
13171 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13172 Py_DECREF(called_object);
13177 else if (type->tp_getattro != NULL) {
13178 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13180 if (unlikely(descr == NULL)) {
13184 descrgetfunc func = NULL;
13185 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13186 func = Py_TYPE(descr)->tp_descr_get;
13188 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13189 PyObject *called_object = func(descr, source, (PyObject *)type);
13192 if (unlikely(called_object == NULL)) {
13196 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13197 Py_DECREF(called_object);
13202 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, descr, args);
13205 }
else if (type->tp_getattr != NULL) {
13206 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
13208 if (unlikely(called_object == NULL)) {
13212 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13213 Py_DECREF(called_object);
13216 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13217 Nuitka_String_AsString_Unchecked(attr_name));
13222PyObject *CALL_METHOD_WITH_ARGS6(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13223 CHECK_OBJECT(source);
13224 CHECK_OBJECT(attr_name);
13226 CHECK_OBJECTS(args, 6);
13228 PyTypeObject *type = Py_TYPE(source);
13230 if (hasTypeGenericGetAttr(type)) {
13232 if (unlikely(type->tp_dict == NULL)) {
13233 if (unlikely(PyType_Ready(type) < 0)) {
13238 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13239 descrgetfunc func = NULL;
13241 if (descr != NULL) {
13244 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13245 func = Py_TYPE(descr)->tp_descr_get;
13247 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13248 PyObject *called_object = func(descr, source, (PyObject *)type);
13251 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13252 Py_DECREF(called_object);
13258 Py_ssize_t dictoffset = type->tp_dictoffset;
13259 PyObject *dict = NULL;
13261 if (dictoffset != 0) {
13263 if (dictoffset < 0) {
13267 tsize = ((PyVarObject *)source)->ob_size;
13271 size = _PyObject_VAR_SIZE(type, tsize);
13273 dictoffset += (long)size;
13276 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13280 if (dict != NULL) {
13281 CHECK_OBJECT(dict);
13285 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13287 if (called_object != NULL) {
13291 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13292 Py_DECREF(called_object);
13299 if (func != NULL) {
13300 if (func == Nuitka_Function_Type.tp_descr_get) {
13301 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13307 PyObject *called_object = func(descr, source, (PyObject *)type);
13308 CHECK_OBJECT(called_object);
13312 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13313 Py_DECREF(called_object);
13318 if (descr != NULL) {
13319 CHECK_OBJECT(descr);
13321 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, descr, args);
13326#if PYTHON_VERSION < 0x300
13327 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13328 PyString_AS_STRING(attr_name));
13330 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
13334#if PYTHON_VERSION < 0x300
13335 else if (type == &PyInstance_Type) {
13336 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13340 assert(attr_name != const_str_plain___dict__);
13341 assert(attr_name != const_str_plain___class__);
13344 PyObject *called_object =
13345 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13349 if (called_object != NULL) {
13350 return CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13354 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13358 if (called_object != NULL) {
13359 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13361 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13362 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
13364 }
else if (descr_get != NULL) {
13365 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13367 if (unlikely(method == NULL)) {
13371 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, method, args);
13375 return CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13378 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13379 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
13380 PyString_AS_STRING(source_instance->in_class->cl_name),
13381 PyString_AS_STRING(attr_name));
13388 PyObject *args2[] = {source, attr_name};
13390 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13392 if (unlikely(called_object == NULL)) {
13396 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13397 Py_DECREF(called_object);
13402 else if (type->tp_getattro != NULL) {
13403 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13405 if (unlikely(descr == NULL)) {
13409 descrgetfunc func = NULL;
13410 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13411 func = Py_TYPE(descr)->tp_descr_get;
13413 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13414 PyObject *called_object = func(descr, source, (PyObject *)type);
13417 if (unlikely(called_object == NULL)) {
13421 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13422 Py_DECREF(called_object);
13427 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, descr, args);
13430 }
else if (type->tp_getattr != NULL) {
13431 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
13433 if (unlikely(called_object == NULL)) {
13437 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13438 Py_DECREF(called_object);
13441 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13442 Nuitka_String_AsString_Unchecked(attr_name));
13447PyObject *CALL_METHOD_WITH_ARGS7(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13448 CHECK_OBJECT(source);
13449 CHECK_OBJECT(attr_name);
13451 CHECK_OBJECTS(args, 7);
13453 PyTypeObject *type = Py_TYPE(source);
13455 if (hasTypeGenericGetAttr(type)) {
13457 if (unlikely(type->tp_dict == NULL)) {
13458 if (unlikely(PyType_Ready(type) < 0)) {
13463 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13464 descrgetfunc func = NULL;
13466 if (descr != NULL) {
13469 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13470 func = Py_TYPE(descr)->tp_descr_get;
13472 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13473 PyObject *called_object = func(descr, source, (PyObject *)type);
13476 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13477 Py_DECREF(called_object);
13483 Py_ssize_t dictoffset = type->tp_dictoffset;
13484 PyObject *dict = NULL;
13486 if (dictoffset != 0) {
13488 if (dictoffset < 0) {
13492 tsize = ((PyVarObject *)source)->ob_size;
13496 size = _PyObject_VAR_SIZE(type, tsize);
13498 dictoffset += (long)size;
13501 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13505 if (dict != NULL) {
13506 CHECK_OBJECT(dict);
13510 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13512 if (called_object != NULL) {
13516 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13517 Py_DECREF(called_object);
13524 if (func != NULL) {
13525 if (func == Nuitka_Function_Type.tp_descr_get) {
13526 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13532 PyObject *called_object = func(descr, source, (PyObject *)type);
13533 CHECK_OBJECT(called_object);
13537 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13538 Py_DECREF(called_object);
13543 if (descr != NULL) {
13544 CHECK_OBJECT(descr);
13546 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, descr, args);
13551#if PYTHON_VERSION < 0x300
13552 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13553 PyString_AS_STRING(attr_name));
13555 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
13559#if PYTHON_VERSION < 0x300
13560 else if (type == &PyInstance_Type) {
13561 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13565 assert(attr_name != const_str_plain___dict__);
13566 assert(attr_name != const_str_plain___class__);
13569 PyObject *called_object =
13570 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13574 if (called_object != NULL) {
13575 return CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13579 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13583 if (called_object != NULL) {
13584 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13586 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13587 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
13589 }
else if (descr_get != NULL) {
13590 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13592 if (unlikely(method == NULL)) {
13596 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, method, args);
13600 return CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13603 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13604 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
13605 PyString_AS_STRING(source_instance->in_class->cl_name),
13606 PyString_AS_STRING(attr_name));
13613 PyObject *args2[] = {source, attr_name};
13615 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13617 if (unlikely(called_object == NULL)) {
13621 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13622 Py_DECREF(called_object);
13627 else if (type->tp_getattro != NULL) {
13628 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13630 if (unlikely(descr == NULL)) {
13634 descrgetfunc func = NULL;
13635 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13636 func = Py_TYPE(descr)->tp_descr_get;
13638 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13639 PyObject *called_object = func(descr, source, (PyObject *)type);
13642 if (unlikely(called_object == NULL)) {
13646 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13647 Py_DECREF(called_object);
13652 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, descr, args);
13655 }
else if (type->tp_getattr != NULL) {
13656 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
13658 if (unlikely(called_object == NULL)) {
13662 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13663 Py_DECREF(called_object);
13666 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13667 Nuitka_String_AsString_Unchecked(attr_name));
13672PyObject *CALL_METHOD_WITH_ARGS8(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13673 CHECK_OBJECT(source);
13674 CHECK_OBJECT(attr_name);
13676 CHECK_OBJECTS(args, 8);
13678 PyTypeObject *type = Py_TYPE(source);
13680 if (hasTypeGenericGetAttr(type)) {
13682 if (unlikely(type->tp_dict == NULL)) {
13683 if (unlikely(PyType_Ready(type) < 0)) {
13688 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13689 descrgetfunc func = NULL;
13691 if (descr != NULL) {
13694 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13695 func = Py_TYPE(descr)->tp_descr_get;
13697 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13698 PyObject *called_object = func(descr, source, (PyObject *)type);
13701 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13702 Py_DECREF(called_object);
13708 Py_ssize_t dictoffset = type->tp_dictoffset;
13709 PyObject *dict = NULL;
13711 if (dictoffset != 0) {
13713 if (dictoffset < 0) {
13717 tsize = ((PyVarObject *)source)->ob_size;
13721 size = _PyObject_VAR_SIZE(type, tsize);
13723 dictoffset += (long)size;
13726 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13730 if (dict != NULL) {
13731 CHECK_OBJECT(dict);
13735 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13737 if (called_object != NULL) {
13741 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13742 Py_DECREF(called_object);
13749 if (func != NULL) {
13750 if (func == Nuitka_Function_Type.tp_descr_get) {
13751 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13757 PyObject *called_object = func(descr, source, (PyObject *)type);
13758 CHECK_OBJECT(called_object);
13762 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13763 Py_DECREF(called_object);
13768 if (descr != NULL) {
13769 CHECK_OBJECT(descr);
13771 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, descr, args);
13776#if PYTHON_VERSION < 0x300
13777 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13778 PyString_AS_STRING(attr_name));
13780 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
13784#if PYTHON_VERSION < 0x300
13785 else if (type == &PyInstance_Type) {
13786 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13790 assert(attr_name != const_str_plain___dict__);
13791 assert(attr_name != const_str_plain___class__);
13794 PyObject *called_object =
13795 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13799 if (called_object != NULL) {
13800 return CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13804 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13808 if (called_object != NULL) {
13809 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13811 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13812 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
13814 }
else if (descr_get != NULL) {
13815 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13817 if (unlikely(method == NULL)) {
13821 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, method, args);
13825 return CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13828 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13829 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
13830 PyString_AS_STRING(source_instance->in_class->cl_name),
13831 PyString_AS_STRING(attr_name));
13838 PyObject *args2[] = {source, attr_name};
13840 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13842 if (unlikely(called_object == NULL)) {
13846 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13847 Py_DECREF(called_object);
13852 else if (type->tp_getattro != NULL) {
13853 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13855 if (unlikely(descr == NULL)) {
13859 descrgetfunc func = NULL;
13860 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13861 func = Py_TYPE(descr)->tp_descr_get;
13863 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13864 PyObject *called_object = func(descr, source, (PyObject *)type);
13867 if (unlikely(called_object == NULL)) {
13871 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13872 Py_DECREF(called_object);
13877 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, descr, args);
13880 }
else if (type->tp_getattr != NULL) {
13881 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
13883 if (unlikely(called_object == NULL)) {
13887 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13888 Py_DECREF(called_object);
13891 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13892 Nuitka_String_AsString_Unchecked(attr_name));
13897PyObject *CALL_METHOD_WITH_ARGS9(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13898 CHECK_OBJECT(source);
13899 CHECK_OBJECT(attr_name);
13901 CHECK_OBJECTS(args, 9);
13903 PyTypeObject *type = Py_TYPE(source);
13905 if (hasTypeGenericGetAttr(type)) {
13907 if (unlikely(type->tp_dict == NULL)) {
13908 if (unlikely(PyType_Ready(type) < 0)) {
13913 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13914 descrgetfunc func = NULL;
13916 if (descr != NULL) {
13919 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13920 func = Py_TYPE(descr)->tp_descr_get;
13922 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13923 PyObject *called_object = func(descr, source, (PyObject *)type);
13926 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
13927 Py_DECREF(called_object);
13933 Py_ssize_t dictoffset = type->tp_dictoffset;
13934 PyObject *dict = NULL;
13936 if (dictoffset != 0) {
13938 if (dictoffset < 0) {
13942 tsize = ((PyVarObject *)source)->ob_size;
13946 size = _PyObject_VAR_SIZE(type, tsize);
13948 dictoffset += (long)size;
13951 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13955 if (dict != NULL) {
13956 CHECK_OBJECT(dict);
13960 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13962 if (called_object != NULL) {
13966 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
13967 Py_DECREF(called_object);
13974 if (func != NULL) {
13975 if (func == Nuitka_Function_Type.tp_descr_get) {
13976 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13982 PyObject *called_object = func(descr, source, (PyObject *)type);
13983 CHECK_OBJECT(called_object);
13987 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
13988 Py_DECREF(called_object);
13993 if (descr != NULL) {
13994 CHECK_OBJECT(descr);
13996 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, descr, args);
14001#if PYTHON_VERSION < 0x300
14002 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
14003 PyString_AS_STRING(attr_name));
14005 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
14009#if PYTHON_VERSION < 0x300
14010 else if (type == &PyInstance_Type) {
14011 PyInstanceObject *source_instance = (PyInstanceObject *)source;
14015 assert(attr_name != const_str_plain___dict__);
14016 assert(attr_name != const_str_plain___class__);
14019 PyObject *called_object =
14020 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
14024 if (called_object != NULL) {
14025 return CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14029 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
14033 if (called_object != NULL) {
14034 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
14036 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
14037 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
14039 }
else if (descr_get != NULL) {
14040 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
14042 if (unlikely(method == NULL)) {
14046 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, method, args);
14050 return CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14053 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
14054 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
14055 PyString_AS_STRING(source_instance->in_class->cl_name),
14056 PyString_AS_STRING(attr_name));
14063 PyObject *args2[] = {source, attr_name};
14065 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
14067 if (unlikely(called_object == NULL)) {
14071 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14072 Py_DECREF(called_object);
14077 else if (type->tp_getattro != NULL) {
14078 PyObject *descr = (*type->tp_getattro)(source, attr_name);
14080 if (unlikely(descr == NULL)) {
14084 descrgetfunc func = NULL;
14085 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
14086 func = Py_TYPE(descr)->tp_descr_get;
14088 if (func != NULL && Nuitka_Descr_IsData(descr)) {
14089 PyObject *called_object = func(descr, source, (PyObject *)type);
14092 if (unlikely(called_object == NULL)) {
14096 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14097 Py_DECREF(called_object);
14102 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, descr, args);
14105 }
else if (type->tp_getattr != NULL) {
14106 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
14108 if (unlikely(called_object == NULL)) {
14112 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14113 Py_DECREF(called_object);
14116 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
14117 Nuitka_String_AsString_Unchecked(attr_name));
14122PyObject *CALL_METHOD_WITH_ARGS10(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
14123 CHECK_OBJECT(source);
14124 CHECK_OBJECT(attr_name);
14126 CHECK_OBJECTS(args, 10);
14128 PyTypeObject *type = Py_TYPE(source);
14130 if (hasTypeGenericGetAttr(type)) {
14132 if (unlikely(type->tp_dict == NULL)) {
14133 if (unlikely(PyType_Ready(type) < 0)) {
14138 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
14139 descrgetfunc func = NULL;
14141 if (descr != NULL) {
14144 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
14145 func = Py_TYPE(descr)->tp_descr_get;
14147 if (func != NULL && Nuitka_Descr_IsData(descr)) {
14148 PyObject *called_object = func(descr, source, (PyObject *)type);
14151 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14152 Py_DECREF(called_object);
14158 Py_ssize_t dictoffset = type->tp_dictoffset;
14159 PyObject *dict = NULL;
14161 if (dictoffset != 0) {
14163 if (dictoffset < 0) {
14167 tsize = ((PyVarObject *)source)->ob_size;
14171 size = _PyObject_VAR_SIZE(type, tsize);
14173 dictoffset += (long)size;
14176 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
14180 if (dict != NULL) {
14181 CHECK_OBJECT(dict);
14185 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
14187 if (called_object != NULL) {
14191 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14192 Py_DECREF(called_object);
14199 if (func != NULL) {
14200 if (func == Nuitka_Function_Type.tp_descr_get) {
14201 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
14207 PyObject *called_object = func(descr, source, (PyObject *)type);
14208 CHECK_OBJECT(called_object);
14212 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14213 Py_DECREF(called_object);
14218 if (descr != NULL) {
14219 CHECK_OBJECT(descr);
14221 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, descr, args);
14226#if PYTHON_VERSION < 0x300
14227 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
14228 PyString_AS_STRING(attr_name));
14230 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
14234#if PYTHON_VERSION < 0x300
14235 else if (type == &PyInstance_Type) {
14236 PyInstanceObject *source_instance = (PyInstanceObject *)source;
14240 assert(attr_name != const_str_plain___dict__);
14241 assert(attr_name != const_str_plain___class__);
14244 PyObject *called_object =
14245 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
14249 if (called_object != NULL) {
14250 return CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14254 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
14258 if (called_object != NULL) {
14259 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
14261 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
14262 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
14264 }
else if (descr_get != NULL) {
14265 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
14267 if (unlikely(method == NULL)) {
14271 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, method, args);
14275 return CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14278 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
14279 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
14280 PyString_AS_STRING(source_instance->in_class->cl_name),
14281 PyString_AS_STRING(attr_name));
14288 PyObject *args2[] = {source, attr_name};
14290 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
14292 if (unlikely(called_object == NULL)) {
14296 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14297 Py_DECREF(called_object);
14302 else if (type->tp_getattro != NULL) {
14303 PyObject *descr = (*type->tp_getattro)(source, attr_name);
14305 if (unlikely(descr == NULL)) {
14309 descrgetfunc func = NULL;
14310 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
14311 func = Py_TYPE(descr)->tp_descr_get;
14313 if (func != NULL && Nuitka_Descr_IsData(descr)) {
14314 PyObject *called_object = func(descr, source, (PyObject *)type);
14317 if (unlikely(called_object == NULL)) {
14321 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14322 Py_DECREF(called_object);
14327 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, descr, args);
14330 }
else if (type->tp_getattr != NULL) {
14331 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
14333 if (unlikely(called_object == NULL)) {
14337 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14338 Py_DECREF(called_object);
14341 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
14342 Nuitka_String_AsString_Unchecked(attr_name));
Definition compiled_function.h:22
Definition compiled_method.h:16