7#include "nuitka/prelude.h"
14#pragma clang diagnostic push
15#pragma clang diagnostic ignored "-Wparentheses-equality"
16#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
17#pragma GCC diagnostic push
18#pragma GCC diagnostic ignored "-Wparentheses"
21PyObject *CALL_FUNCTION_NO_ARGS(PyThreadState *tstate, PyObject *called) {
24 if (Nuitka_Function_Check(called)) {
25 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
32 if (function->m_args_simple && 0 == function->m_args_positional_count) {
33 result = function->m_c_code(tstate, function, NULL);
34 }
else if (function->m_args_simple && 0 + function->m_defaults_given == function->m_args_positional_count) {
35 PyObject **python_pars = &PyTuple_GET_ITEM(function->m_defaults, 0);
37 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
38 Py_INCREF(python_pars[i]);
41 result = function->m_c_code(tstate, function, python_pars);
43 result = Nuitka_CallFunctionNoArgs(tstate, function);
46 Py_LeaveRecursiveCall();
48 CHECK_OBJECT_X(result);
51 }
else if (Nuitka_Method_Check(called)) {
54 if (method->m_object == NULL) {
57 "unbound compiled_method %s%s must be called with %s instance as first argument (got nothing instead)",
58 GET_CALLABLE_NAME((PyObject *)method->m_function), GET_CALLABLE_DESC((PyObject *)method->m_function),
59 GET_CLASS_NAME(method->m_class));
62 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
70 if (function->m_args_simple && 0 + 1 == function->m_args_positional_count) {
71 PyObject *python_pars[0 + 1];
73 python_pars[0] = method->m_object;
74 Py_INCREF(method->m_object);
76 result = function->m_c_code(tstate, function, python_pars);
77 }
else if (function->m_args_simple &&
78 0 + 1 + function->m_defaults_given == function->m_args_positional_count) {
79 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
81 python_pars[0] = method->m_object;
82 Py_INCREF(method->m_object);
84 memcpy(python_pars + 1 + 0, &PyTuple_GET_ITEM(function->m_defaults, 0),
85 function->m_defaults_given *
sizeof(PyObject *));
87 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
88 Py_INCREF(python_pars[i]);
91 result = function->m_c_code(tstate, function, python_pars);
93 result = Nuitka_CallMethodFunctionNoArgs(tstate, function, method->m_object);
96 Py_LeaveRecursiveCall();
98 CHECK_OBJECT_X(result);
102#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
103 }
else if (PyCFunction_CheckExact(called)) {
104#if PYTHON_VERSION >= 0x380
105#ifdef _NUITKA_FULL_COMPAT
106 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
111 int flags = PyCFunction_GET_FLAGS(called);
115 if (!(flags & METH_VARARGS)) {
116 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
118 assert(func != NULL);
119 result = func(called, NULL, 0, NULL);
121 CHECK_OBJECT_X(result);
123 PyCFunction method = PyCFunction_GET_FUNCTION(called);
124 PyObject *self = PyCFunction_GET_SELF(called);
126 PyObject *pos_args = const_tuple_empty;
128 if (flags & METH_KEYWORDS) {
129 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
131 result = (*method)(self, pos_args);
135#ifdef _NUITKA_FULL_COMPAT
136 Py_LeaveRecursiveCall();
138 CHECK_OBJECT_X(result);
140 return Nuitka_CheckFunctionResult(tstate, called, result);
143 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
145 if (likely(flags & METH_NOARGS)) {
148#ifdef _NUITKA_FULL_COMPAT
149 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
153 PyCFunction method = PyCFunction_GET_FUNCTION(called);
154 PyObject *self = PyCFunction_GET_SELF(called);
156 PyObject *result = (*method)(self, NULL);
158#ifdef _NUITKA_FULL_COMPAT
159 Py_LeaveRecursiveCall();
161 CHECK_OBJECT_X(result);
163 return Nuitka_CheckFunctionResult(tstate, called, result);
164 }
else if (unlikely(flags & METH_O)) {
165 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (0 given)",
166 ((PyCFunctionObject *)called)->m_ml->ml_name);
168 }
else if (flags & METH_VARARGS) {
171#ifdef _NUITKA_FULL_COMPAT
172 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
176 PyCFunction method = PyCFunction_GET_FUNCTION(called);
177 PyObject *self = PyCFunction_GET_SELF(called);
181#if PYTHON_VERSION < 0x360
182 PyObject *pos_args = const_tuple_empty;
183 if (flags & METH_KEYWORDS) {
184 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
186 result = (*method)(self, pos_args);
190 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
191 PyObject *pos_args = const_tuple_empty;
192 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
193 }
else if (flags == METH_FASTCALL) {
194#if PYTHON_VERSION < 0x370
195 result = (*(_PyCFunctionFast)method)(self, NULL, 0, NULL);
197 PyObject *pos_args = const_tuple_empty;
198 result = (*(_PyCFunctionFast)method)(self, &pos_args, 0);
201 PyObject *pos_args = const_tuple_empty;
202 result = (*method)(self, pos_args);
206#ifdef _NUITKA_FULL_COMPAT
207 Py_LeaveRecursiveCall();
210 CHECK_OBJECT_X(result);
212 return Nuitka_CheckFunctionResult(tstate, called, result);
216#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
217 }
else if (PyFunction_Check(called)) {
218#if PYTHON_VERSION < 0x3b0
219 PyObject *result = callPythonFunctionNoArgs(called);
221 PyObject *result = _PyFunction_Vectorcall(called, NULL, 0, NULL);
223 CHECK_OBJECT_X(result);
227#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
228 }
else if (PyType_Check(called)) {
229 PyTypeObject *type = Py_TYPE(called);
231 if (type->tp_call == PyType_Type.tp_call) {
232 PyTypeObject *called_type = (PyTypeObject *)(called);
234 if (unlikely(called_type->tp_new == NULL)) {
235 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
239 PyObject *pos_args = const_tuple_empty;
242 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
243 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
244 formatCannotInstantiateAbstractClass(tstate, called_type);
248 obj = called_type->tp_alloc(called_type, 0);
251 obj = called_type->tp_new(called_type, pos_args, NULL);
254 if (likely(obj != NULL)) {
255 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
262 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
263 if (type->tp_init == default_tp_init_wrapper) {
265 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
268 assert(init_method != NULL);
270 bool is_compiled_function =
false;
271 bool init_method_needs_release =
false;
273 if (likely(init_method != NULL)) {
274 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
276 if (func == Nuitka_Function_Type.tp_descr_get) {
277 is_compiled_function =
true;
278 }
else if (func != NULL) {
279 init_method = func(init_method, obj, (PyObject *)(type));
280 init_method_needs_release =
true;
284 if (unlikely(init_method == NULL)) {
285 if (!HAS_ERROR_OCCURRED(tstate)) {
286 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
287 const_str_plain___init__);
294 if (is_compiled_function) {
295 result = Nuitka_CallMethodFunctionNoArgs(
298 result = CALL_FUNCTION_NO_ARGS(tstate, init_method);
300 if (init_method_needs_release) {
301 Py_DECREF(init_method);
305 if (unlikely(result == NULL)) {
312 if (unlikely(result != Py_None)) {
315 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
320 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
333#if PYTHON_VERSION < 0x300
334 }
else if (PyClass_Check(called)) {
335 PyObject *obj = PyInstance_NewRaw(called, NULL);
337 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
339 if ((init_method == NULL)) {
340 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
348 bool is_compiled_function =
false;
350 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
352 if (descr_get == NULL) {
353 Py_INCREF(init_method);
354 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
355 is_compiled_function =
true;
356 }
else if (descr_get != NULL) {
357 PyObject *descr_method = descr_get(init_method, obj, called);
359 if (unlikely(descr_method == NULL)) {
363 init_method = descr_method;
367 if (is_compiled_function) {
368 result = Nuitka_CallMethodFunctionNoArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj);
370 result = CALL_FUNCTION_NO_ARGS(tstate, init_method);
371 Py_DECREF(init_method);
373 if (unlikely(result == NULL)) {
379 if (unlikely(result != Py_None)) {
380 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
388#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
389 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
390 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
392 if (likely(func != NULL)) {
393 PyObject *result = func(called, NULL, 0, NULL);
395 CHECK_OBJECT_X(result);
397 return Nuitka_CheckFunctionResult(tstate, called, result);
404 PRINT_STRING(
"FALLBACK");
409 PyObject *result = CALL_FUNCTION(tstate, called, const_tuple_empty, NULL);
411 CHECK_OBJECT_X(result);
415PyObject *CALL_FUNCTION_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *called, PyObject *arg) {
416 PyObject *
const *args = &arg;
417 CHECK_OBJECT(called);
418 CHECK_OBJECTS(args, 1);
420 if (Nuitka_Function_Check(called)) {
421 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
428 if (function->m_args_simple && 1 == function->m_args_positional_count) {
430 result = function->m_c_code(tstate, function, (PyObject **)args);
431 }
else if (function->m_args_simple && 1 + function->m_defaults_given == function->m_args_positional_count) {
432 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
434 memcpy(python_pars, args, 1 *
sizeof(PyObject *));
435 memcpy(python_pars + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
436 function->m_defaults_given *
sizeof(PyObject *));
438 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
439 Py_INCREF(python_pars[i]);
442 result = function->m_c_code(tstate, function, python_pars);
444 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 1);
447 Py_LeaveRecursiveCall();
449 CHECK_OBJECT_X(result);
452 }
else if (Nuitka_Method_Check(called)) {
455 if (method->m_object == NULL) {
456 PyObject *self = args[0];
458 int res = PyObject_IsInstance(self, method->m_class);
460 if (unlikely(res < 0)) {
462 }
else if (unlikely(res == 0)) {
463 PyErr_Format(PyExc_TypeError,
464 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
466 GET_CALLABLE_NAME((PyObject *)method->m_function),
467 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
468 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
473 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 1);
475 CHECK_OBJECT_X(result);
479 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
487 if (function->m_args_simple && 1 + 1 == function->m_args_positional_count) {
488 PyObject *python_pars[1 + 1];
490 python_pars[0] = method->m_object;
491 Py_INCREF(method->m_object);
493 python_pars[1] = args[0];
495 result = function->m_c_code(tstate, function, python_pars);
496 }
else if (function->m_args_simple &&
497 1 + 1 + function->m_defaults_given == function->m_args_positional_count) {
498 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
500 python_pars[0] = method->m_object;
501 Py_INCREF(method->m_object);
503 memcpy(python_pars + 1, args, 1 *
sizeof(PyObject *));
504 memcpy(python_pars + 1 + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
505 function->m_defaults_given *
sizeof(PyObject *));
507 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
508 Py_INCREF(python_pars[i]);
511 result = function->m_c_code(tstate, function, python_pars);
513 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 1);
516 Py_LeaveRecursiveCall();
518 CHECK_OBJECT_X(result);
522#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
523 }
else if (PyCFunction_CheckExact(called)) {
524#if PYTHON_VERSION >= 0x380
525#ifdef _NUITKA_FULL_COMPAT
526 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
531 int flags = PyCFunction_GET_FLAGS(called);
535 if (!(flags & METH_VARARGS)) {
536 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
538 assert(func != NULL);
539 result = func(called, args, 1, NULL);
541 CHECK_OBJECT_X(result);
543 PyCFunction method = PyCFunction_GET_FUNCTION(called);
544 PyObject *self = PyCFunction_GET_SELF(called);
546 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
548 if (flags & METH_KEYWORDS) {
549 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
551 result = (*method)(self, pos_args);
557#ifdef _NUITKA_FULL_COMPAT
558 Py_LeaveRecursiveCall();
560 CHECK_OBJECT_X(result);
562 return Nuitka_CheckFunctionResult(tstate, called, result);
565 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
567 if (unlikely(flags & METH_NOARGS)) {
568 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (1 given)",
569 ((PyCFunctionObject *)called)->m_ml->ml_name);
571 }
else if ((flags & METH_O)) {
574#ifdef _NUITKA_FULL_COMPAT
575 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
579 PyCFunction method = PyCFunction_GET_FUNCTION(called);
580 PyObject *self = PyCFunction_GET_SELF(called);
582 PyObject *result = (*method)(self, args[0]);
584#ifdef _NUITKA_FULL_COMPAT
585 Py_LeaveRecursiveCall();
588 CHECK_OBJECT_X(result);
590 return Nuitka_CheckFunctionResult(tstate, called, result);
591 }
else if (flags & METH_VARARGS) {
594#ifdef _NUITKA_FULL_COMPAT
595 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
599 PyCFunction method = PyCFunction_GET_FUNCTION(called);
600 PyObject *self = PyCFunction_GET_SELF(called);
604#if PYTHON_VERSION < 0x360
605 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
606 if (flags & METH_KEYWORDS) {
607 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
609 result = (*method)(self, pos_args);
614 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
615 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
616 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
618 }
else if (flags == METH_FASTCALL) {
619#if PYTHON_VERSION < 0x370
620 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 1, NULL);
622 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
623 result = (*(_PyCFunctionFast)method)(self, &pos_args, 1);
627 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
628 result = (*method)(self, pos_args);
633#ifdef _NUITKA_FULL_COMPAT
634 Py_LeaveRecursiveCall();
637 CHECK_OBJECT_X(result);
639 return Nuitka_CheckFunctionResult(tstate, called, result);
643#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
644 }
else if (PyFunction_Check(called)) {
645#if PYTHON_VERSION < 0x3b0
646 PyObject *result = callPythonFunction(called, args, 1);
648 PyObject *result = _PyFunction_Vectorcall(called, args, 1, NULL);
650 CHECK_OBJECT_X(result);
654#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
655 }
else if (PyType_Check(called)) {
656 PyTypeObject *type = Py_TYPE(called);
658 if (type->tp_call == PyType_Type.tp_call) {
659 PyTypeObject *called_type = (PyTypeObject *)(called);
661 if (unlikely(called == (PyObject *)&PyType_Type)) {
662 PyObject *result = (PyObject *)Py_TYPE(args[0]);
667 if (unlikely(called_type->tp_new == NULL)) {
668 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
672 PyObject *pos_args = NULL;
675 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
676 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
677 formatCannotInstantiateAbstractClass(tstate, called_type);
681 obj = called_type->tp_alloc(called_type, 0);
684 pos_args = MAKE_TUPLE(tstate, args, 1);
685 obj = called_type->tp_new(called_type, pos_args, NULL);
688 if (likely(obj != NULL)) {
689 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
697 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
698 if (type->tp_init == default_tp_init_wrapper) {
699 Py_XDECREF(pos_args);
702 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
705 assert(init_method != NULL);
707 bool is_compiled_function =
false;
708 bool init_method_needs_release =
false;
710 if (likely(init_method != NULL)) {
711 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
713 if (func == Nuitka_Function_Type.tp_descr_get) {
714 is_compiled_function =
true;
715 }
else if (func != NULL) {
716 init_method = func(init_method, obj, (PyObject *)(type));
717 init_method_needs_release =
true;
721 if (unlikely(init_method == NULL)) {
722 if (!HAS_ERROR_OCCURRED(tstate)) {
723 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
724 const_str_plain___init__);
731 if (is_compiled_function) {
732 result = Nuitka_CallMethodFunctionPosArgs(
735 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
737 if (init_method_needs_release) {
738 Py_DECREF(init_method);
742 if (unlikely(result == NULL)) {
749 if (unlikely(result != Py_None)) {
752 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
756 if (pos_args == NULL) {
757 pos_args = MAKE_TUPLE(tstate, args, 1);
760 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
762 Py_XDECREF(pos_args);
769 Py_XDECREF(pos_args);
776#if PYTHON_VERSION < 0x300
777 }
else if (PyClass_Check(called)) {
778 PyObject *obj = PyInstance_NewRaw(called, NULL);
780 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
782 if (unlikely(init_method == NULL)) {
783 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
790 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
794 bool is_compiled_function =
false;
796 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
798 if (descr_get == NULL) {
799 Py_INCREF(init_method);
800 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
801 is_compiled_function =
true;
802 }
else if (descr_get != NULL) {
803 PyObject *descr_method = descr_get(init_method, obj, called);
805 if (unlikely(descr_method == NULL)) {
809 init_method = descr_method;
813 if (is_compiled_function) {
814 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
817 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
818 Py_DECREF(init_method);
820 if (unlikely(result == NULL)) {
826 if (unlikely(result != Py_None)) {
827 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
835#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
836 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
837 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
839 if (likely(func != NULL)) {
840 PyObject *result = func(called, args, 1, NULL);
842 CHECK_OBJECT_X(result);
844 return Nuitka_CheckFunctionResult(tstate, called, result);
851 PRINT_STRING(
"FALLBACK");
856 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
858 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
862 CHECK_OBJECT_X(result);
866PyObject *CALL_FUNCTION_WITH_POS_ARGS1(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
867 assert(PyTuple_CheckExact(pos_args));
868 assert(PyTuple_GET_SIZE(pos_args) == 1);
869 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
870 CHECK_OBJECT(called);
871 CHECK_OBJECTS(args, 1);
873 if (Nuitka_Function_Check(called)) {
874 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
881 if (function->m_args_simple && 1 == function->m_args_positional_count) {
883 result = function->m_c_code(tstate, function, (PyObject **)args);
884 }
else if (function->m_args_simple && 1 + function->m_defaults_given == function->m_args_positional_count) {
885 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
887 memcpy(python_pars, args, 1 *
sizeof(PyObject *));
888 memcpy(python_pars + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
889 function->m_defaults_given *
sizeof(PyObject *));
891 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
892 Py_INCREF(python_pars[i]);
895 result = function->m_c_code(tstate, function, python_pars);
897 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 1);
900 Py_LeaveRecursiveCall();
902 CHECK_OBJECT_X(result);
905 }
else if (Nuitka_Method_Check(called)) {
908 if (method->m_object == NULL) {
909 PyObject *self = args[0];
911 int res = PyObject_IsInstance(self, method->m_class);
913 if (unlikely(res < 0)) {
915 }
else if (unlikely(res == 0)) {
916 PyErr_Format(PyExc_TypeError,
917 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
919 GET_CALLABLE_NAME((PyObject *)method->m_function),
920 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
921 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
926 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 1);
928 CHECK_OBJECT_X(result);
932 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
940 if (function->m_args_simple && 1 + 1 == function->m_args_positional_count) {
941 PyObject *python_pars[1 + 1];
943 python_pars[0] = method->m_object;
944 Py_INCREF(method->m_object);
946 python_pars[1] = args[0];
948 result = function->m_c_code(tstate, function, python_pars);
949 }
else if (function->m_args_simple &&
950 1 + 1 + function->m_defaults_given == function->m_args_positional_count) {
951 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
953 python_pars[0] = method->m_object;
954 Py_INCREF(method->m_object);
956 memcpy(python_pars + 1, args, 1 *
sizeof(PyObject *));
957 memcpy(python_pars + 1 + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
958 function->m_defaults_given *
sizeof(PyObject *));
960 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
961 Py_INCREF(python_pars[i]);
964 result = function->m_c_code(tstate, function, python_pars);
966 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 1);
969 Py_LeaveRecursiveCall();
971 CHECK_OBJECT_X(result);
975#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
976 }
else if (PyCFunction_CheckExact(called)) {
977#if PYTHON_VERSION >= 0x380
978#ifdef _NUITKA_FULL_COMPAT
979 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
984 int flags = PyCFunction_GET_FLAGS(called);
988 if (!(flags & METH_VARARGS)) {
989 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
991 assert(func != NULL);
992 result = func(called, args, 1, NULL);
994 CHECK_OBJECT_X(result);
996 PyCFunction method = PyCFunction_GET_FUNCTION(called);
997 PyObject *self = PyCFunction_GET_SELF(called);
999 if (flags & METH_KEYWORDS) {
1000 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
1002 result = (*method)(self, pos_args);
1006#ifdef _NUITKA_FULL_COMPAT
1007 Py_LeaveRecursiveCall();
1009 CHECK_OBJECT_X(result);
1011 return Nuitka_CheckFunctionResult(tstate, called, result);
1014 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
1016 if (unlikely(flags & METH_NOARGS)) {
1017 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (1 given)",
1018 ((PyCFunctionObject *)called)->m_ml->ml_name);
1020 }
else if ((flags & METH_O)) {
1023#ifdef _NUITKA_FULL_COMPAT
1024 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1028 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1029 PyObject *self = PyCFunction_GET_SELF(called);
1031 PyObject *result = (*method)(self, args[0]);
1033#ifdef _NUITKA_FULL_COMPAT
1034 Py_LeaveRecursiveCall();
1037 CHECK_OBJECT_X(result);
1039 return Nuitka_CheckFunctionResult(tstate, called, result);
1040 }
else if (flags & METH_VARARGS) {
1043#ifdef _NUITKA_FULL_COMPAT
1044 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1048 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1049 PyObject *self = PyCFunction_GET_SELF(called);
1053#if PYTHON_VERSION < 0x360
1054 if (flags & METH_KEYWORDS) {
1055 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1057 result = (*method)(self, pos_args);
1061 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
1062 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1063 }
else if (flags == METH_FASTCALL) {
1064#if PYTHON_VERSION < 0x370
1065 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 1, NULL);
1067 result = (*(_PyCFunctionFast)method)(self, &pos_args, 1);
1070 result = (*method)(self, pos_args);
1074#ifdef _NUITKA_FULL_COMPAT
1075 Py_LeaveRecursiveCall();
1078 CHECK_OBJECT_X(result);
1080 return Nuitka_CheckFunctionResult(tstate, called, result);
1084#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
1085 }
else if (PyFunction_Check(called)) {
1086#if PYTHON_VERSION < 0x3b0
1087 PyObject *result = callPythonFunction(called, args, 1);
1089 PyObject *result = _PyFunction_Vectorcall(called, args, 1, NULL);
1091 CHECK_OBJECT_X(result);
1095#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
1096 }
else if (PyType_Check(called)) {
1097 PyTypeObject *type = Py_TYPE(called);
1099 if (type->tp_call == PyType_Type.tp_call) {
1100 PyTypeObject *called_type = (PyTypeObject *)(called);
1102 if (unlikely(called == (PyObject *)&PyType_Type)) {
1103 PyObject *result = (PyObject *)Py_TYPE(args[0]);
1108 if (unlikely(called_type->tp_new == NULL)) {
1109 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
1115 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
1116 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
1117 formatCannotInstantiateAbstractClass(tstate, called_type);
1121 obj = called_type->tp_alloc(called_type, 0);
1124 obj = called_type->tp_new(called_type, pos_args, NULL);
1127 if (likely(obj != NULL)) {
1128 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
1133 type = Py_TYPE(obj);
1135 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
1136 if (type->tp_init == default_tp_init_wrapper) {
1138 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
1141 assert(init_method != NULL);
1143 bool is_compiled_function =
false;
1144 bool init_method_needs_release =
false;
1146 if (likely(init_method != NULL)) {
1147 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
1149 if (func == Nuitka_Function_Type.tp_descr_get) {
1150 is_compiled_function =
true;
1151 }
else if (func != NULL) {
1152 init_method = func(init_method, obj, (PyObject *)(type));
1153 init_method_needs_release =
true;
1157 if (unlikely(init_method == NULL)) {
1158 if (!HAS_ERROR_OCCURRED(tstate)) {
1159 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
1160 const_str_plain___init__);
1167 if (is_compiled_function) {
1168 result = Nuitka_CallMethodFunctionPosArgs(
1171 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
1173 if (init_method_needs_release) {
1174 Py_DECREF(init_method);
1178 if (unlikely(result == NULL)) {
1185 if (unlikely(result != Py_None)) {
1188 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
1193 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
1201 CHECK_OBJECT_X(obj);
1206#if PYTHON_VERSION < 0x300
1207 }
else if (PyClass_Check(called)) {
1208 PyObject *obj = PyInstance_NewRaw(called, NULL);
1210 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
1212 if (unlikely(init_method == NULL)) {
1213 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
1220 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
1224 bool is_compiled_function =
false;
1226 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
1228 if (descr_get == NULL) {
1229 Py_INCREF(init_method);
1230 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
1231 is_compiled_function =
true;
1232 }
else if (descr_get != NULL) {
1233 PyObject *descr_method = descr_get(init_method, obj, called);
1235 if (unlikely(descr_method == NULL)) {
1239 init_method = descr_method;
1243 if (is_compiled_function) {
1244 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
1247 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
1248 Py_DECREF(init_method);
1250 if (unlikely(result == NULL)) {
1256 if (unlikely(result != Py_None)) {
1257 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
1261 CHECK_OBJECT_X(obj);
1265#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
1266 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
1267 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1269 if (likely(func != NULL)) {
1270 PyObject *result = func(called, args, 1, NULL);
1272 CHECK_OBJECT_X(result);
1274 return Nuitka_CheckFunctionResult(tstate, called, result);
1281 PRINT_STRING(
"FALLBACK");
1286 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
1288 CHECK_OBJECT_X(result);
1292PyObject *CALL_FUNCTION_WITH_ARGS2(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
1293 CHECK_OBJECT(called);
1294 CHECK_OBJECTS(args, 2);
1296 if (Nuitka_Function_Check(called)) {
1297 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1304 if (function->m_args_simple && 2 == function->m_args_positional_count) {
1305 for (Py_ssize_t i = 0; i < 2; i++) {
1308 result = function->m_c_code(tstate, function, (PyObject **)args);
1309 }
else if (function->m_args_simple && 2 + function->m_defaults_given == function->m_args_positional_count) {
1310 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1312 memcpy(python_pars, args, 2 *
sizeof(PyObject *));
1313 memcpy(python_pars + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1314 function->m_defaults_given *
sizeof(PyObject *));
1316 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
1317 Py_INCREF(python_pars[i]);
1320 result = function->m_c_code(tstate, function, python_pars);
1322 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 2);
1325 Py_LeaveRecursiveCall();
1327 CHECK_OBJECT_X(result);
1330 }
else if (Nuitka_Method_Check(called)) {
1333 if (method->m_object == NULL) {
1334 PyObject *self = args[0];
1336 int res = PyObject_IsInstance(self, method->m_class);
1338 if (unlikely(res < 0)) {
1340 }
else if (unlikely(res == 0)) {
1341 PyErr_Format(PyExc_TypeError,
1342 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
1343 "instance instead)",
1344 GET_CALLABLE_NAME((PyObject *)method->m_function),
1345 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
1346 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
1351 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 2);
1353 CHECK_OBJECT_X(result);
1357 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1365 if (function->m_args_simple && 2 + 1 == function->m_args_positional_count) {
1366 PyObject *python_pars[2 + 1];
1368 python_pars[0] = method->m_object;
1369 Py_INCREF(method->m_object);
1371 for (Py_ssize_t i = 0; i < 2; i++) {
1372 python_pars[i + 1] = args[i];
1375 result = function->m_c_code(tstate, function, python_pars);
1376 }
else if (function->m_args_simple &&
1377 2 + 1 + function->m_defaults_given == function->m_args_positional_count) {
1378 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1380 python_pars[0] = method->m_object;
1381 Py_INCREF(method->m_object);
1383 memcpy(python_pars + 1, args, 2 *
sizeof(PyObject *));
1384 memcpy(python_pars + 1 + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1385 function->m_defaults_given *
sizeof(PyObject *));
1387 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
1388 Py_INCREF(python_pars[i]);
1391 result = function->m_c_code(tstate, function, python_pars);
1393 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 2);
1396 Py_LeaveRecursiveCall();
1398 CHECK_OBJECT_X(result);
1402#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
1403 }
else if (PyCFunction_CheckExact(called)) {
1404#if PYTHON_VERSION >= 0x380
1405#ifdef _NUITKA_FULL_COMPAT
1406 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1411 int flags = PyCFunction_GET_FLAGS(called);
1415 if (!(flags & METH_VARARGS)) {
1416 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1418 assert(func != NULL);
1419 result = func(called, args, 2, NULL);
1421 CHECK_OBJECT_X(result);
1423 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1424 PyObject *self = PyCFunction_GET_SELF(called);
1426 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1428 if (flags & METH_KEYWORDS) {
1429 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
1431 result = (*method)(self, pos_args);
1434 Py_DECREF(pos_args);
1437#ifdef _NUITKA_FULL_COMPAT
1438 Py_LeaveRecursiveCall();
1440 CHECK_OBJECT_X(result);
1442 return Nuitka_CheckFunctionResult(tstate, called, result);
1445 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
1447 if (unlikely(flags & METH_NOARGS)) {
1448 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (2 given)",
1449 ((PyCFunctionObject *)called)->m_ml->ml_name);
1451 }
else if (unlikely(flags & METH_O)) {
1452 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (2 given)",
1453 ((PyCFunctionObject *)called)->m_ml->ml_name);
1455 }
else if (flags & METH_VARARGS) {
1458#ifdef _NUITKA_FULL_COMPAT
1459 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1463 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1464 PyObject *self = PyCFunction_GET_SELF(called);
1468#if PYTHON_VERSION < 0x360
1469 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1470 if (flags & METH_KEYWORDS) {
1471 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1473 result = (*method)(self, pos_args);
1476 Py_DECREF(pos_args);
1478 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
1479 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1480 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1481 Py_DECREF(pos_args);
1482 }
else if (flags == METH_FASTCALL) {
1483#if PYTHON_VERSION < 0x370
1484 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 2, NULL);
1486 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1487 result = (*(_PyCFunctionFast)method)(self, &pos_args, 2);
1488 Py_DECREF(pos_args);
1491 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1492 result = (*method)(self, pos_args);
1493 Py_DECREF(pos_args);
1497#ifdef _NUITKA_FULL_COMPAT
1498 Py_LeaveRecursiveCall();
1501 CHECK_OBJECT_X(result);
1503 return Nuitka_CheckFunctionResult(tstate, called, result);
1507#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
1508 }
else if (PyFunction_Check(called)) {
1509#if PYTHON_VERSION < 0x3b0
1510 PyObject *result = callPythonFunction(called, args, 2);
1512 PyObject *result = _PyFunction_Vectorcall(called, args, 2, NULL);
1514 CHECK_OBJECT_X(result);
1518#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
1519 }
else if (PyType_Check(called)) {
1520 PyTypeObject *type = Py_TYPE(called);
1522 if (type->tp_call == PyType_Type.tp_call) {
1523 PyTypeObject *called_type = (PyTypeObject *)(called);
1525 if (unlikely(called_type->tp_new == NULL)) {
1526 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
1530 PyObject *pos_args = NULL;
1533 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
1534 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
1535 formatCannotInstantiateAbstractClass(tstate, called_type);
1539 obj = called_type->tp_alloc(called_type, 0);
1542 pos_args = MAKE_TUPLE(tstate, args, 2);
1543 obj = called_type->tp_new(called_type, pos_args, NULL);
1546 if (likely(obj != NULL)) {
1547 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
1548 Py_DECREF(pos_args);
1553 type = Py_TYPE(obj);
1555 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
1556 if (type->tp_init == default_tp_init_wrapper) {
1557 Py_XDECREF(pos_args);
1560 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
1563 assert(init_method != NULL);
1565 bool is_compiled_function =
false;
1566 bool init_method_needs_release =
false;
1568 if (likely(init_method != NULL)) {
1569 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
1571 if (func == Nuitka_Function_Type.tp_descr_get) {
1572 is_compiled_function =
true;
1573 }
else if (func != NULL) {
1574 init_method = func(init_method, obj, (PyObject *)(type));
1575 init_method_needs_release =
true;
1579 if (unlikely(init_method == NULL)) {
1580 if (!HAS_ERROR_OCCURRED(tstate)) {
1581 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
1582 const_str_plain___init__);
1589 if (is_compiled_function) {
1590 result = Nuitka_CallMethodFunctionPosArgs(
1593 result = CALL_FUNCTION_WITH_ARGS2(tstate, init_method, args);
1594 if (init_method_needs_release) {
1595 Py_DECREF(init_method);
1599 if (unlikely(result == NULL)) {
1606 if (unlikely(result != Py_None)) {
1609 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
1613 if (pos_args == NULL) {
1614 pos_args = MAKE_TUPLE(tstate, args, 2);
1617 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
1619 Py_XDECREF(pos_args);
1626 Py_XDECREF(pos_args);
1628 CHECK_OBJECT_X(obj);
1633#if PYTHON_VERSION < 0x300
1634 }
else if (PyClass_Check(called)) {
1635 PyObject *obj = PyInstance_NewRaw(called, NULL);
1637 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
1639 if (unlikely(init_method == NULL)) {
1640 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
1647 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
1651 bool is_compiled_function =
false;
1653 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
1655 if (descr_get == NULL) {
1656 Py_INCREF(init_method);
1657 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
1658 is_compiled_function =
true;
1659 }
else if (descr_get != NULL) {
1660 PyObject *descr_method = descr_get(init_method, obj, called);
1662 if (unlikely(descr_method == NULL)) {
1666 init_method = descr_method;
1670 if (is_compiled_function) {
1671 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
1674 result = CALL_FUNCTION_WITH_ARGS2(tstate, init_method, args);
1675 Py_DECREF(init_method);
1677 if (unlikely(result == NULL)) {
1683 if (unlikely(result != Py_None)) {
1684 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
1688 CHECK_OBJECT_X(obj);
1692#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
1693 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
1694 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1696 if (likely(func != NULL)) {
1697 PyObject *result = func(called, args, 2, NULL);
1699 CHECK_OBJECT_X(result);
1701 return Nuitka_CheckFunctionResult(tstate, called, result);
1708 PRINT_STRING(
"FALLBACK");
1713 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1715 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
1717 Py_DECREF(pos_args);
1719 CHECK_OBJECT_X(result);
1723PyObject *CALL_FUNCTION_WITH_POS_ARGS2(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
1724 assert(PyTuple_CheckExact(pos_args));
1725 assert(PyTuple_GET_SIZE(pos_args) == 2);
1726 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
1727 CHECK_OBJECT(called);
1728 CHECK_OBJECTS(args, 2);
1730 if (Nuitka_Function_Check(called)) {
1731 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1738 if (function->m_args_simple && 2 == function->m_args_positional_count) {
1739 for (Py_ssize_t i = 0; i < 2; i++) {
1742 result = function->m_c_code(tstate, function, (PyObject **)args);
1743 }
else if (function->m_args_simple && 2 + function->m_defaults_given == function->m_args_positional_count) {
1744 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1746 memcpy(python_pars, args, 2 *
sizeof(PyObject *));
1747 memcpy(python_pars + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1748 function->m_defaults_given *
sizeof(PyObject *));
1750 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
1751 Py_INCREF(python_pars[i]);
1754 result = function->m_c_code(tstate, function, python_pars);
1756 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 2);
1759 Py_LeaveRecursiveCall();
1761 CHECK_OBJECT_X(result);
1764 }
else if (Nuitka_Method_Check(called)) {
1767 if (method->m_object == NULL) {
1768 PyObject *self = args[0];
1770 int res = PyObject_IsInstance(self, method->m_class);
1772 if (unlikely(res < 0)) {
1774 }
else if (unlikely(res == 0)) {
1775 PyErr_Format(PyExc_TypeError,
1776 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
1777 "instance instead)",
1778 GET_CALLABLE_NAME((PyObject *)method->m_function),
1779 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
1780 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
1785 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 2);
1787 CHECK_OBJECT_X(result);
1791 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1799 if (function->m_args_simple && 2 + 1 == function->m_args_positional_count) {
1800 PyObject *python_pars[2 + 1];
1802 python_pars[0] = method->m_object;
1803 Py_INCREF(method->m_object);
1805 for (Py_ssize_t i = 0; i < 2; i++) {
1806 python_pars[i + 1] = args[i];
1809 result = function->m_c_code(tstate, function, python_pars);
1810 }
else if (function->m_args_simple &&
1811 2 + 1 + function->m_defaults_given == function->m_args_positional_count) {
1812 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1814 python_pars[0] = method->m_object;
1815 Py_INCREF(method->m_object);
1817 memcpy(python_pars + 1, args, 2 *
sizeof(PyObject *));
1818 memcpy(python_pars + 1 + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1819 function->m_defaults_given *
sizeof(PyObject *));
1821 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
1822 Py_INCREF(python_pars[i]);
1825 result = function->m_c_code(tstate, function, python_pars);
1827 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 2);
1830 Py_LeaveRecursiveCall();
1832 CHECK_OBJECT_X(result);
1836#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
1837 }
else if (PyCFunction_CheckExact(called)) {
1838#if PYTHON_VERSION >= 0x380
1839#ifdef _NUITKA_FULL_COMPAT
1840 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1845 int flags = PyCFunction_GET_FLAGS(called);
1849 if (!(flags & METH_VARARGS)) {
1850 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1852 assert(func != NULL);
1853 result = func(called, args, 2, NULL);
1855 CHECK_OBJECT_X(result);
1857 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1858 PyObject *self = PyCFunction_GET_SELF(called);
1860 if (flags & METH_KEYWORDS) {
1861 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
1863 result = (*method)(self, pos_args);
1867#ifdef _NUITKA_FULL_COMPAT
1868 Py_LeaveRecursiveCall();
1870 CHECK_OBJECT_X(result);
1872 return Nuitka_CheckFunctionResult(tstate, called, result);
1875 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
1877 if (unlikely(flags & METH_NOARGS)) {
1878 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (2 given)",
1879 ((PyCFunctionObject *)called)->m_ml->ml_name);
1881 }
else if (unlikely(flags & METH_O)) {
1882 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (2 given)",
1883 ((PyCFunctionObject *)called)->m_ml->ml_name);
1885 }
else if (flags & METH_VARARGS) {
1888#ifdef _NUITKA_FULL_COMPAT
1889 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1893 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1894 PyObject *self = PyCFunction_GET_SELF(called);
1898#if PYTHON_VERSION < 0x360
1899 if (flags & METH_KEYWORDS) {
1900 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1902 result = (*method)(self, pos_args);
1906 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
1907 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1908 }
else if (flags == METH_FASTCALL) {
1909#if PYTHON_VERSION < 0x370
1910 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 2, NULL);
1912 result = (*(_PyCFunctionFast)method)(self, &pos_args, 2);
1915 result = (*method)(self, pos_args);
1919#ifdef _NUITKA_FULL_COMPAT
1920 Py_LeaveRecursiveCall();
1923 CHECK_OBJECT_X(result);
1925 return Nuitka_CheckFunctionResult(tstate, called, result);
1929#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
1930 }
else if (PyFunction_Check(called)) {
1931#if PYTHON_VERSION < 0x3b0
1932 PyObject *result = callPythonFunction(called, args, 2);
1934 PyObject *result = _PyFunction_Vectorcall(called, args, 2, NULL);
1936 CHECK_OBJECT_X(result);
1940#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
1941 }
else if (PyType_Check(called)) {
1942 PyTypeObject *type = Py_TYPE(called);
1944 if (type->tp_call == PyType_Type.tp_call) {
1945 PyTypeObject *called_type = (PyTypeObject *)(called);
1947 if (unlikely(called_type->tp_new == NULL)) {
1948 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
1954 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
1955 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
1956 formatCannotInstantiateAbstractClass(tstate, called_type);
1960 obj = called_type->tp_alloc(called_type, 0);
1963 obj = called_type->tp_new(called_type, pos_args, NULL);
1966 if (likely(obj != NULL)) {
1967 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
1972 type = Py_TYPE(obj);
1974 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
1975 if (type->tp_init == default_tp_init_wrapper) {
1977 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
1980 assert(init_method != NULL);
1982 bool is_compiled_function =
false;
1983 bool init_method_needs_release =
false;
1985 if (likely(init_method != NULL)) {
1986 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
1988 if (func == Nuitka_Function_Type.tp_descr_get) {
1989 is_compiled_function =
true;
1990 }
else if (func != NULL) {
1991 init_method = func(init_method, obj, (PyObject *)(type));
1992 init_method_needs_release =
true;
1996 if (unlikely(init_method == NULL)) {
1997 if (!HAS_ERROR_OCCURRED(tstate)) {
1998 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
1999 const_str_plain___init__);
2006 if (is_compiled_function) {
2007 result = Nuitka_CallMethodFunctionPosArgs(
2010 result = CALL_FUNCTION_WITH_POS_ARGS2(tstate, init_method, pos_args);
2011 if (init_method_needs_release) {
2012 Py_DECREF(init_method);
2016 if (unlikely(result == NULL)) {
2023 if (unlikely(result != Py_None)) {
2026 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2031 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
2039 CHECK_OBJECT_X(obj);
2044#if PYTHON_VERSION < 0x300
2045 }
else if (PyClass_Check(called)) {
2046 PyObject *obj = PyInstance_NewRaw(called, NULL);
2048 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
2050 if (unlikely(init_method == NULL)) {
2051 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
2058 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
2062 bool is_compiled_function =
false;
2064 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
2066 if (descr_get == NULL) {
2067 Py_INCREF(init_method);
2068 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
2069 is_compiled_function =
true;
2070 }
else if (descr_get != NULL) {
2071 PyObject *descr_method = descr_get(init_method, obj, called);
2073 if (unlikely(descr_method == NULL)) {
2077 init_method = descr_method;
2081 if (is_compiled_function) {
2082 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
2085 result = CALL_FUNCTION_WITH_POS_ARGS2(tstate, init_method, pos_args);
2086 Py_DECREF(init_method);
2088 if (unlikely(result == NULL)) {
2094 if (unlikely(result != Py_None)) {
2095 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2099 CHECK_OBJECT_X(obj);
2103#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
2104 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
2105 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2107 if (likely(func != NULL)) {
2108 PyObject *result = func(called, args, 2, NULL);
2110 CHECK_OBJECT_X(result);
2112 return Nuitka_CheckFunctionResult(tstate, called, result);
2119 PRINT_STRING(
"FALLBACK");
2124 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
2126 CHECK_OBJECT_X(result);
2130PyObject *CALL_FUNCTION_WITH_ARGS3(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
2131 CHECK_OBJECT(called);
2132 CHECK_OBJECTS(args, 3);
2134 if (Nuitka_Function_Check(called)) {
2135 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2142 if (function->m_args_simple && 3 == function->m_args_positional_count) {
2143 for (Py_ssize_t i = 0; i < 3; i++) {
2146 result = function->m_c_code(tstate, function, (PyObject **)args);
2147 }
else if (function->m_args_simple && 3 + function->m_defaults_given == function->m_args_positional_count) {
2148 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2150 memcpy(python_pars, args, 3 *
sizeof(PyObject *));
2151 memcpy(python_pars + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2152 function->m_defaults_given *
sizeof(PyObject *));
2154 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
2155 Py_INCREF(python_pars[i]);
2158 result = function->m_c_code(tstate, function, python_pars);
2160 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 3);
2163 Py_LeaveRecursiveCall();
2165 CHECK_OBJECT_X(result);
2168 }
else if (Nuitka_Method_Check(called)) {
2171 if (method->m_object == NULL) {
2172 PyObject *self = args[0];
2174 int res = PyObject_IsInstance(self, method->m_class);
2176 if (unlikely(res < 0)) {
2178 }
else if (unlikely(res == 0)) {
2179 PyErr_Format(PyExc_TypeError,
2180 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
2181 "instance instead)",
2182 GET_CALLABLE_NAME((PyObject *)method->m_function),
2183 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
2184 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
2189 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 3);
2191 CHECK_OBJECT_X(result);
2195 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2203 if (function->m_args_simple && 3 + 1 == function->m_args_positional_count) {
2204 PyObject *python_pars[3 + 1];
2206 python_pars[0] = method->m_object;
2207 Py_INCREF(method->m_object);
2209 for (Py_ssize_t i = 0; i < 3; i++) {
2210 python_pars[i + 1] = args[i];
2213 result = function->m_c_code(tstate, function, python_pars);
2214 }
else if (function->m_args_simple &&
2215 3 + 1 + function->m_defaults_given == function->m_args_positional_count) {
2216 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2218 python_pars[0] = method->m_object;
2219 Py_INCREF(method->m_object);
2221 memcpy(python_pars + 1, args, 3 *
sizeof(PyObject *));
2222 memcpy(python_pars + 1 + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2223 function->m_defaults_given *
sizeof(PyObject *));
2225 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
2226 Py_INCREF(python_pars[i]);
2229 result = function->m_c_code(tstate, function, python_pars);
2231 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 3);
2234 Py_LeaveRecursiveCall();
2236 CHECK_OBJECT_X(result);
2240#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
2241 }
else if (PyCFunction_CheckExact(called)) {
2242#if PYTHON_VERSION >= 0x380
2243#ifdef _NUITKA_FULL_COMPAT
2244 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2249 int flags = PyCFunction_GET_FLAGS(called);
2253 if (!(flags & METH_VARARGS)) {
2254 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2256 assert(func != NULL);
2257 result = func(called, args, 3, NULL);
2259 CHECK_OBJECT_X(result);
2261 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2262 PyObject *self = PyCFunction_GET_SELF(called);
2264 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2266 if (flags & METH_KEYWORDS) {
2267 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
2269 result = (*method)(self, pos_args);
2272 Py_DECREF(pos_args);
2275#ifdef _NUITKA_FULL_COMPAT
2276 Py_LeaveRecursiveCall();
2278 CHECK_OBJECT_X(result);
2280 return Nuitka_CheckFunctionResult(tstate, called, result);
2283 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
2285 if (unlikely(flags & METH_NOARGS)) {
2286 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (3 given)",
2287 ((PyCFunctionObject *)called)->m_ml->ml_name);
2289 }
else if (unlikely(flags & METH_O)) {
2290 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (3 given)",
2291 ((PyCFunctionObject *)called)->m_ml->ml_name);
2293 }
else if (flags & METH_VARARGS) {
2296#ifdef _NUITKA_FULL_COMPAT
2297 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2301 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2302 PyObject *self = PyCFunction_GET_SELF(called);
2306#if PYTHON_VERSION < 0x360
2307 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2308 if (flags & METH_KEYWORDS) {
2309 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2311 result = (*method)(self, pos_args);
2314 Py_DECREF(pos_args);
2316 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
2317 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2318 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2319 Py_DECREF(pos_args);
2320 }
else if (flags == METH_FASTCALL) {
2321#if PYTHON_VERSION < 0x370
2322 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 3, NULL);
2324 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2325 result = (*(_PyCFunctionFast)method)(self, &pos_args, 3);
2326 Py_DECREF(pos_args);
2329 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2330 result = (*method)(self, pos_args);
2331 Py_DECREF(pos_args);
2335#ifdef _NUITKA_FULL_COMPAT
2336 Py_LeaveRecursiveCall();
2339 CHECK_OBJECT_X(result);
2341 return Nuitka_CheckFunctionResult(tstate, called, result);
2345#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
2346 }
else if (PyFunction_Check(called)) {
2347#if PYTHON_VERSION < 0x3b0
2348 PyObject *result = callPythonFunction(called, args, 3);
2350 PyObject *result = _PyFunction_Vectorcall(called, args, 3, NULL);
2352 CHECK_OBJECT_X(result);
2356#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
2357 }
else if (PyType_Check(called)) {
2358 PyTypeObject *type = Py_TYPE(called);
2360 if (type->tp_call == PyType_Type.tp_call) {
2361 PyTypeObject *called_type = (PyTypeObject *)(called);
2363 if (unlikely(called_type->tp_new == NULL)) {
2364 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
2368 PyObject *pos_args = NULL;
2371 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
2372 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
2373 formatCannotInstantiateAbstractClass(tstate, called_type);
2377 obj = called_type->tp_alloc(called_type, 0);
2380 pos_args = MAKE_TUPLE(tstate, args, 3);
2381 obj = called_type->tp_new(called_type, pos_args, NULL);
2384 if (likely(obj != NULL)) {
2385 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
2386 Py_DECREF(pos_args);
2391 type = Py_TYPE(obj);
2393 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
2394 if (type->tp_init == default_tp_init_wrapper) {
2395 Py_XDECREF(pos_args);
2398 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
2401 assert(init_method != NULL);
2403 bool is_compiled_function =
false;
2404 bool init_method_needs_release =
false;
2406 if (likely(init_method != NULL)) {
2407 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
2409 if (func == Nuitka_Function_Type.tp_descr_get) {
2410 is_compiled_function =
true;
2411 }
else if (func != NULL) {
2412 init_method = func(init_method, obj, (PyObject *)(type));
2413 init_method_needs_release =
true;
2417 if (unlikely(init_method == NULL)) {
2418 if (!HAS_ERROR_OCCURRED(tstate)) {
2419 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
2420 const_str_plain___init__);
2427 if (is_compiled_function) {
2428 result = Nuitka_CallMethodFunctionPosArgs(
2431 result = CALL_FUNCTION_WITH_ARGS3(tstate, init_method, args);
2432 if (init_method_needs_release) {
2433 Py_DECREF(init_method);
2437 if (unlikely(result == NULL)) {
2444 if (unlikely(result != Py_None)) {
2447 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2451 if (pos_args == NULL) {
2452 pos_args = MAKE_TUPLE(tstate, args, 3);
2455 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
2457 Py_XDECREF(pos_args);
2464 Py_XDECREF(pos_args);
2466 CHECK_OBJECT_X(obj);
2471#if PYTHON_VERSION < 0x300
2472 }
else if (PyClass_Check(called)) {
2473 PyObject *obj = PyInstance_NewRaw(called, NULL);
2475 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
2477 if (unlikely(init_method == NULL)) {
2478 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
2485 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
2489 bool is_compiled_function =
false;
2491 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
2493 if (descr_get == NULL) {
2494 Py_INCREF(init_method);
2495 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
2496 is_compiled_function =
true;
2497 }
else if (descr_get != NULL) {
2498 PyObject *descr_method = descr_get(init_method, obj, called);
2500 if (unlikely(descr_method == NULL)) {
2504 init_method = descr_method;
2508 if (is_compiled_function) {
2509 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
2512 result = CALL_FUNCTION_WITH_ARGS3(tstate, init_method, args);
2513 Py_DECREF(init_method);
2515 if (unlikely(result == NULL)) {
2521 if (unlikely(result != Py_None)) {
2522 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2526 CHECK_OBJECT_X(obj);
2530#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
2531 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
2532 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2534 if (likely(func != NULL)) {
2535 PyObject *result = func(called, args, 3, NULL);
2537 CHECK_OBJECT_X(result);
2539 return Nuitka_CheckFunctionResult(tstate, called, result);
2546 PRINT_STRING(
"FALLBACK");
2551 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2553 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
2555 Py_DECREF(pos_args);
2557 CHECK_OBJECT_X(result);
2561PyObject *CALL_FUNCTION_WITH_POS_ARGS3(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
2562 assert(PyTuple_CheckExact(pos_args));
2563 assert(PyTuple_GET_SIZE(pos_args) == 3);
2564 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
2565 CHECK_OBJECT(called);
2566 CHECK_OBJECTS(args, 3);
2568 if (Nuitka_Function_Check(called)) {
2569 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2576 if (function->m_args_simple && 3 == function->m_args_positional_count) {
2577 for (Py_ssize_t i = 0; i < 3; i++) {
2580 result = function->m_c_code(tstate, function, (PyObject **)args);
2581 }
else if (function->m_args_simple && 3 + function->m_defaults_given == function->m_args_positional_count) {
2582 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2584 memcpy(python_pars, args, 3 *
sizeof(PyObject *));
2585 memcpy(python_pars + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2586 function->m_defaults_given *
sizeof(PyObject *));
2588 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
2589 Py_INCREF(python_pars[i]);
2592 result = function->m_c_code(tstate, function, python_pars);
2594 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 3);
2597 Py_LeaveRecursiveCall();
2599 CHECK_OBJECT_X(result);
2602 }
else if (Nuitka_Method_Check(called)) {
2605 if (method->m_object == NULL) {
2606 PyObject *self = args[0];
2608 int res = PyObject_IsInstance(self, method->m_class);
2610 if (unlikely(res < 0)) {
2612 }
else if (unlikely(res == 0)) {
2613 PyErr_Format(PyExc_TypeError,
2614 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
2615 "instance instead)",
2616 GET_CALLABLE_NAME((PyObject *)method->m_function),
2617 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
2618 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
2623 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 3);
2625 CHECK_OBJECT_X(result);
2629 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2637 if (function->m_args_simple && 3 + 1 == function->m_args_positional_count) {
2638 PyObject *python_pars[3 + 1];
2640 python_pars[0] = method->m_object;
2641 Py_INCREF(method->m_object);
2643 for (Py_ssize_t i = 0; i < 3; i++) {
2644 python_pars[i + 1] = args[i];
2647 result = function->m_c_code(tstate, function, python_pars);
2648 }
else if (function->m_args_simple &&
2649 3 + 1 + function->m_defaults_given == function->m_args_positional_count) {
2650 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2652 python_pars[0] = method->m_object;
2653 Py_INCREF(method->m_object);
2655 memcpy(python_pars + 1, args, 3 *
sizeof(PyObject *));
2656 memcpy(python_pars + 1 + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2657 function->m_defaults_given *
sizeof(PyObject *));
2659 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
2660 Py_INCREF(python_pars[i]);
2663 result = function->m_c_code(tstate, function, python_pars);
2665 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 3);
2668 Py_LeaveRecursiveCall();
2670 CHECK_OBJECT_X(result);
2674#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
2675 }
else if (PyCFunction_CheckExact(called)) {
2676#if PYTHON_VERSION >= 0x380
2677#ifdef _NUITKA_FULL_COMPAT
2678 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2683 int flags = PyCFunction_GET_FLAGS(called);
2687 if (!(flags & METH_VARARGS)) {
2688 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2690 assert(func != NULL);
2691 result = func(called, args, 3, NULL);
2693 CHECK_OBJECT_X(result);
2695 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2696 PyObject *self = PyCFunction_GET_SELF(called);
2698 if (flags & METH_KEYWORDS) {
2699 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
2701 result = (*method)(self, pos_args);
2705#ifdef _NUITKA_FULL_COMPAT
2706 Py_LeaveRecursiveCall();
2708 CHECK_OBJECT_X(result);
2710 return Nuitka_CheckFunctionResult(tstate, called, result);
2713 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
2715 if (unlikely(flags & METH_NOARGS)) {
2716 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (3 given)",
2717 ((PyCFunctionObject *)called)->m_ml->ml_name);
2719 }
else if (unlikely(flags & METH_O)) {
2720 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (3 given)",
2721 ((PyCFunctionObject *)called)->m_ml->ml_name);
2723 }
else if (flags & METH_VARARGS) {
2726#ifdef _NUITKA_FULL_COMPAT
2727 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2731 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2732 PyObject *self = PyCFunction_GET_SELF(called);
2736#if PYTHON_VERSION < 0x360
2737 if (flags & METH_KEYWORDS) {
2738 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2740 result = (*method)(self, pos_args);
2744 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
2745 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2746 }
else if (flags == METH_FASTCALL) {
2747#if PYTHON_VERSION < 0x370
2748 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 3, NULL);
2750 result = (*(_PyCFunctionFast)method)(self, &pos_args, 3);
2753 result = (*method)(self, pos_args);
2757#ifdef _NUITKA_FULL_COMPAT
2758 Py_LeaveRecursiveCall();
2761 CHECK_OBJECT_X(result);
2763 return Nuitka_CheckFunctionResult(tstate, called, result);
2767#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
2768 }
else if (PyFunction_Check(called)) {
2769#if PYTHON_VERSION < 0x3b0
2770 PyObject *result = callPythonFunction(called, args, 3);
2772 PyObject *result = _PyFunction_Vectorcall(called, args, 3, NULL);
2774 CHECK_OBJECT_X(result);
2778#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
2779 }
else if (PyType_Check(called)) {
2780 PyTypeObject *type = Py_TYPE(called);
2782 if (type->tp_call == PyType_Type.tp_call) {
2783 PyTypeObject *called_type = (PyTypeObject *)(called);
2785 if (unlikely(called_type->tp_new == NULL)) {
2786 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
2792 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
2793 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
2794 formatCannotInstantiateAbstractClass(tstate, called_type);
2798 obj = called_type->tp_alloc(called_type, 0);
2801 obj = called_type->tp_new(called_type, pos_args, NULL);
2804 if (likely(obj != NULL)) {
2805 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
2810 type = Py_TYPE(obj);
2812 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
2813 if (type->tp_init == default_tp_init_wrapper) {
2815 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
2818 assert(init_method != NULL);
2820 bool is_compiled_function =
false;
2821 bool init_method_needs_release =
false;
2823 if (likely(init_method != NULL)) {
2824 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
2826 if (func == Nuitka_Function_Type.tp_descr_get) {
2827 is_compiled_function =
true;
2828 }
else if (func != NULL) {
2829 init_method = func(init_method, obj, (PyObject *)(type));
2830 init_method_needs_release =
true;
2834 if (unlikely(init_method == NULL)) {
2835 if (!HAS_ERROR_OCCURRED(tstate)) {
2836 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
2837 const_str_plain___init__);
2844 if (is_compiled_function) {
2845 result = Nuitka_CallMethodFunctionPosArgs(
2848 result = CALL_FUNCTION_WITH_POS_ARGS3(tstate, init_method, pos_args);
2849 if (init_method_needs_release) {
2850 Py_DECREF(init_method);
2854 if (unlikely(result == NULL)) {
2861 if (unlikely(result != Py_None)) {
2864 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2869 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
2877 CHECK_OBJECT_X(obj);
2882#if PYTHON_VERSION < 0x300
2883 }
else if (PyClass_Check(called)) {
2884 PyObject *obj = PyInstance_NewRaw(called, NULL);
2886 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
2888 if (unlikely(init_method == NULL)) {
2889 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
2896 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
2900 bool is_compiled_function =
false;
2902 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
2904 if (descr_get == NULL) {
2905 Py_INCREF(init_method);
2906 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
2907 is_compiled_function =
true;
2908 }
else if (descr_get != NULL) {
2909 PyObject *descr_method = descr_get(init_method, obj, called);
2911 if (unlikely(descr_method == NULL)) {
2915 init_method = descr_method;
2919 if (is_compiled_function) {
2920 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
2923 result = CALL_FUNCTION_WITH_POS_ARGS3(tstate, init_method, pos_args);
2924 Py_DECREF(init_method);
2926 if (unlikely(result == NULL)) {
2932 if (unlikely(result != Py_None)) {
2933 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2937 CHECK_OBJECT_X(obj);
2941#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
2942 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
2943 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2945 if (likely(func != NULL)) {
2946 PyObject *result = func(called, args, 3, NULL);
2948 CHECK_OBJECT_X(result);
2950 return Nuitka_CheckFunctionResult(tstate, called, result);
2957 PRINT_STRING(
"FALLBACK");
2962 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
2964 CHECK_OBJECT_X(result);
2968PyObject *CALL_FUNCTION_WITH_ARGS4(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
2969 CHECK_OBJECT(called);
2970 CHECK_OBJECTS(args, 4);
2972 if (Nuitka_Function_Check(called)) {
2973 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2980 if (function->m_args_simple && 4 == function->m_args_positional_count) {
2981 for (Py_ssize_t i = 0; i < 4; i++) {
2984 result = function->m_c_code(tstate, function, (PyObject **)args);
2985 }
else if (function->m_args_simple && 4 + function->m_defaults_given == function->m_args_positional_count) {
2986 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2988 memcpy(python_pars, args, 4 *
sizeof(PyObject *));
2989 memcpy(python_pars + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
2990 function->m_defaults_given *
sizeof(PyObject *));
2992 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
2993 Py_INCREF(python_pars[i]);
2996 result = function->m_c_code(tstate, function, python_pars);
2998 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 4);
3001 Py_LeaveRecursiveCall();
3003 CHECK_OBJECT_X(result);
3006 }
else if (Nuitka_Method_Check(called)) {
3009 if (method->m_object == NULL) {
3010 PyObject *self = args[0];
3012 int res = PyObject_IsInstance(self, method->m_class);
3014 if (unlikely(res < 0)) {
3016 }
else if (unlikely(res == 0)) {
3017 PyErr_Format(PyExc_TypeError,
3018 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
3019 "instance instead)",
3020 GET_CALLABLE_NAME((PyObject *)method->m_function),
3021 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
3022 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
3027 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 4);
3029 CHECK_OBJECT_X(result);
3033 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3041 if (function->m_args_simple && 4 + 1 == function->m_args_positional_count) {
3042 PyObject *python_pars[4 + 1];
3044 python_pars[0] = method->m_object;
3045 Py_INCREF(method->m_object);
3047 for (Py_ssize_t i = 0; i < 4; i++) {
3048 python_pars[i + 1] = args[i];
3051 result = function->m_c_code(tstate, function, python_pars);
3052 }
else if (function->m_args_simple &&
3053 4 + 1 + function->m_defaults_given == function->m_args_positional_count) {
3054 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3056 python_pars[0] = method->m_object;
3057 Py_INCREF(method->m_object);
3059 memcpy(python_pars + 1, args, 4 *
sizeof(PyObject *));
3060 memcpy(python_pars + 1 + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
3061 function->m_defaults_given *
sizeof(PyObject *));
3063 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
3064 Py_INCREF(python_pars[i]);
3067 result = function->m_c_code(tstate, function, python_pars);
3069 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 4);
3072 Py_LeaveRecursiveCall();
3074 CHECK_OBJECT_X(result);
3078#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
3079 }
else if (PyCFunction_CheckExact(called)) {
3080#if PYTHON_VERSION >= 0x380
3081#ifdef _NUITKA_FULL_COMPAT
3082 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3087 int flags = PyCFunction_GET_FLAGS(called);
3091 if (!(flags & METH_VARARGS)) {
3092 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3094 assert(func != NULL);
3095 result = func(called, args, 4, NULL);
3097 CHECK_OBJECT_X(result);
3099 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3100 PyObject *self = PyCFunction_GET_SELF(called);
3102 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3104 if (flags & METH_KEYWORDS) {
3105 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
3107 result = (*method)(self, pos_args);
3110 Py_DECREF(pos_args);
3113#ifdef _NUITKA_FULL_COMPAT
3114 Py_LeaveRecursiveCall();
3116 CHECK_OBJECT_X(result);
3118 return Nuitka_CheckFunctionResult(tstate, called, result);
3121 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
3123 if (unlikely(flags & METH_NOARGS)) {
3124 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (4 given)",
3125 ((PyCFunctionObject *)called)->m_ml->ml_name);
3127 }
else if (unlikely(flags & METH_O)) {
3128 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (4 given)",
3129 ((PyCFunctionObject *)called)->m_ml->ml_name);
3131 }
else if (flags & METH_VARARGS) {
3134#ifdef _NUITKA_FULL_COMPAT
3135 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3139 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3140 PyObject *self = PyCFunction_GET_SELF(called);
3144#if PYTHON_VERSION < 0x360
3145 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3146 if (flags & METH_KEYWORDS) {
3147 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3149 result = (*method)(self, pos_args);
3152 Py_DECREF(pos_args);
3154 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
3155 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3156 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3157 Py_DECREF(pos_args);
3158 }
else if (flags == METH_FASTCALL) {
3159#if PYTHON_VERSION < 0x370
3160 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 4, NULL);
3162 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3163 result = (*(_PyCFunctionFast)method)(self, &pos_args, 4);
3164 Py_DECREF(pos_args);
3167 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3168 result = (*method)(self, pos_args);
3169 Py_DECREF(pos_args);
3173#ifdef _NUITKA_FULL_COMPAT
3174 Py_LeaveRecursiveCall();
3177 CHECK_OBJECT_X(result);
3179 return Nuitka_CheckFunctionResult(tstate, called, result);
3183#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
3184 }
else if (PyFunction_Check(called)) {
3185#if PYTHON_VERSION < 0x3b0
3186 PyObject *result = callPythonFunction(called, args, 4);
3188 PyObject *result = _PyFunction_Vectorcall(called, args, 4, NULL);
3190 CHECK_OBJECT_X(result);
3194#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
3195 }
else if (PyType_Check(called)) {
3196 PyTypeObject *type = Py_TYPE(called);
3198 if (type->tp_call == PyType_Type.tp_call) {
3199 PyTypeObject *called_type = (PyTypeObject *)(called);
3201 if (unlikely(called_type->tp_new == NULL)) {
3202 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
3206 PyObject *pos_args = NULL;
3209 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
3210 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
3211 formatCannotInstantiateAbstractClass(tstate, called_type);
3215 obj = called_type->tp_alloc(called_type, 0);
3218 pos_args = MAKE_TUPLE(tstate, args, 4);
3219 obj = called_type->tp_new(called_type, pos_args, NULL);
3222 if (likely(obj != NULL)) {
3223 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
3224 Py_DECREF(pos_args);
3229 type = Py_TYPE(obj);
3231 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
3232 if (type->tp_init == default_tp_init_wrapper) {
3233 Py_XDECREF(pos_args);
3236 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
3239 assert(init_method != NULL);
3241 bool is_compiled_function =
false;
3242 bool init_method_needs_release =
false;
3244 if (likely(init_method != NULL)) {
3245 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
3247 if (func == Nuitka_Function_Type.tp_descr_get) {
3248 is_compiled_function =
true;
3249 }
else if (func != NULL) {
3250 init_method = func(init_method, obj, (PyObject *)(type));
3251 init_method_needs_release =
true;
3255 if (unlikely(init_method == NULL)) {
3256 if (!HAS_ERROR_OCCURRED(tstate)) {
3257 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
3258 const_str_plain___init__);
3265 if (is_compiled_function) {
3266 result = Nuitka_CallMethodFunctionPosArgs(
3269 result = CALL_FUNCTION_WITH_ARGS4(tstate, init_method, args);
3270 if (init_method_needs_release) {
3271 Py_DECREF(init_method);
3275 if (unlikely(result == NULL)) {
3282 if (unlikely(result != Py_None)) {
3285 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
3289 if (pos_args == NULL) {
3290 pos_args = MAKE_TUPLE(tstate, args, 4);
3293 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
3295 Py_XDECREF(pos_args);
3302 Py_XDECREF(pos_args);
3304 CHECK_OBJECT_X(obj);
3309#if PYTHON_VERSION < 0x300
3310 }
else if (PyClass_Check(called)) {
3311 PyObject *obj = PyInstance_NewRaw(called, NULL);
3313 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
3315 if (unlikely(init_method == NULL)) {
3316 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
3323 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
3327 bool is_compiled_function =
false;
3329 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
3331 if (descr_get == NULL) {
3332 Py_INCREF(init_method);
3333 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
3334 is_compiled_function =
true;
3335 }
else if (descr_get != NULL) {
3336 PyObject *descr_method = descr_get(init_method, obj, called);
3338 if (unlikely(descr_method == NULL)) {
3342 init_method = descr_method;
3346 if (is_compiled_function) {
3347 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
3350 result = CALL_FUNCTION_WITH_ARGS4(tstate, init_method, args);
3351 Py_DECREF(init_method);
3353 if (unlikely(result == NULL)) {
3359 if (unlikely(result != Py_None)) {
3360 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
3364 CHECK_OBJECT_X(obj);
3368#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
3369 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
3370 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3372 if (likely(func != NULL)) {
3373 PyObject *result = func(called, args, 4, NULL);
3375 CHECK_OBJECT_X(result);
3377 return Nuitka_CheckFunctionResult(tstate, called, result);
3384 PRINT_STRING(
"FALLBACK");
3389 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3391 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
3393 Py_DECREF(pos_args);
3395 CHECK_OBJECT_X(result);
3399PyObject *CALL_FUNCTION_WITH_POS_ARGS4(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
3400 assert(PyTuple_CheckExact(pos_args));
3401 assert(PyTuple_GET_SIZE(pos_args) == 4);
3402 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
3403 CHECK_OBJECT(called);
3404 CHECK_OBJECTS(args, 4);
3406 if (Nuitka_Function_Check(called)) {
3407 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3414 if (function->m_args_simple && 4 == function->m_args_positional_count) {
3415 for (Py_ssize_t i = 0; i < 4; i++) {
3418 result = function->m_c_code(tstate, function, (PyObject **)args);
3419 }
else if (function->m_args_simple && 4 + function->m_defaults_given == function->m_args_positional_count) {
3420 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3422 memcpy(python_pars, args, 4 *
sizeof(PyObject *));
3423 memcpy(python_pars + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
3424 function->m_defaults_given *
sizeof(PyObject *));
3426 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
3427 Py_INCREF(python_pars[i]);
3430 result = function->m_c_code(tstate, function, python_pars);
3432 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 4);
3435 Py_LeaveRecursiveCall();
3437 CHECK_OBJECT_X(result);
3440 }
else if (Nuitka_Method_Check(called)) {
3443 if (method->m_object == NULL) {
3444 PyObject *self = args[0];
3446 int res = PyObject_IsInstance(self, method->m_class);
3448 if (unlikely(res < 0)) {
3450 }
else if (unlikely(res == 0)) {
3451 PyErr_Format(PyExc_TypeError,
3452 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
3453 "instance instead)",
3454 GET_CALLABLE_NAME((PyObject *)method->m_function),
3455 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
3456 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
3461 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 4);
3463 CHECK_OBJECT_X(result);
3467 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3475 if (function->m_args_simple && 4 + 1 == function->m_args_positional_count) {
3476 PyObject *python_pars[4 + 1];
3478 python_pars[0] = method->m_object;
3479 Py_INCREF(method->m_object);
3481 for (Py_ssize_t i = 0; i < 4; i++) {
3482 python_pars[i + 1] = args[i];
3485 result = function->m_c_code(tstate, function, python_pars);
3486 }
else if (function->m_args_simple &&
3487 4 + 1 + function->m_defaults_given == function->m_args_positional_count) {
3488 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3490 python_pars[0] = method->m_object;
3491 Py_INCREF(method->m_object);
3493 memcpy(python_pars + 1, args, 4 *
sizeof(PyObject *));
3494 memcpy(python_pars + 1 + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
3495 function->m_defaults_given *
sizeof(PyObject *));
3497 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
3498 Py_INCREF(python_pars[i]);
3501 result = function->m_c_code(tstate, function, python_pars);
3503 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 4);
3506 Py_LeaveRecursiveCall();
3508 CHECK_OBJECT_X(result);
3512#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
3513 }
else if (PyCFunction_CheckExact(called)) {
3514#if PYTHON_VERSION >= 0x380
3515#ifdef _NUITKA_FULL_COMPAT
3516 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3521 int flags = PyCFunction_GET_FLAGS(called);
3525 if (!(flags & METH_VARARGS)) {
3526 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3528 assert(func != NULL);
3529 result = func(called, args, 4, NULL);
3531 CHECK_OBJECT_X(result);
3533 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3534 PyObject *self = PyCFunction_GET_SELF(called);
3536 if (flags & METH_KEYWORDS) {
3537 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
3539 result = (*method)(self, pos_args);
3543#ifdef _NUITKA_FULL_COMPAT
3544 Py_LeaveRecursiveCall();
3546 CHECK_OBJECT_X(result);
3548 return Nuitka_CheckFunctionResult(tstate, called, result);
3551 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
3553 if (unlikely(flags & METH_NOARGS)) {
3554 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (4 given)",
3555 ((PyCFunctionObject *)called)->m_ml->ml_name);
3557 }
else if (unlikely(flags & METH_O)) {
3558 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (4 given)",
3559 ((PyCFunctionObject *)called)->m_ml->ml_name);
3561 }
else if (flags & METH_VARARGS) {
3564#ifdef _NUITKA_FULL_COMPAT
3565 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3569 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3570 PyObject *self = PyCFunction_GET_SELF(called);
3574#if PYTHON_VERSION < 0x360
3575 if (flags & METH_KEYWORDS) {
3576 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3578 result = (*method)(self, pos_args);
3582 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
3583 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3584 }
else if (flags == METH_FASTCALL) {
3585#if PYTHON_VERSION < 0x370
3586 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 4, NULL);
3588 result = (*(_PyCFunctionFast)method)(self, &pos_args, 4);
3591 result = (*method)(self, pos_args);
3595#ifdef _NUITKA_FULL_COMPAT
3596 Py_LeaveRecursiveCall();
3599 CHECK_OBJECT_X(result);
3601 return Nuitka_CheckFunctionResult(tstate, called, result);
3605#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
3606 }
else if (PyFunction_Check(called)) {
3607#if PYTHON_VERSION < 0x3b0
3608 PyObject *result = callPythonFunction(called, args, 4);
3610 PyObject *result = _PyFunction_Vectorcall(called, args, 4, NULL);
3612 CHECK_OBJECT_X(result);
3616#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
3617 }
else if (PyType_Check(called)) {
3618 PyTypeObject *type = Py_TYPE(called);
3620 if (type->tp_call == PyType_Type.tp_call) {
3621 PyTypeObject *called_type = (PyTypeObject *)(called);
3623 if (unlikely(called_type->tp_new == NULL)) {
3624 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
3630 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
3631 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
3632 formatCannotInstantiateAbstractClass(tstate, called_type);
3636 obj = called_type->tp_alloc(called_type, 0);
3639 obj = called_type->tp_new(called_type, pos_args, NULL);
3642 if (likely(obj != NULL)) {
3643 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
3648 type = Py_TYPE(obj);
3650 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
3651 if (type->tp_init == default_tp_init_wrapper) {
3653 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
3656 assert(init_method != NULL);
3658 bool is_compiled_function =
false;
3659 bool init_method_needs_release =
false;
3661 if (likely(init_method != NULL)) {
3662 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
3664 if (func == Nuitka_Function_Type.tp_descr_get) {
3665 is_compiled_function =
true;
3666 }
else if (func != NULL) {
3667 init_method = func(init_method, obj, (PyObject *)(type));
3668 init_method_needs_release =
true;
3672 if (unlikely(init_method == NULL)) {
3673 if (!HAS_ERROR_OCCURRED(tstate)) {
3674 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
3675 const_str_plain___init__);
3682 if (is_compiled_function) {
3683 result = Nuitka_CallMethodFunctionPosArgs(
3686 result = CALL_FUNCTION_WITH_POS_ARGS4(tstate, init_method, pos_args);
3687 if (init_method_needs_release) {
3688 Py_DECREF(init_method);
3692 if (unlikely(result == NULL)) {
3699 if (unlikely(result != Py_None)) {
3702 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
3707 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
3715 CHECK_OBJECT_X(obj);
3720#if PYTHON_VERSION < 0x300
3721 }
else if (PyClass_Check(called)) {
3722 PyObject *obj = PyInstance_NewRaw(called, NULL);
3724 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
3726 if (unlikely(init_method == NULL)) {
3727 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
3734 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
3738 bool is_compiled_function =
false;
3740 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
3742 if (descr_get == NULL) {
3743 Py_INCREF(init_method);
3744 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
3745 is_compiled_function =
true;
3746 }
else if (descr_get != NULL) {
3747 PyObject *descr_method = descr_get(init_method, obj, called);
3749 if (unlikely(descr_method == NULL)) {
3753 init_method = descr_method;
3757 if (is_compiled_function) {
3758 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
3761 result = CALL_FUNCTION_WITH_POS_ARGS4(tstate, init_method, pos_args);
3762 Py_DECREF(init_method);
3764 if (unlikely(result == NULL)) {
3770 if (unlikely(result != Py_None)) {
3771 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
3775 CHECK_OBJECT_X(obj);
3779#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
3780 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
3781 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3783 if (likely(func != NULL)) {
3784 PyObject *result = func(called, args, 4, NULL);
3786 CHECK_OBJECT_X(result);
3788 return Nuitka_CheckFunctionResult(tstate, called, result);
3795 PRINT_STRING(
"FALLBACK");
3800 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
3802 CHECK_OBJECT_X(result);
3806PyObject *CALL_FUNCTION_WITH_ARGS5(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
3807 CHECK_OBJECT(called);
3808 CHECK_OBJECTS(args, 5);
3810 if (Nuitka_Function_Check(called)) {
3811 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3818 if (function->m_args_simple && 5 == function->m_args_positional_count) {
3819 for (Py_ssize_t i = 0; i < 5; i++) {
3822 result = function->m_c_code(tstate, function, (PyObject **)args);
3823 }
else if (function->m_args_simple && 5 + function->m_defaults_given == function->m_args_positional_count) {
3824 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3826 memcpy(python_pars, args, 5 *
sizeof(PyObject *));
3827 memcpy(python_pars + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
3828 function->m_defaults_given *
sizeof(PyObject *));
3830 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
3831 Py_INCREF(python_pars[i]);
3834 result = function->m_c_code(tstate, function, python_pars);
3836 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 5);
3839 Py_LeaveRecursiveCall();
3841 CHECK_OBJECT_X(result);
3844 }
else if (Nuitka_Method_Check(called)) {
3847 if (method->m_object == NULL) {
3848 PyObject *self = args[0];
3850 int res = PyObject_IsInstance(self, method->m_class);
3852 if (unlikely(res < 0)) {
3854 }
else if (unlikely(res == 0)) {
3855 PyErr_Format(PyExc_TypeError,
3856 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
3857 "instance instead)",
3858 GET_CALLABLE_NAME((PyObject *)method->m_function),
3859 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
3860 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
3865 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 5);
3867 CHECK_OBJECT_X(result);
3871 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3879 if (function->m_args_simple && 5 + 1 == function->m_args_positional_count) {
3880 PyObject *python_pars[5 + 1];
3882 python_pars[0] = method->m_object;
3883 Py_INCREF(method->m_object);
3885 for (Py_ssize_t i = 0; i < 5; i++) {
3886 python_pars[i + 1] = args[i];
3889 result = function->m_c_code(tstate, function, python_pars);
3890 }
else if (function->m_args_simple &&
3891 5 + 1 + function->m_defaults_given == function->m_args_positional_count) {
3892 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3894 python_pars[0] = method->m_object;
3895 Py_INCREF(method->m_object);
3897 memcpy(python_pars + 1, args, 5 *
sizeof(PyObject *));
3898 memcpy(python_pars + 1 + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
3899 function->m_defaults_given *
sizeof(PyObject *));
3901 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
3902 Py_INCREF(python_pars[i]);
3905 result = function->m_c_code(tstate, function, python_pars);
3907 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 5);
3910 Py_LeaveRecursiveCall();
3912 CHECK_OBJECT_X(result);
3916#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
3917 }
else if (PyCFunction_CheckExact(called)) {
3918#if PYTHON_VERSION >= 0x380
3919#ifdef _NUITKA_FULL_COMPAT
3920 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3925 int flags = PyCFunction_GET_FLAGS(called);
3929 if (!(flags & METH_VARARGS)) {
3930 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3932 assert(func != NULL);
3933 result = func(called, args, 5, NULL);
3935 CHECK_OBJECT_X(result);
3937 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3938 PyObject *self = PyCFunction_GET_SELF(called);
3940 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3942 if (flags & METH_KEYWORDS) {
3943 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
3945 result = (*method)(self, pos_args);
3948 Py_DECREF(pos_args);
3951#ifdef _NUITKA_FULL_COMPAT
3952 Py_LeaveRecursiveCall();
3954 CHECK_OBJECT_X(result);
3956 return Nuitka_CheckFunctionResult(tstate, called, result);
3959 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
3961 if (unlikely(flags & METH_NOARGS)) {
3962 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (5 given)",
3963 ((PyCFunctionObject *)called)->m_ml->ml_name);
3965 }
else if (unlikely(flags & METH_O)) {
3966 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (5 given)",
3967 ((PyCFunctionObject *)called)->m_ml->ml_name);
3969 }
else if (flags & METH_VARARGS) {
3972#ifdef _NUITKA_FULL_COMPAT
3973 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3977 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3978 PyObject *self = PyCFunction_GET_SELF(called);
3982#if PYTHON_VERSION < 0x360
3983 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3984 if (flags & METH_KEYWORDS) {
3985 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3987 result = (*method)(self, pos_args);
3990 Py_DECREF(pos_args);
3992 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
3993 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3994 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3995 Py_DECREF(pos_args);
3996 }
else if (flags == METH_FASTCALL) {
3997#if PYTHON_VERSION < 0x370
3998 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 5, NULL);
4000 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
4001 result = (*(_PyCFunctionFast)method)(self, &pos_args, 5);
4002 Py_DECREF(pos_args);
4005 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
4006 result = (*method)(self, pos_args);
4007 Py_DECREF(pos_args);
4011#ifdef _NUITKA_FULL_COMPAT
4012 Py_LeaveRecursiveCall();
4015 CHECK_OBJECT_X(result);
4017 return Nuitka_CheckFunctionResult(tstate, called, result);
4021#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
4022 }
else if (PyFunction_Check(called)) {
4023#if PYTHON_VERSION < 0x3b0
4024 PyObject *result = callPythonFunction(called, args, 5);
4026 PyObject *result = _PyFunction_Vectorcall(called, args, 5, NULL);
4028 CHECK_OBJECT_X(result);
4032#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
4033 }
else if (PyType_Check(called)) {
4034 PyTypeObject *type = Py_TYPE(called);
4036 if (type->tp_call == PyType_Type.tp_call) {
4037 PyTypeObject *called_type = (PyTypeObject *)(called);
4039 if (unlikely(called_type->tp_new == NULL)) {
4040 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
4044 PyObject *pos_args = NULL;
4047 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
4048 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
4049 formatCannotInstantiateAbstractClass(tstate, called_type);
4053 obj = called_type->tp_alloc(called_type, 0);
4056 pos_args = MAKE_TUPLE(tstate, args, 5);
4057 obj = called_type->tp_new(called_type, pos_args, NULL);
4060 if (likely(obj != NULL)) {
4061 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
4062 Py_DECREF(pos_args);
4067 type = Py_TYPE(obj);
4069 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
4070 if (type->tp_init == default_tp_init_wrapper) {
4071 Py_XDECREF(pos_args);
4074 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
4077 assert(init_method != NULL);
4079 bool is_compiled_function =
false;
4080 bool init_method_needs_release =
false;
4082 if (likely(init_method != NULL)) {
4083 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
4085 if (func == Nuitka_Function_Type.tp_descr_get) {
4086 is_compiled_function =
true;
4087 }
else if (func != NULL) {
4088 init_method = func(init_method, obj, (PyObject *)(type));
4089 init_method_needs_release =
true;
4093 if (unlikely(init_method == NULL)) {
4094 if (!HAS_ERROR_OCCURRED(tstate)) {
4095 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
4096 const_str_plain___init__);
4103 if (is_compiled_function) {
4104 result = Nuitka_CallMethodFunctionPosArgs(
4107 result = CALL_FUNCTION_WITH_ARGS5(tstate, init_method, args);
4108 if (init_method_needs_release) {
4109 Py_DECREF(init_method);
4113 if (unlikely(result == NULL)) {
4120 if (unlikely(result != Py_None)) {
4123 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4127 if (pos_args == NULL) {
4128 pos_args = MAKE_TUPLE(tstate, args, 5);
4131 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
4133 Py_XDECREF(pos_args);
4140 Py_XDECREF(pos_args);
4142 CHECK_OBJECT_X(obj);
4147#if PYTHON_VERSION < 0x300
4148 }
else if (PyClass_Check(called)) {
4149 PyObject *obj = PyInstance_NewRaw(called, NULL);
4151 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
4153 if (unlikely(init_method == NULL)) {
4154 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
4161 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
4165 bool is_compiled_function =
false;
4167 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
4169 if (descr_get == NULL) {
4170 Py_INCREF(init_method);
4171 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
4172 is_compiled_function =
true;
4173 }
else if (descr_get != NULL) {
4174 PyObject *descr_method = descr_get(init_method, obj, called);
4176 if (unlikely(descr_method == NULL)) {
4180 init_method = descr_method;
4184 if (is_compiled_function) {
4185 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
4188 result = CALL_FUNCTION_WITH_ARGS5(tstate, init_method, args);
4189 Py_DECREF(init_method);
4191 if (unlikely(result == NULL)) {
4197 if (unlikely(result != Py_None)) {
4198 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4202 CHECK_OBJECT_X(obj);
4206#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
4207 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
4208 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4210 if (likely(func != NULL)) {
4211 PyObject *result = func(called, args, 5, NULL);
4213 CHECK_OBJECT_X(result);
4215 return Nuitka_CheckFunctionResult(tstate, called, result);
4222 PRINT_STRING(
"FALLBACK");
4227 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
4229 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
4231 Py_DECREF(pos_args);
4233 CHECK_OBJECT_X(result);
4237PyObject *CALL_FUNCTION_WITH_POS_ARGS5(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
4238 assert(PyTuple_CheckExact(pos_args));
4239 assert(PyTuple_GET_SIZE(pos_args) == 5);
4240 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
4241 CHECK_OBJECT(called);
4242 CHECK_OBJECTS(args, 5);
4244 if (Nuitka_Function_Check(called)) {
4245 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4252 if (function->m_args_simple && 5 == function->m_args_positional_count) {
4253 for (Py_ssize_t i = 0; i < 5; i++) {
4256 result = function->m_c_code(tstate, function, (PyObject **)args);
4257 }
else if (function->m_args_simple && 5 + function->m_defaults_given == function->m_args_positional_count) {
4258 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4260 memcpy(python_pars, args, 5 *
sizeof(PyObject *));
4261 memcpy(python_pars + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
4262 function->m_defaults_given *
sizeof(PyObject *));
4264 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
4265 Py_INCREF(python_pars[i]);
4268 result = function->m_c_code(tstate, function, python_pars);
4270 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 5);
4273 Py_LeaveRecursiveCall();
4275 CHECK_OBJECT_X(result);
4278 }
else if (Nuitka_Method_Check(called)) {
4281 if (method->m_object == NULL) {
4282 PyObject *self = args[0];
4284 int res = PyObject_IsInstance(self, method->m_class);
4286 if (unlikely(res < 0)) {
4288 }
else if (unlikely(res == 0)) {
4289 PyErr_Format(PyExc_TypeError,
4290 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
4291 "instance instead)",
4292 GET_CALLABLE_NAME((PyObject *)method->m_function),
4293 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
4294 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
4299 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 5);
4301 CHECK_OBJECT_X(result);
4305 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4313 if (function->m_args_simple && 5 + 1 == function->m_args_positional_count) {
4314 PyObject *python_pars[5 + 1];
4316 python_pars[0] = method->m_object;
4317 Py_INCREF(method->m_object);
4319 for (Py_ssize_t i = 0; i < 5; i++) {
4320 python_pars[i + 1] = args[i];
4323 result = function->m_c_code(tstate, function, python_pars);
4324 }
else if (function->m_args_simple &&
4325 5 + 1 + function->m_defaults_given == function->m_args_positional_count) {
4326 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4328 python_pars[0] = method->m_object;
4329 Py_INCREF(method->m_object);
4331 memcpy(python_pars + 1, args, 5 *
sizeof(PyObject *));
4332 memcpy(python_pars + 1 + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
4333 function->m_defaults_given *
sizeof(PyObject *));
4335 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
4336 Py_INCREF(python_pars[i]);
4339 result = function->m_c_code(tstate, function, python_pars);
4341 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 5);
4344 Py_LeaveRecursiveCall();
4346 CHECK_OBJECT_X(result);
4350#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
4351 }
else if (PyCFunction_CheckExact(called)) {
4352#if PYTHON_VERSION >= 0x380
4353#ifdef _NUITKA_FULL_COMPAT
4354 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4359 int flags = PyCFunction_GET_FLAGS(called);
4363 if (!(flags & METH_VARARGS)) {
4364 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4366 assert(func != NULL);
4367 result = func(called, args, 5, NULL);
4369 CHECK_OBJECT_X(result);
4371 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4372 PyObject *self = PyCFunction_GET_SELF(called);
4374 if (flags & METH_KEYWORDS) {
4375 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
4377 result = (*method)(self, pos_args);
4381#ifdef _NUITKA_FULL_COMPAT
4382 Py_LeaveRecursiveCall();
4384 CHECK_OBJECT_X(result);
4386 return Nuitka_CheckFunctionResult(tstate, called, result);
4389 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
4391 if (unlikely(flags & METH_NOARGS)) {
4392 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (5 given)",
4393 ((PyCFunctionObject *)called)->m_ml->ml_name);
4395 }
else if (unlikely(flags & METH_O)) {
4396 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (5 given)",
4397 ((PyCFunctionObject *)called)->m_ml->ml_name);
4399 }
else if (flags & METH_VARARGS) {
4402#ifdef _NUITKA_FULL_COMPAT
4403 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4407 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4408 PyObject *self = PyCFunction_GET_SELF(called);
4412#if PYTHON_VERSION < 0x360
4413 if (flags & METH_KEYWORDS) {
4414 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4416 result = (*method)(self, pos_args);
4420 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
4421 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4422 }
else if (flags == METH_FASTCALL) {
4423#if PYTHON_VERSION < 0x370
4424 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 5, NULL);
4426 result = (*(_PyCFunctionFast)method)(self, &pos_args, 5);
4429 result = (*method)(self, pos_args);
4433#ifdef _NUITKA_FULL_COMPAT
4434 Py_LeaveRecursiveCall();
4437 CHECK_OBJECT_X(result);
4439 return Nuitka_CheckFunctionResult(tstate, called, result);
4443#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
4444 }
else if (PyFunction_Check(called)) {
4445#if PYTHON_VERSION < 0x3b0
4446 PyObject *result = callPythonFunction(called, args, 5);
4448 PyObject *result = _PyFunction_Vectorcall(called, args, 5, NULL);
4450 CHECK_OBJECT_X(result);
4454#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
4455 }
else if (PyType_Check(called)) {
4456 PyTypeObject *type = Py_TYPE(called);
4458 if (type->tp_call == PyType_Type.tp_call) {
4459 PyTypeObject *called_type = (PyTypeObject *)(called);
4461 if (unlikely(called_type->tp_new == NULL)) {
4462 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
4468 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
4469 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
4470 formatCannotInstantiateAbstractClass(tstate, called_type);
4474 obj = called_type->tp_alloc(called_type, 0);
4477 obj = called_type->tp_new(called_type, pos_args, NULL);
4480 if (likely(obj != NULL)) {
4481 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
4486 type = Py_TYPE(obj);
4488 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
4489 if (type->tp_init == default_tp_init_wrapper) {
4491 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
4494 assert(init_method != NULL);
4496 bool is_compiled_function =
false;
4497 bool init_method_needs_release =
false;
4499 if (likely(init_method != NULL)) {
4500 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
4502 if (func == Nuitka_Function_Type.tp_descr_get) {
4503 is_compiled_function =
true;
4504 }
else if (func != NULL) {
4505 init_method = func(init_method, obj, (PyObject *)(type));
4506 init_method_needs_release =
true;
4510 if (unlikely(init_method == NULL)) {
4511 if (!HAS_ERROR_OCCURRED(tstate)) {
4512 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
4513 const_str_plain___init__);
4520 if (is_compiled_function) {
4521 result = Nuitka_CallMethodFunctionPosArgs(
4524 result = CALL_FUNCTION_WITH_POS_ARGS5(tstate, init_method, pos_args);
4525 if (init_method_needs_release) {
4526 Py_DECREF(init_method);
4530 if (unlikely(result == NULL)) {
4537 if (unlikely(result != Py_None)) {
4540 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4545 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
4553 CHECK_OBJECT_X(obj);
4558#if PYTHON_VERSION < 0x300
4559 }
else if (PyClass_Check(called)) {
4560 PyObject *obj = PyInstance_NewRaw(called, NULL);
4562 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
4564 if (unlikely(init_method == NULL)) {
4565 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
4572 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
4576 bool is_compiled_function =
false;
4578 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
4580 if (descr_get == NULL) {
4581 Py_INCREF(init_method);
4582 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
4583 is_compiled_function =
true;
4584 }
else if (descr_get != NULL) {
4585 PyObject *descr_method = descr_get(init_method, obj, called);
4587 if (unlikely(descr_method == NULL)) {
4591 init_method = descr_method;
4595 if (is_compiled_function) {
4596 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
4599 result = CALL_FUNCTION_WITH_POS_ARGS5(tstate, init_method, pos_args);
4600 Py_DECREF(init_method);
4602 if (unlikely(result == NULL)) {
4608 if (unlikely(result != Py_None)) {
4609 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4613 CHECK_OBJECT_X(obj);
4617#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
4618 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
4619 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4621 if (likely(func != NULL)) {
4622 PyObject *result = func(called, args, 5, NULL);
4624 CHECK_OBJECT_X(result);
4626 return Nuitka_CheckFunctionResult(tstate, called, result);
4633 PRINT_STRING(
"FALLBACK");
4638 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
4640 CHECK_OBJECT_X(result);
4644PyObject *CALL_FUNCTION_WITH_ARGS6(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
4645 CHECK_OBJECT(called);
4646 CHECK_OBJECTS(args, 6);
4648 if (Nuitka_Function_Check(called)) {
4649 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4656 if (function->m_args_simple && 6 == function->m_args_positional_count) {
4657 for (Py_ssize_t i = 0; i < 6; i++) {
4660 result = function->m_c_code(tstate, function, (PyObject **)args);
4661 }
else if (function->m_args_simple && 6 + function->m_defaults_given == function->m_args_positional_count) {
4662 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4664 memcpy(python_pars, args, 6 *
sizeof(PyObject *));
4665 memcpy(python_pars + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
4666 function->m_defaults_given *
sizeof(PyObject *));
4668 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
4669 Py_INCREF(python_pars[i]);
4672 result = function->m_c_code(tstate, function, python_pars);
4674 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 6);
4677 Py_LeaveRecursiveCall();
4679 CHECK_OBJECT_X(result);
4682 }
else if (Nuitka_Method_Check(called)) {
4685 if (method->m_object == NULL) {
4686 PyObject *self = args[0];
4688 int res = PyObject_IsInstance(self, method->m_class);
4690 if (unlikely(res < 0)) {
4692 }
else if (unlikely(res == 0)) {
4693 PyErr_Format(PyExc_TypeError,
4694 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
4695 "instance instead)",
4696 GET_CALLABLE_NAME((PyObject *)method->m_function),
4697 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
4698 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
4703 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 6);
4705 CHECK_OBJECT_X(result);
4709 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4717 if (function->m_args_simple && 6 + 1 == function->m_args_positional_count) {
4718 PyObject *python_pars[6 + 1];
4720 python_pars[0] = method->m_object;
4721 Py_INCREF(method->m_object);
4723 for (Py_ssize_t i = 0; i < 6; i++) {
4724 python_pars[i + 1] = args[i];
4727 result = function->m_c_code(tstate, function, python_pars);
4728 }
else if (function->m_args_simple &&
4729 6 + 1 + function->m_defaults_given == function->m_args_positional_count) {
4730 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4732 python_pars[0] = method->m_object;
4733 Py_INCREF(method->m_object);
4735 memcpy(python_pars + 1, args, 6 *
sizeof(PyObject *));
4736 memcpy(python_pars + 1 + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
4737 function->m_defaults_given *
sizeof(PyObject *));
4739 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
4740 Py_INCREF(python_pars[i]);
4743 result = function->m_c_code(tstate, function, python_pars);
4745 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 6);
4748 Py_LeaveRecursiveCall();
4750 CHECK_OBJECT_X(result);
4754#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
4755 }
else if (PyCFunction_CheckExact(called)) {
4756#if PYTHON_VERSION >= 0x380
4757#ifdef _NUITKA_FULL_COMPAT
4758 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4763 int flags = PyCFunction_GET_FLAGS(called);
4767 if (!(flags & METH_VARARGS)) {
4768 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4770 assert(func != NULL);
4771 result = func(called, args, 6, NULL);
4773 CHECK_OBJECT_X(result);
4775 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4776 PyObject *self = PyCFunction_GET_SELF(called);
4778 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4780 if (flags & METH_KEYWORDS) {
4781 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
4783 result = (*method)(self, pos_args);
4786 Py_DECREF(pos_args);
4789#ifdef _NUITKA_FULL_COMPAT
4790 Py_LeaveRecursiveCall();
4792 CHECK_OBJECT_X(result);
4794 return Nuitka_CheckFunctionResult(tstate, called, result);
4797 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
4799 if (unlikely(flags & METH_NOARGS)) {
4800 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (6 given)",
4801 ((PyCFunctionObject *)called)->m_ml->ml_name);
4803 }
else if (unlikely(flags & METH_O)) {
4804 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (6 given)",
4805 ((PyCFunctionObject *)called)->m_ml->ml_name);
4807 }
else if (flags & METH_VARARGS) {
4810#ifdef _NUITKA_FULL_COMPAT
4811 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4815 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4816 PyObject *self = PyCFunction_GET_SELF(called);
4820#if PYTHON_VERSION < 0x360
4821 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4822 if (flags & METH_KEYWORDS) {
4823 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4825 result = (*method)(self, pos_args);
4828 Py_DECREF(pos_args);
4830 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
4831 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4832 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4833 Py_DECREF(pos_args);
4834 }
else if (flags == METH_FASTCALL) {
4835#if PYTHON_VERSION < 0x370
4836 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 6, NULL);
4838 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4839 result = (*(_PyCFunctionFast)method)(self, &pos_args, 6);
4840 Py_DECREF(pos_args);
4843 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4844 result = (*method)(self, pos_args);
4845 Py_DECREF(pos_args);
4849#ifdef _NUITKA_FULL_COMPAT
4850 Py_LeaveRecursiveCall();
4853 CHECK_OBJECT_X(result);
4855 return Nuitka_CheckFunctionResult(tstate, called, result);
4859#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
4860 }
else if (PyFunction_Check(called)) {
4861#if PYTHON_VERSION < 0x3b0
4862 PyObject *result = callPythonFunction(called, args, 6);
4864 PyObject *result = _PyFunction_Vectorcall(called, args, 6, NULL);
4866 CHECK_OBJECT_X(result);
4870#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
4871 }
else if (PyType_Check(called)) {
4872 PyTypeObject *type = Py_TYPE(called);
4874 if (type->tp_call == PyType_Type.tp_call) {
4875 PyTypeObject *called_type = (PyTypeObject *)(called);
4877 if (unlikely(called_type->tp_new == NULL)) {
4878 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
4882 PyObject *pos_args = NULL;
4885 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
4886 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
4887 formatCannotInstantiateAbstractClass(tstate, called_type);
4891 obj = called_type->tp_alloc(called_type, 0);
4894 pos_args = MAKE_TUPLE(tstate, args, 6);
4895 obj = called_type->tp_new(called_type, pos_args, NULL);
4898 if (likely(obj != NULL)) {
4899 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
4900 Py_DECREF(pos_args);
4905 type = Py_TYPE(obj);
4907 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
4908 if (type->tp_init == default_tp_init_wrapper) {
4909 Py_XDECREF(pos_args);
4912 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
4915 assert(init_method != NULL);
4917 bool is_compiled_function =
false;
4918 bool init_method_needs_release =
false;
4920 if (likely(init_method != NULL)) {
4921 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
4923 if (func == Nuitka_Function_Type.tp_descr_get) {
4924 is_compiled_function =
true;
4925 }
else if (func != NULL) {
4926 init_method = func(init_method, obj, (PyObject *)(type));
4927 init_method_needs_release =
true;
4931 if (unlikely(init_method == NULL)) {
4932 if (!HAS_ERROR_OCCURRED(tstate)) {
4933 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
4934 const_str_plain___init__);
4941 if (is_compiled_function) {
4942 result = Nuitka_CallMethodFunctionPosArgs(
4945 result = CALL_FUNCTION_WITH_ARGS6(tstate, init_method, args);
4946 if (init_method_needs_release) {
4947 Py_DECREF(init_method);
4951 if (unlikely(result == NULL)) {
4958 if (unlikely(result != Py_None)) {
4961 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4965 if (pos_args == NULL) {
4966 pos_args = MAKE_TUPLE(tstate, args, 6);
4969 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
4971 Py_XDECREF(pos_args);
4978 Py_XDECREF(pos_args);
4980 CHECK_OBJECT_X(obj);
4985#if PYTHON_VERSION < 0x300
4986 }
else if (PyClass_Check(called)) {
4987 PyObject *obj = PyInstance_NewRaw(called, NULL);
4989 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
4991 if (unlikely(init_method == NULL)) {
4992 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
4999 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
5003 bool is_compiled_function =
false;
5005 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
5007 if (descr_get == NULL) {
5008 Py_INCREF(init_method);
5009 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
5010 is_compiled_function =
true;
5011 }
else if (descr_get != NULL) {
5012 PyObject *descr_method = descr_get(init_method, obj, called);
5014 if (unlikely(descr_method == NULL)) {
5018 init_method = descr_method;
5022 if (is_compiled_function) {
5023 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
5026 result = CALL_FUNCTION_WITH_ARGS6(tstate, init_method, args);
5027 Py_DECREF(init_method);
5029 if (unlikely(result == NULL)) {
5035 if (unlikely(result != Py_None)) {
5036 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5040 CHECK_OBJECT_X(obj);
5044#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
5045 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
5046 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5048 if (likely(func != NULL)) {
5049 PyObject *result = func(called, args, 6, NULL);
5051 CHECK_OBJECT_X(result);
5053 return Nuitka_CheckFunctionResult(tstate, called, result);
5060 PRINT_STRING(
"FALLBACK");
5065 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
5067 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
5069 Py_DECREF(pos_args);
5071 CHECK_OBJECT_X(result);
5075PyObject *CALL_FUNCTION_WITH_POS_ARGS6(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
5076 assert(PyTuple_CheckExact(pos_args));
5077 assert(PyTuple_GET_SIZE(pos_args) == 6);
5078 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
5079 CHECK_OBJECT(called);
5080 CHECK_OBJECTS(args, 6);
5082 if (Nuitka_Function_Check(called)) {
5083 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5090 if (function->m_args_simple && 6 == function->m_args_positional_count) {
5091 for (Py_ssize_t i = 0; i < 6; i++) {
5094 result = function->m_c_code(tstate, function, (PyObject **)args);
5095 }
else if (function->m_args_simple && 6 + function->m_defaults_given == function->m_args_positional_count) {
5096 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5098 memcpy(python_pars, args, 6 *
sizeof(PyObject *));
5099 memcpy(python_pars + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
5100 function->m_defaults_given *
sizeof(PyObject *));
5102 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
5103 Py_INCREF(python_pars[i]);
5106 result = function->m_c_code(tstate, function, python_pars);
5108 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 6);
5111 Py_LeaveRecursiveCall();
5113 CHECK_OBJECT_X(result);
5116 }
else if (Nuitka_Method_Check(called)) {
5119 if (method->m_object == NULL) {
5120 PyObject *self = args[0];
5122 int res = PyObject_IsInstance(self, method->m_class);
5124 if (unlikely(res < 0)) {
5126 }
else if (unlikely(res == 0)) {
5127 PyErr_Format(PyExc_TypeError,
5128 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
5129 "instance instead)",
5130 GET_CALLABLE_NAME((PyObject *)method->m_function),
5131 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
5132 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
5137 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 6);
5139 CHECK_OBJECT_X(result);
5143 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5151 if (function->m_args_simple && 6 + 1 == function->m_args_positional_count) {
5152 PyObject *python_pars[6 + 1];
5154 python_pars[0] = method->m_object;
5155 Py_INCREF(method->m_object);
5157 for (Py_ssize_t i = 0; i < 6; i++) {
5158 python_pars[i + 1] = args[i];
5161 result = function->m_c_code(tstate, function, python_pars);
5162 }
else if (function->m_args_simple &&
5163 6 + 1 + function->m_defaults_given == function->m_args_positional_count) {
5164 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5166 python_pars[0] = method->m_object;
5167 Py_INCREF(method->m_object);
5169 memcpy(python_pars + 1, args, 6 *
sizeof(PyObject *));
5170 memcpy(python_pars + 1 + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
5171 function->m_defaults_given *
sizeof(PyObject *));
5173 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
5174 Py_INCREF(python_pars[i]);
5177 result = function->m_c_code(tstate, function, python_pars);
5179 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 6);
5182 Py_LeaveRecursiveCall();
5184 CHECK_OBJECT_X(result);
5188#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
5189 }
else if (PyCFunction_CheckExact(called)) {
5190#if PYTHON_VERSION >= 0x380
5191#ifdef _NUITKA_FULL_COMPAT
5192 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5197 int flags = PyCFunction_GET_FLAGS(called);
5201 if (!(flags & METH_VARARGS)) {
5202 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5204 assert(func != NULL);
5205 result = func(called, args, 6, NULL);
5207 CHECK_OBJECT_X(result);
5209 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5210 PyObject *self = PyCFunction_GET_SELF(called);
5212 if (flags & METH_KEYWORDS) {
5213 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
5215 result = (*method)(self, pos_args);
5219#ifdef _NUITKA_FULL_COMPAT
5220 Py_LeaveRecursiveCall();
5222 CHECK_OBJECT_X(result);
5224 return Nuitka_CheckFunctionResult(tstate, called, result);
5227 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
5229 if (unlikely(flags & METH_NOARGS)) {
5230 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (6 given)",
5231 ((PyCFunctionObject *)called)->m_ml->ml_name);
5233 }
else if (unlikely(flags & METH_O)) {
5234 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (6 given)",
5235 ((PyCFunctionObject *)called)->m_ml->ml_name);
5237 }
else if (flags & METH_VARARGS) {
5240#ifdef _NUITKA_FULL_COMPAT
5241 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5245 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5246 PyObject *self = PyCFunction_GET_SELF(called);
5250#if PYTHON_VERSION < 0x360
5251 if (flags & METH_KEYWORDS) {
5252 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5254 result = (*method)(self, pos_args);
5258 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
5259 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5260 }
else if (flags == METH_FASTCALL) {
5261#if PYTHON_VERSION < 0x370
5262 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 6, NULL);
5264 result = (*(_PyCFunctionFast)method)(self, &pos_args, 6);
5267 result = (*method)(self, pos_args);
5271#ifdef _NUITKA_FULL_COMPAT
5272 Py_LeaveRecursiveCall();
5275 CHECK_OBJECT_X(result);
5277 return Nuitka_CheckFunctionResult(tstate, called, result);
5281#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
5282 }
else if (PyFunction_Check(called)) {
5283#if PYTHON_VERSION < 0x3b0
5284 PyObject *result = callPythonFunction(called, args, 6);
5286 PyObject *result = _PyFunction_Vectorcall(called, args, 6, NULL);
5288 CHECK_OBJECT_X(result);
5292#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
5293 }
else if (PyType_Check(called)) {
5294 PyTypeObject *type = Py_TYPE(called);
5296 if (type->tp_call == PyType_Type.tp_call) {
5297 PyTypeObject *called_type = (PyTypeObject *)(called);
5299 if (unlikely(called_type->tp_new == NULL)) {
5300 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
5306 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
5307 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
5308 formatCannotInstantiateAbstractClass(tstate, called_type);
5312 obj = called_type->tp_alloc(called_type, 0);
5315 obj = called_type->tp_new(called_type, pos_args, NULL);
5318 if (likely(obj != NULL)) {
5319 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
5324 type = Py_TYPE(obj);
5326 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
5327 if (type->tp_init == default_tp_init_wrapper) {
5329 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
5332 assert(init_method != NULL);
5334 bool is_compiled_function =
false;
5335 bool init_method_needs_release =
false;
5337 if (likely(init_method != NULL)) {
5338 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
5340 if (func == Nuitka_Function_Type.tp_descr_get) {
5341 is_compiled_function =
true;
5342 }
else if (func != NULL) {
5343 init_method = func(init_method, obj, (PyObject *)(type));
5344 init_method_needs_release =
true;
5348 if (unlikely(init_method == NULL)) {
5349 if (!HAS_ERROR_OCCURRED(tstate)) {
5350 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
5351 const_str_plain___init__);
5358 if (is_compiled_function) {
5359 result = Nuitka_CallMethodFunctionPosArgs(
5362 result = CALL_FUNCTION_WITH_POS_ARGS6(tstate, init_method, pos_args);
5363 if (init_method_needs_release) {
5364 Py_DECREF(init_method);
5368 if (unlikely(result == NULL)) {
5375 if (unlikely(result != Py_None)) {
5378 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5383 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
5391 CHECK_OBJECT_X(obj);
5396#if PYTHON_VERSION < 0x300
5397 }
else if (PyClass_Check(called)) {
5398 PyObject *obj = PyInstance_NewRaw(called, NULL);
5400 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
5402 if (unlikely(init_method == NULL)) {
5403 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
5410 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
5414 bool is_compiled_function =
false;
5416 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
5418 if (descr_get == NULL) {
5419 Py_INCREF(init_method);
5420 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
5421 is_compiled_function =
true;
5422 }
else if (descr_get != NULL) {
5423 PyObject *descr_method = descr_get(init_method, obj, called);
5425 if (unlikely(descr_method == NULL)) {
5429 init_method = descr_method;
5433 if (is_compiled_function) {
5434 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
5437 result = CALL_FUNCTION_WITH_POS_ARGS6(tstate, init_method, pos_args);
5438 Py_DECREF(init_method);
5440 if (unlikely(result == NULL)) {
5446 if (unlikely(result != Py_None)) {
5447 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5451 CHECK_OBJECT_X(obj);
5455#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
5456 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
5457 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5459 if (likely(func != NULL)) {
5460 PyObject *result = func(called, args, 6, NULL);
5462 CHECK_OBJECT_X(result);
5464 return Nuitka_CheckFunctionResult(tstate, called, result);
5471 PRINT_STRING(
"FALLBACK");
5476 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
5478 CHECK_OBJECT_X(result);
5482PyObject *CALL_FUNCTION_WITH_ARGS7(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
5483 CHECK_OBJECT(called);
5484 CHECK_OBJECTS(args, 7);
5486 if (Nuitka_Function_Check(called)) {
5487 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5494 if (function->m_args_simple && 7 == function->m_args_positional_count) {
5495 for (Py_ssize_t i = 0; i < 7; i++) {
5498 result = function->m_c_code(tstate, function, (PyObject **)args);
5499 }
else if (function->m_args_simple && 7 + function->m_defaults_given == function->m_args_positional_count) {
5500 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5502 memcpy(python_pars, args, 7 *
sizeof(PyObject *));
5503 memcpy(python_pars + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
5504 function->m_defaults_given *
sizeof(PyObject *));
5506 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
5507 Py_INCREF(python_pars[i]);
5510 result = function->m_c_code(tstate, function, python_pars);
5512 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 7);
5515 Py_LeaveRecursiveCall();
5517 CHECK_OBJECT_X(result);
5520 }
else if (Nuitka_Method_Check(called)) {
5523 if (method->m_object == NULL) {
5524 PyObject *self = args[0];
5526 int res = PyObject_IsInstance(self, method->m_class);
5528 if (unlikely(res < 0)) {
5530 }
else if (unlikely(res == 0)) {
5531 PyErr_Format(PyExc_TypeError,
5532 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
5533 "instance instead)",
5534 GET_CALLABLE_NAME((PyObject *)method->m_function),
5535 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
5536 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
5541 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 7);
5543 CHECK_OBJECT_X(result);
5547 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5555 if (function->m_args_simple && 7 + 1 == function->m_args_positional_count) {
5556 PyObject *python_pars[7 + 1];
5558 python_pars[0] = method->m_object;
5559 Py_INCREF(method->m_object);
5561 for (Py_ssize_t i = 0; i < 7; i++) {
5562 python_pars[i + 1] = args[i];
5565 result = function->m_c_code(tstate, function, python_pars);
5566 }
else if (function->m_args_simple &&
5567 7 + 1 + function->m_defaults_given == function->m_args_positional_count) {
5568 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5570 python_pars[0] = method->m_object;
5571 Py_INCREF(method->m_object);
5573 memcpy(python_pars + 1, args, 7 *
sizeof(PyObject *));
5574 memcpy(python_pars + 1 + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
5575 function->m_defaults_given *
sizeof(PyObject *));
5577 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
5578 Py_INCREF(python_pars[i]);
5581 result = function->m_c_code(tstate, function, python_pars);
5583 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 7);
5586 Py_LeaveRecursiveCall();
5588 CHECK_OBJECT_X(result);
5592#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
5593 }
else if (PyCFunction_CheckExact(called)) {
5594#if PYTHON_VERSION >= 0x380
5595#ifdef _NUITKA_FULL_COMPAT
5596 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5601 int flags = PyCFunction_GET_FLAGS(called);
5605 if (!(flags & METH_VARARGS)) {
5606 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5608 assert(func != NULL);
5609 result = func(called, args, 7, NULL);
5611 CHECK_OBJECT_X(result);
5613 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5614 PyObject *self = PyCFunction_GET_SELF(called);
5616 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5618 if (flags & METH_KEYWORDS) {
5619 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
5621 result = (*method)(self, pos_args);
5624 Py_DECREF(pos_args);
5627#ifdef _NUITKA_FULL_COMPAT
5628 Py_LeaveRecursiveCall();
5630 CHECK_OBJECT_X(result);
5632 return Nuitka_CheckFunctionResult(tstate, called, result);
5635 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
5637 if (unlikely(flags & METH_NOARGS)) {
5638 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (7 given)",
5639 ((PyCFunctionObject *)called)->m_ml->ml_name);
5641 }
else if (unlikely(flags & METH_O)) {
5642 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (7 given)",
5643 ((PyCFunctionObject *)called)->m_ml->ml_name);
5645 }
else if (flags & METH_VARARGS) {
5648#ifdef _NUITKA_FULL_COMPAT
5649 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5653 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5654 PyObject *self = PyCFunction_GET_SELF(called);
5658#if PYTHON_VERSION < 0x360
5659 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5660 if (flags & METH_KEYWORDS) {
5661 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5663 result = (*method)(self, pos_args);
5666 Py_DECREF(pos_args);
5668 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
5669 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5670 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5671 Py_DECREF(pos_args);
5672 }
else if (flags == METH_FASTCALL) {
5673#if PYTHON_VERSION < 0x370
5674 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 7, NULL);
5676 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5677 result = (*(_PyCFunctionFast)method)(self, &pos_args, 7);
5678 Py_DECREF(pos_args);
5681 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5682 result = (*method)(self, pos_args);
5683 Py_DECREF(pos_args);
5687#ifdef _NUITKA_FULL_COMPAT
5688 Py_LeaveRecursiveCall();
5691 CHECK_OBJECT_X(result);
5693 return Nuitka_CheckFunctionResult(tstate, called, result);
5697#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
5698 }
else if (PyFunction_Check(called)) {
5699#if PYTHON_VERSION < 0x3b0
5700 PyObject *result = callPythonFunction(called, args, 7);
5702 PyObject *result = _PyFunction_Vectorcall(called, args, 7, NULL);
5704 CHECK_OBJECT_X(result);
5708#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
5709 }
else if (PyType_Check(called)) {
5710 PyTypeObject *type = Py_TYPE(called);
5712 if (type->tp_call == PyType_Type.tp_call) {
5713 PyTypeObject *called_type = (PyTypeObject *)(called);
5715 if (unlikely(called_type->tp_new == NULL)) {
5716 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
5720 PyObject *pos_args = NULL;
5723 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
5724 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
5725 formatCannotInstantiateAbstractClass(tstate, called_type);
5729 obj = called_type->tp_alloc(called_type, 0);
5732 pos_args = MAKE_TUPLE(tstate, args, 7);
5733 obj = called_type->tp_new(called_type, pos_args, NULL);
5736 if (likely(obj != NULL)) {
5737 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
5738 Py_DECREF(pos_args);
5743 type = Py_TYPE(obj);
5745 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
5746 if (type->tp_init == default_tp_init_wrapper) {
5747 Py_XDECREF(pos_args);
5750 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
5753 assert(init_method != NULL);
5755 bool is_compiled_function =
false;
5756 bool init_method_needs_release =
false;
5758 if (likely(init_method != NULL)) {
5759 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
5761 if (func == Nuitka_Function_Type.tp_descr_get) {
5762 is_compiled_function =
true;
5763 }
else if (func != NULL) {
5764 init_method = func(init_method, obj, (PyObject *)(type));
5765 init_method_needs_release =
true;
5769 if (unlikely(init_method == NULL)) {
5770 if (!HAS_ERROR_OCCURRED(tstate)) {
5771 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
5772 const_str_plain___init__);
5779 if (is_compiled_function) {
5780 result = Nuitka_CallMethodFunctionPosArgs(
5783 result = CALL_FUNCTION_WITH_ARGS7(tstate, init_method, args);
5784 if (init_method_needs_release) {
5785 Py_DECREF(init_method);
5789 if (unlikely(result == NULL)) {
5796 if (unlikely(result != Py_None)) {
5799 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5803 if (pos_args == NULL) {
5804 pos_args = MAKE_TUPLE(tstate, args, 7);
5807 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
5809 Py_XDECREF(pos_args);
5816 Py_XDECREF(pos_args);
5818 CHECK_OBJECT_X(obj);
5823#if PYTHON_VERSION < 0x300
5824 }
else if (PyClass_Check(called)) {
5825 PyObject *obj = PyInstance_NewRaw(called, NULL);
5827 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
5829 if (unlikely(init_method == NULL)) {
5830 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
5837 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
5841 bool is_compiled_function =
false;
5843 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
5845 if (descr_get == NULL) {
5846 Py_INCREF(init_method);
5847 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
5848 is_compiled_function =
true;
5849 }
else if (descr_get != NULL) {
5850 PyObject *descr_method = descr_get(init_method, obj, called);
5852 if (unlikely(descr_method == NULL)) {
5856 init_method = descr_method;
5860 if (is_compiled_function) {
5861 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
5864 result = CALL_FUNCTION_WITH_ARGS7(tstate, init_method, args);
5865 Py_DECREF(init_method);
5867 if (unlikely(result == NULL)) {
5873 if (unlikely(result != Py_None)) {
5874 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5878 CHECK_OBJECT_X(obj);
5882#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
5883 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
5884 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5886 if (likely(func != NULL)) {
5887 PyObject *result = func(called, args, 7, NULL);
5889 CHECK_OBJECT_X(result);
5891 return Nuitka_CheckFunctionResult(tstate, called, result);
5898 PRINT_STRING(
"FALLBACK");
5903 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5905 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
5907 Py_DECREF(pos_args);
5909 CHECK_OBJECT_X(result);
5913PyObject *CALL_FUNCTION_WITH_POS_ARGS7(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
5914 assert(PyTuple_CheckExact(pos_args));
5915 assert(PyTuple_GET_SIZE(pos_args) == 7);
5916 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
5917 CHECK_OBJECT(called);
5918 CHECK_OBJECTS(args, 7);
5920 if (Nuitka_Function_Check(called)) {
5921 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5928 if (function->m_args_simple && 7 == function->m_args_positional_count) {
5929 for (Py_ssize_t i = 0; i < 7; i++) {
5932 result = function->m_c_code(tstate, function, (PyObject **)args);
5933 }
else if (function->m_args_simple && 7 + function->m_defaults_given == function->m_args_positional_count) {
5934 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5936 memcpy(python_pars, args, 7 *
sizeof(PyObject *));
5937 memcpy(python_pars + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
5938 function->m_defaults_given *
sizeof(PyObject *));
5940 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
5941 Py_INCREF(python_pars[i]);
5944 result = function->m_c_code(tstate, function, python_pars);
5946 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 7);
5949 Py_LeaveRecursiveCall();
5951 CHECK_OBJECT_X(result);
5954 }
else if (Nuitka_Method_Check(called)) {
5957 if (method->m_object == NULL) {
5958 PyObject *self = args[0];
5960 int res = PyObject_IsInstance(self, method->m_class);
5962 if (unlikely(res < 0)) {
5964 }
else if (unlikely(res == 0)) {
5965 PyErr_Format(PyExc_TypeError,
5966 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
5967 "instance instead)",
5968 GET_CALLABLE_NAME((PyObject *)method->m_function),
5969 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
5970 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
5975 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 7);
5977 CHECK_OBJECT_X(result);
5981 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5989 if (function->m_args_simple && 7 + 1 == function->m_args_positional_count) {
5990 PyObject *python_pars[7 + 1];
5992 python_pars[0] = method->m_object;
5993 Py_INCREF(method->m_object);
5995 for (Py_ssize_t i = 0; i < 7; i++) {
5996 python_pars[i + 1] = args[i];
5999 result = function->m_c_code(tstate, function, python_pars);
6000 }
else if (function->m_args_simple &&
6001 7 + 1 + function->m_defaults_given == function->m_args_positional_count) {
6002 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6004 python_pars[0] = method->m_object;
6005 Py_INCREF(method->m_object);
6007 memcpy(python_pars + 1, args, 7 *
sizeof(PyObject *));
6008 memcpy(python_pars + 1 + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
6009 function->m_defaults_given *
sizeof(PyObject *));
6011 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
6012 Py_INCREF(python_pars[i]);
6015 result = function->m_c_code(tstate, function, python_pars);
6017 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 7);
6020 Py_LeaveRecursiveCall();
6022 CHECK_OBJECT_X(result);
6026#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
6027 }
else if (PyCFunction_CheckExact(called)) {
6028#if PYTHON_VERSION >= 0x380
6029#ifdef _NUITKA_FULL_COMPAT
6030 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6035 int flags = PyCFunction_GET_FLAGS(called);
6039 if (!(flags & METH_VARARGS)) {
6040 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6042 assert(func != NULL);
6043 result = func(called, args, 7, NULL);
6045 CHECK_OBJECT_X(result);
6047 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6048 PyObject *self = PyCFunction_GET_SELF(called);
6050 if (flags & METH_KEYWORDS) {
6051 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
6053 result = (*method)(self, pos_args);
6057#ifdef _NUITKA_FULL_COMPAT
6058 Py_LeaveRecursiveCall();
6060 CHECK_OBJECT_X(result);
6062 return Nuitka_CheckFunctionResult(tstate, called, result);
6065 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
6067 if (unlikely(flags & METH_NOARGS)) {
6068 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (7 given)",
6069 ((PyCFunctionObject *)called)->m_ml->ml_name);
6071 }
else if (unlikely(flags & METH_O)) {
6072 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (7 given)",
6073 ((PyCFunctionObject *)called)->m_ml->ml_name);
6075 }
else if (flags & METH_VARARGS) {
6078#ifdef _NUITKA_FULL_COMPAT
6079 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6083 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6084 PyObject *self = PyCFunction_GET_SELF(called);
6088#if PYTHON_VERSION < 0x360
6089 if (flags & METH_KEYWORDS) {
6090 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6092 result = (*method)(self, pos_args);
6096 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
6097 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6098 }
else if (flags == METH_FASTCALL) {
6099#if PYTHON_VERSION < 0x370
6100 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 7, NULL);
6102 result = (*(_PyCFunctionFast)method)(self, &pos_args, 7);
6105 result = (*method)(self, pos_args);
6109#ifdef _NUITKA_FULL_COMPAT
6110 Py_LeaveRecursiveCall();
6113 CHECK_OBJECT_X(result);
6115 return Nuitka_CheckFunctionResult(tstate, called, result);
6119#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
6120 }
else if (PyFunction_Check(called)) {
6121#if PYTHON_VERSION < 0x3b0
6122 PyObject *result = callPythonFunction(called, args, 7);
6124 PyObject *result = _PyFunction_Vectorcall(called, args, 7, NULL);
6126 CHECK_OBJECT_X(result);
6130#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
6131 }
else if (PyType_Check(called)) {
6132 PyTypeObject *type = Py_TYPE(called);
6134 if (type->tp_call == PyType_Type.tp_call) {
6135 PyTypeObject *called_type = (PyTypeObject *)(called);
6137 if (unlikely(called_type->tp_new == NULL)) {
6138 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
6144 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
6145 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
6146 formatCannotInstantiateAbstractClass(tstate, called_type);
6150 obj = called_type->tp_alloc(called_type, 0);
6153 obj = called_type->tp_new(called_type, pos_args, NULL);
6156 if (likely(obj != NULL)) {
6157 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
6162 type = Py_TYPE(obj);
6164 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
6165 if (type->tp_init == default_tp_init_wrapper) {
6167 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
6170 assert(init_method != NULL);
6172 bool is_compiled_function =
false;
6173 bool init_method_needs_release =
false;
6175 if (likely(init_method != NULL)) {
6176 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
6178 if (func == Nuitka_Function_Type.tp_descr_get) {
6179 is_compiled_function =
true;
6180 }
else if (func != NULL) {
6181 init_method = func(init_method, obj, (PyObject *)(type));
6182 init_method_needs_release =
true;
6186 if (unlikely(init_method == NULL)) {
6187 if (!HAS_ERROR_OCCURRED(tstate)) {
6188 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
6189 const_str_plain___init__);
6196 if (is_compiled_function) {
6197 result = Nuitka_CallMethodFunctionPosArgs(
6200 result = CALL_FUNCTION_WITH_POS_ARGS7(tstate, init_method, pos_args);
6201 if (init_method_needs_release) {
6202 Py_DECREF(init_method);
6206 if (unlikely(result == NULL)) {
6213 if (unlikely(result != Py_None)) {
6216 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
6221 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
6229 CHECK_OBJECT_X(obj);
6234#if PYTHON_VERSION < 0x300
6235 }
else if (PyClass_Check(called)) {
6236 PyObject *obj = PyInstance_NewRaw(called, NULL);
6238 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
6240 if (unlikely(init_method == NULL)) {
6241 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
6248 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
6252 bool is_compiled_function =
false;
6254 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
6256 if (descr_get == NULL) {
6257 Py_INCREF(init_method);
6258 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
6259 is_compiled_function =
true;
6260 }
else if (descr_get != NULL) {
6261 PyObject *descr_method = descr_get(init_method, obj, called);
6263 if (unlikely(descr_method == NULL)) {
6267 init_method = descr_method;
6271 if (is_compiled_function) {
6272 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
6275 result = CALL_FUNCTION_WITH_POS_ARGS7(tstate, init_method, pos_args);
6276 Py_DECREF(init_method);
6278 if (unlikely(result == NULL)) {
6284 if (unlikely(result != Py_None)) {
6285 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
6289 CHECK_OBJECT_X(obj);
6293#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
6294 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
6295 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6297 if (likely(func != NULL)) {
6298 PyObject *result = func(called, args, 7, NULL);
6300 CHECK_OBJECT_X(result);
6302 return Nuitka_CheckFunctionResult(tstate, called, result);
6309 PRINT_STRING(
"FALLBACK");
6314 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
6316 CHECK_OBJECT_X(result);
6320PyObject *CALL_FUNCTION_WITH_ARGS8(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
6321 CHECK_OBJECT(called);
6322 CHECK_OBJECTS(args, 8);
6324 if (Nuitka_Function_Check(called)) {
6325 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6332 if (function->m_args_simple && 8 == function->m_args_positional_count) {
6333 for (Py_ssize_t i = 0; i < 8; i++) {
6336 result = function->m_c_code(tstate, function, (PyObject **)args);
6337 }
else if (function->m_args_simple && 8 + function->m_defaults_given == function->m_args_positional_count) {
6338 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6340 memcpy(python_pars, args, 8 *
sizeof(PyObject *));
6341 memcpy(python_pars + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6342 function->m_defaults_given *
sizeof(PyObject *));
6344 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
6345 Py_INCREF(python_pars[i]);
6348 result = function->m_c_code(tstate, function, python_pars);
6350 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 8);
6353 Py_LeaveRecursiveCall();
6355 CHECK_OBJECT_X(result);
6358 }
else if (Nuitka_Method_Check(called)) {
6361 if (method->m_object == NULL) {
6362 PyObject *self = args[0];
6364 int res = PyObject_IsInstance(self, method->m_class);
6366 if (unlikely(res < 0)) {
6368 }
else if (unlikely(res == 0)) {
6369 PyErr_Format(PyExc_TypeError,
6370 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
6371 "instance instead)",
6372 GET_CALLABLE_NAME((PyObject *)method->m_function),
6373 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
6374 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
6379 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 8);
6381 CHECK_OBJECT_X(result);
6385 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6393 if (function->m_args_simple && 8 + 1 == function->m_args_positional_count) {
6394 PyObject *python_pars[8 + 1];
6396 python_pars[0] = method->m_object;
6397 Py_INCREF(method->m_object);
6399 for (Py_ssize_t i = 0; i < 8; i++) {
6400 python_pars[i + 1] = args[i];
6403 result = function->m_c_code(tstate, function, python_pars);
6404 }
else if (function->m_args_simple &&
6405 8 + 1 + function->m_defaults_given == function->m_args_positional_count) {
6406 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6408 python_pars[0] = method->m_object;
6409 Py_INCREF(method->m_object);
6411 memcpy(python_pars + 1, args, 8 *
sizeof(PyObject *));
6412 memcpy(python_pars + 1 + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6413 function->m_defaults_given *
sizeof(PyObject *));
6415 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
6416 Py_INCREF(python_pars[i]);
6419 result = function->m_c_code(tstate, function, python_pars);
6421 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 8);
6424 Py_LeaveRecursiveCall();
6426 CHECK_OBJECT_X(result);
6430#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
6431 }
else if (PyCFunction_CheckExact(called)) {
6432#if PYTHON_VERSION >= 0x380
6433#ifdef _NUITKA_FULL_COMPAT
6434 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6439 int flags = PyCFunction_GET_FLAGS(called);
6443 if (!(flags & METH_VARARGS)) {
6444 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6446 assert(func != NULL);
6447 result = func(called, args, 8, NULL);
6449 CHECK_OBJECT_X(result);
6451 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6452 PyObject *self = PyCFunction_GET_SELF(called);
6454 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6456 if (flags & METH_KEYWORDS) {
6457 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
6459 result = (*method)(self, pos_args);
6462 Py_DECREF(pos_args);
6465#ifdef _NUITKA_FULL_COMPAT
6466 Py_LeaveRecursiveCall();
6468 CHECK_OBJECT_X(result);
6470 return Nuitka_CheckFunctionResult(tstate, called, result);
6473 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
6475 if (unlikely(flags & METH_NOARGS)) {
6476 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (8 given)",
6477 ((PyCFunctionObject *)called)->m_ml->ml_name);
6479 }
else if (unlikely(flags & METH_O)) {
6480 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (8 given)",
6481 ((PyCFunctionObject *)called)->m_ml->ml_name);
6483 }
else if (flags & METH_VARARGS) {
6486#ifdef _NUITKA_FULL_COMPAT
6487 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6491 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6492 PyObject *self = PyCFunction_GET_SELF(called);
6496#if PYTHON_VERSION < 0x360
6497 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6498 if (flags & METH_KEYWORDS) {
6499 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6501 result = (*method)(self, pos_args);
6504 Py_DECREF(pos_args);
6506 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
6507 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6508 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6509 Py_DECREF(pos_args);
6510 }
else if (flags == METH_FASTCALL) {
6511#if PYTHON_VERSION < 0x370
6512 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 8, NULL);
6514 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6515 result = (*(_PyCFunctionFast)method)(self, &pos_args, 8);
6516 Py_DECREF(pos_args);
6519 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6520 result = (*method)(self, pos_args);
6521 Py_DECREF(pos_args);
6525#ifdef _NUITKA_FULL_COMPAT
6526 Py_LeaveRecursiveCall();
6529 CHECK_OBJECT_X(result);
6531 return Nuitka_CheckFunctionResult(tstate, called, result);
6535#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
6536 }
else if (PyFunction_Check(called)) {
6537#if PYTHON_VERSION < 0x3b0
6538 PyObject *result = callPythonFunction(called, args, 8);
6540 PyObject *result = _PyFunction_Vectorcall(called, args, 8, NULL);
6542 CHECK_OBJECT_X(result);
6546#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
6547 }
else if (PyType_Check(called)) {
6548 PyTypeObject *type = Py_TYPE(called);
6550 if (type->tp_call == PyType_Type.tp_call) {
6551 PyTypeObject *called_type = (PyTypeObject *)(called);
6553 if (unlikely(called_type->tp_new == NULL)) {
6554 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
6558 PyObject *pos_args = NULL;
6561 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
6562 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
6563 formatCannotInstantiateAbstractClass(tstate, called_type);
6567 obj = called_type->tp_alloc(called_type, 0);
6570 pos_args = MAKE_TUPLE(tstate, args, 8);
6571 obj = called_type->tp_new(called_type, pos_args, NULL);
6574 if (likely(obj != NULL)) {
6575 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
6576 Py_DECREF(pos_args);
6581 type = Py_TYPE(obj);
6583 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
6584 if (type->tp_init == default_tp_init_wrapper) {
6585 Py_XDECREF(pos_args);
6588 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
6591 assert(init_method != NULL);
6593 bool is_compiled_function =
false;
6594 bool init_method_needs_release =
false;
6596 if (likely(init_method != NULL)) {
6597 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
6599 if (func == Nuitka_Function_Type.tp_descr_get) {
6600 is_compiled_function =
true;
6601 }
else if (func != NULL) {
6602 init_method = func(init_method, obj, (PyObject *)(type));
6603 init_method_needs_release =
true;
6607 if (unlikely(init_method == NULL)) {
6608 if (!HAS_ERROR_OCCURRED(tstate)) {
6609 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
6610 const_str_plain___init__);
6617 if (is_compiled_function) {
6618 result = Nuitka_CallMethodFunctionPosArgs(
6621 result = CALL_FUNCTION_WITH_ARGS8(tstate, init_method, args);
6622 if (init_method_needs_release) {
6623 Py_DECREF(init_method);
6627 if (unlikely(result == NULL)) {
6634 if (unlikely(result != Py_None)) {
6637 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
6641 if (pos_args == NULL) {
6642 pos_args = MAKE_TUPLE(tstate, args, 8);
6645 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
6647 Py_XDECREF(pos_args);
6654 Py_XDECREF(pos_args);
6656 CHECK_OBJECT_X(obj);
6661#if PYTHON_VERSION < 0x300
6662 }
else if (PyClass_Check(called)) {
6663 PyObject *obj = PyInstance_NewRaw(called, NULL);
6665 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
6667 if (unlikely(init_method == NULL)) {
6668 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
6675 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
6679 bool is_compiled_function =
false;
6681 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
6683 if (descr_get == NULL) {
6684 Py_INCREF(init_method);
6685 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
6686 is_compiled_function =
true;
6687 }
else if (descr_get != NULL) {
6688 PyObject *descr_method = descr_get(init_method, obj, called);
6690 if (unlikely(descr_method == NULL)) {
6694 init_method = descr_method;
6698 if (is_compiled_function) {
6699 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
6702 result = CALL_FUNCTION_WITH_ARGS8(tstate, init_method, args);
6703 Py_DECREF(init_method);
6705 if (unlikely(result == NULL)) {
6711 if (unlikely(result != Py_None)) {
6712 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
6716 CHECK_OBJECT_X(obj);
6720#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
6721 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
6722 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6724 if (likely(func != NULL)) {
6725 PyObject *result = func(called, args, 8, NULL);
6727 CHECK_OBJECT_X(result);
6729 return Nuitka_CheckFunctionResult(tstate, called, result);
6736 PRINT_STRING(
"FALLBACK");
6741 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6743 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
6745 Py_DECREF(pos_args);
6747 CHECK_OBJECT_X(result);
6751PyObject *CALL_FUNCTION_WITH_POS_ARGS8(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
6752 assert(PyTuple_CheckExact(pos_args));
6753 assert(PyTuple_GET_SIZE(pos_args) == 8);
6754 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
6755 CHECK_OBJECT(called);
6756 CHECK_OBJECTS(args, 8);
6758 if (Nuitka_Function_Check(called)) {
6759 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6766 if (function->m_args_simple && 8 == function->m_args_positional_count) {
6767 for (Py_ssize_t i = 0; i < 8; i++) {
6770 result = function->m_c_code(tstate, function, (PyObject **)args);
6771 }
else if (function->m_args_simple && 8 + function->m_defaults_given == function->m_args_positional_count) {
6772 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6774 memcpy(python_pars, args, 8 *
sizeof(PyObject *));
6775 memcpy(python_pars + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6776 function->m_defaults_given *
sizeof(PyObject *));
6778 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
6779 Py_INCREF(python_pars[i]);
6782 result = function->m_c_code(tstate, function, python_pars);
6784 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 8);
6787 Py_LeaveRecursiveCall();
6789 CHECK_OBJECT_X(result);
6792 }
else if (Nuitka_Method_Check(called)) {
6795 if (method->m_object == NULL) {
6796 PyObject *self = args[0];
6798 int res = PyObject_IsInstance(self, method->m_class);
6800 if (unlikely(res < 0)) {
6802 }
else if (unlikely(res == 0)) {
6803 PyErr_Format(PyExc_TypeError,
6804 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
6805 "instance instead)",
6806 GET_CALLABLE_NAME((PyObject *)method->m_function),
6807 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
6808 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
6813 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 8);
6815 CHECK_OBJECT_X(result);
6819 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6827 if (function->m_args_simple && 8 + 1 == function->m_args_positional_count) {
6828 PyObject *python_pars[8 + 1];
6830 python_pars[0] = method->m_object;
6831 Py_INCREF(method->m_object);
6833 for (Py_ssize_t i = 0; i < 8; i++) {
6834 python_pars[i + 1] = args[i];
6837 result = function->m_c_code(tstate, function, python_pars);
6838 }
else if (function->m_args_simple &&
6839 8 + 1 + function->m_defaults_given == function->m_args_positional_count) {
6840 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6842 python_pars[0] = method->m_object;
6843 Py_INCREF(method->m_object);
6845 memcpy(python_pars + 1, args, 8 *
sizeof(PyObject *));
6846 memcpy(python_pars + 1 + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6847 function->m_defaults_given *
sizeof(PyObject *));
6849 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
6850 Py_INCREF(python_pars[i]);
6853 result = function->m_c_code(tstate, function, python_pars);
6855 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 8);
6858 Py_LeaveRecursiveCall();
6860 CHECK_OBJECT_X(result);
6864#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
6865 }
else if (PyCFunction_CheckExact(called)) {
6866#if PYTHON_VERSION >= 0x380
6867#ifdef _NUITKA_FULL_COMPAT
6868 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6873 int flags = PyCFunction_GET_FLAGS(called);
6877 if (!(flags & METH_VARARGS)) {
6878 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6880 assert(func != NULL);
6881 result = func(called, args, 8, NULL);
6883 CHECK_OBJECT_X(result);
6885 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6886 PyObject *self = PyCFunction_GET_SELF(called);
6888 if (flags & METH_KEYWORDS) {
6889 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
6891 result = (*method)(self, pos_args);
6895#ifdef _NUITKA_FULL_COMPAT
6896 Py_LeaveRecursiveCall();
6898 CHECK_OBJECT_X(result);
6900 return Nuitka_CheckFunctionResult(tstate, called, result);
6903 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
6905 if (unlikely(flags & METH_NOARGS)) {
6906 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (8 given)",
6907 ((PyCFunctionObject *)called)->m_ml->ml_name);
6909 }
else if (unlikely(flags & METH_O)) {
6910 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (8 given)",
6911 ((PyCFunctionObject *)called)->m_ml->ml_name);
6913 }
else if (flags & METH_VARARGS) {
6916#ifdef _NUITKA_FULL_COMPAT
6917 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6921 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6922 PyObject *self = PyCFunction_GET_SELF(called);
6926#if PYTHON_VERSION < 0x360
6927 if (flags & METH_KEYWORDS) {
6928 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6930 result = (*method)(self, pos_args);
6934 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
6935 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6936 }
else if (flags == METH_FASTCALL) {
6937#if PYTHON_VERSION < 0x370
6938 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 8, NULL);
6940 result = (*(_PyCFunctionFast)method)(self, &pos_args, 8);
6943 result = (*method)(self, pos_args);
6947#ifdef _NUITKA_FULL_COMPAT
6948 Py_LeaveRecursiveCall();
6951 CHECK_OBJECT_X(result);
6953 return Nuitka_CheckFunctionResult(tstate, called, result);
6957#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
6958 }
else if (PyFunction_Check(called)) {
6959#if PYTHON_VERSION < 0x3b0
6960 PyObject *result = callPythonFunction(called, args, 8);
6962 PyObject *result = _PyFunction_Vectorcall(called, args, 8, NULL);
6964 CHECK_OBJECT_X(result);
6968#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
6969 }
else if (PyType_Check(called)) {
6970 PyTypeObject *type = Py_TYPE(called);
6972 if (type->tp_call == PyType_Type.tp_call) {
6973 PyTypeObject *called_type = (PyTypeObject *)(called);
6975 if (unlikely(called_type->tp_new == NULL)) {
6976 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
6982 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
6983 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
6984 formatCannotInstantiateAbstractClass(tstate, called_type);
6988 obj = called_type->tp_alloc(called_type, 0);
6991 obj = called_type->tp_new(called_type, pos_args, NULL);
6994 if (likely(obj != NULL)) {
6995 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
7000 type = Py_TYPE(obj);
7002 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
7003 if (type->tp_init == default_tp_init_wrapper) {
7005 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
7008 assert(init_method != NULL);
7010 bool is_compiled_function =
false;
7011 bool init_method_needs_release =
false;
7013 if (likely(init_method != NULL)) {
7014 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
7016 if (func == Nuitka_Function_Type.tp_descr_get) {
7017 is_compiled_function =
true;
7018 }
else if (func != NULL) {
7019 init_method = func(init_method, obj, (PyObject *)(type));
7020 init_method_needs_release =
true;
7024 if (unlikely(init_method == NULL)) {
7025 if (!HAS_ERROR_OCCURRED(tstate)) {
7026 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
7027 const_str_plain___init__);
7034 if (is_compiled_function) {
7035 result = Nuitka_CallMethodFunctionPosArgs(
7038 result = CALL_FUNCTION_WITH_POS_ARGS8(tstate, init_method, pos_args);
7039 if (init_method_needs_release) {
7040 Py_DECREF(init_method);
7044 if (unlikely(result == NULL)) {
7051 if (unlikely(result != Py_None)) {
7054 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7059 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
7067 CHECK_OBJECT_X(obj);
7072#if PYTHON_VERSION < 0x300
7073 }
else if (PyClass_Check(called)) {
7074 PyObject *obj = PyInstance_NewRaw(called, NULL);
7076 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
7078 if (unlikely(init_method == NULL)) {
7079 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
7086 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
7090 bool is_compiled_function =
false;
7092 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
7094 if (descr_get == NULL) {
7095 Py_INCREF(init_method);
7096 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
7097 is_compiled_function =
true;
7098 }
else if (descr_get != NULL) {
7099 PyObject *descr_method = descr_get(init_method, obj, called);
7101 if (unlikely(descr_method == NULL)) {
7105 init_method = descr_method;
7109 if (is_compiled_function) {
7110 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
7113 result = CALL_FUNCTION_WITH_POS_ARGS8(tstate, init_method, pos_args);
7114 Py_DECREF(init_method);
7116 if (unlikely(result == NULL)) {
7122 if (unlikely(result != Py_None)) {
7123 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7127 CHECK_OBJECT_X(obj);
7131#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
7132 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
7133 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7135 if (likely(func != NULL)) {
7136 PyObject *result = func(called, args, 8, NULL);
7138 CHECK_OBJECT_X(result);
7140 return Nuitka_CheckFunctionResult(tstate, called, result);
7147 PRINT_STRING(
"FALLBACK");
7152 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
7154 CHECK_OBJECT_X(result);
7158PyObject *CALL_FUNCTION_WITH_ARGS9(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
7159 CHECK_OBJECT(called);
7160 CHECK_OBJECTS(args, 9);
7162 if (Nuitka_Function_Check(called)) {
7163 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7170 if (function->m_args_simple && 9 == function->m_args_positional_count) {
7171 for (Py_ssize_t i = 0; i < 9; i++) {
7174 result = function->m_c_code(tstate, function, (PyObject **)args);
7175 }
else if (function->m_args_simple && 9 + function->m_defaults_given == function->m_args_positional_count) {
7176 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7178 memcpy(python_pars, args, 9 *
sizeof(PyObject *));
7179 memcpy(python_pars + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7180 function->m_defaults_given *
sizeof(PyObject *));
7182 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
7183 Py_INCREF(python_pars[i]);
7186 result = function->m_c_code(tstate, function, python_pars);
7188 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 9);
7191 Py_LeaveRecursiveCall();
7193 CHECK_OBJECT_X(result);
7196 }
else if (Nuitka_Method_Check(called)) {
7199 if (method->m_object == NULL) {
7200 PyObject *self = args[0];
7202 int res = PyObject_IsInstance(self, method->m_class);
7204 if (unlikely(res < 0)) {
7206 }
else if (unlikely(res == 0)) {
7207 PyErr_Format(PyExc_TypeError,
7208 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
7209 "instance instead)",
7210 GET_CALLABLE_NAME((PyObject *)method->m_function),
7211 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
7212 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
7217 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 9);
7219 CHECK_OBJECT_X(result);
7223 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7231 if (function->m_args_simple && 9 + 1 == function->m_args_positional_count) {
7232 PyObject *python_pars[9 + 1];
7234 python_pars[0] = method->m_object;
7235 Py_INCREF(method->m_object);
7237 for (Py_ssize_t i = 0; i < 9; i++) {
7238 python_pars[i + 1] = args[i];
7241 result = function->m_c_code(tstate, function, python_pars);
7242 }
else if (function->m_args_simple &&
7243 9 + 1 + function->m_defaults_given == function->m_args_positional_count) {
7244 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7246 python_pars[0] = method->m_object;
7247 Py_INCREF(method->m_object);
7249 memcpy(python_pars + 1, args, 9 *
sizeof(PyObject *));
7250 memcpy(python_pars + 1 + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7251 function->m_defaults_given *
sizeof(PyObject *));
7253 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
7254 Py_INCREF(python_pars[i]);
7257 result = function->m_c_code(tstate, function, python_pars);
7259 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 9);
7262 Py_LeaveRecursiveCall();
7264 CHECK_OBJECT_X(result);
7268#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
7269 }
else if (PyCFunction_CheckExact(called)) {
7270#if PYTHON_VERSION >= 0x380
7271#ifdef _NUITKA_FULL_COMPAT
7272 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7277 int flags = PyCFunction_GET_FLAGS(called);
7281 if (!(flags & METH_VARARGS)) {
7282 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7284 assert(func != NULL);
7285 result = func(called, args, 9, NULL);
7287 CHECK_OBJECT_X(result);
7289 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7290 PyObject *self = PyCFunction_GET_SELF(called);
7292 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7294 if (flags & METH_KEYWORDS) {
7295 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
7297 result = (*method)(self, pos_args);
7300 Py_DECREF(pos_args);
7303#ifdef _NUITKA_FULL_COMPAT
7304 Py_LeaveRecursiveCall();
7306 CHECK_OBJECT_X(result);
7308 return Nuitka_CheckFunctionResult(tstate, called, result);
7311 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
7313 if (unlikely(flags & METH_NOARGS)) {
7314 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (9 given)",
7315 ((PyCFunctionObject *)called)->m_ml->ml_name);
7317 }
else if (unlikely(flags & METH_O)) {
7318 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (9 given)",
7319 ((PyCFunctionObject *)called)->m_ml->ml_name);
7321 }
else if (flags & METH_VARARGS) {
7324#ifdef _NUITKA_FULL_COMPAT
7325 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7329 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7330 PyObject *self = PyCFunction_GET_SELF(called);
7334#if PYTHON_VERSION < 0x360
7335 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7336 if (flags & METH_KEYWORDS) {
7337 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7339 result = (*method)(self, pos_args);
7342 Py_DECREF(pos_args);
7344 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
7345 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7346 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7347 Py_DECREF(pos_args);
7348 }
else if (flags == METH_FASTCALL) {
7349#if PYTHON_VERSION < 0x370
7350 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 9, NULL);
7352 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7353 result = (*(_PyCFunctionFast)method)(self, &pos_args, 9);
7354 Py_DECREF(pos_args);
7357 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7358 result = (*method)(self, pos_args);
7359 Py_DECREF(pos_args);
7363#ifdef _NUITKA_FULL_COMPAT
7364 Py_LeaveRecursiveCall();
7367 CHECK_OBJECT_X(result);
7369 return Nuitka_CheckFunctionResult(tstate, called, result);
7373#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
7374 }
else if (PyFunction_Check(called)) {
7375#if PYTHON_VERSION < 0x3b0
7376 PyObject *result = callPythonFunction(called, args, 9);
7378 PyObject *result = _PyFunction_Vectorcall(called, args, 9, NULL);
7380 CHECK_OBJECT_X(result);
7384#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
7385 }
else if (PyType_Check(called)) {
7386 PyTypeObject *type = Py_TYPE(called);
7388 if (type->tp_call == PyType_Type.tp_call) {
7389 PyTypeObject *called_type = (PyTypeObject *)(called);
7391 if (unlikely(called_type->tp_new == NULL)) {
7392 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
7396 PyObject *pos_args = NULL;
7399 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
7400 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
7401 formatCannotInstantiateAbstractClass(tstate, called_type);
7405 obj = called_type->tp_alloc(called_type, 0);
7408 pos_args = MAKE_TUPLE(tstate, args, 9);
7409 obj = called_type->tp_new(called_type, pos_args, NULL);
7412 if (likely(obj != NULL)) {
7413 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
7414 Py_DECREF(pos_args);
7419 type = Py_TYPE(obj);
7421 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
7422 if (type->tp_init == default_tp_init_wrapper) {
7423 Py_XDECREF(pos_args);
7426 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
7429 assert(init_method != NULL);
7431 bool is_compiled_function =
false;
7432 bool init_method_needs_release =
false;
7434 if (likely(init_method != NULL)) {
7435 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
7437 if (func == Nuitka_Function_Type.tp_descr_get) {
7438 is_compiled_function =
true;
7439 }
else if (func != NULL) {
7440 init_method = func(init_method, obj, (PyObject *)(type));
7441 init_method_needs_release =
true;
7445 if (unlikely(init_method == NULL)) {
7446 if (!HAS_ERROR_OCCURRED(tstate)) {
7447 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
7448 const_str_plain___init__);
7455 if (is_compiled_function) {
7456 result = Nuitka_CallMethodFunctionPosArgs(
7459 result = CALL_FUNCTION_WITH_ARGS9(tstate, init_method, args);
7460 if (init_method_needs_release) {
7461 Py_DECREF(init_method);
7465 if (unlikely(result == NULL)) {
7472 if (unlikely(result != Py_None)) {
7475 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7479 if (pos_args == NULL) {
7480 pos_args = MAKE_TUPLE(tstate, args, 9);
7483 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
7485 Py_XDECREF(pos_args);
7492 Py_XDECREF(pos_args);
7494 CHECK_OBJECT_X(obj);
7499#if PYTHON_VERSION < 0x300
7500 }
else if (PyClass_Check(called)) {
7501 PyObject *obj = PyInstance_NewRaw(called, NULL);
7503 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
7505 if (unlikely(init_method == NULL)) {
7506 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
7513 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
7517 bool is_compiled_function =
false;
7519 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
7521 if (descr_get == NULL) {
7522 Py_INCREF(init_method);
7523 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
7524 is_compiled_function =
true;
7525 }
else if (descr_get != NULL) {
7526 PyObject *descr_method = descr_get(init_method, obj, called);
7528 if (unlikely(descr_method == NULL)) {
7532 init_method = descr_method;
7536 if (is_compiled_function) {
7537 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
7540 result = CALL_FUNCTION_WITH_ARGS9(tstate, init_method, args);
7541 Py_DECREF(init_method);
7543 if (unlikely(result == NULL)) {
7549 if (unlikely(result != Py_None)) {
7550 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7554 CHECK_OBJECT_X(obj);
7558#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
7559 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
7560 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7562 if (likely(func != NULL)) {
7563 PyObject *result = func(called, args, 9, NULL);
7565 CHECK_OBJECT_X(result);
7567 return Nuitka_CheckFunctionResult(tstate, called, result);
7574 PRINT_STRING(
"FALLBACK");
7579 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7581 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
7583 Py_DECREF(pos_args);
7585 CHECK_OBJECT_X(result);
7589PyObject *CALL_FUNCTION_WITH_POS_ARGS9(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
7590 assert(PyTuple_CheckExact(pos_args));
7591 assert(PyTuple_GET_SIZE(pos_args) == 9);
7592 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
7593 CHECK_OBJECT(called);
7594 CHECK_OBJECTS(args, 9);
7596 if (Nuitka_Function_Check(called)) {
7597 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7604 if (function->m_args_simple && 9 == function->m_args_positional_count) {
7605 for (Py_ssize_t i = 0; i < 9; i++) {
7608 result = function->m_c_code(tstate, function, (PyObject **)args);
7609 }
else if (function->m_args_simple && 9 + function->m_defaults_given == function->m_args_positional_count) {
7610 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7612 memcpy(python_pars, args, 9 *
sizeof(PyObject *));
7613 memcpy(python_pars + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7614 function->m_defaults_given *
sizeof(PyObject *));
7616 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
7617 Py_INCREF(python_pars[i]);
7620 result = function->m_c_code(tstate, function, python_pars);
7622 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 9);
7625 Py_LeaveRecursiveCall();
7627 CHECK_OBJECT_X(result);
7630 }
else if (Nuitka_Method_Check(called)) {
7633 if (method->m_object == NULL) {
7634 PyObject *self = args[0];
7636 int res = PyObject_IsInstance(self, method->m_class);
7638 if (unlikely(res < 0)) {
7640 }
else if (unlikely(res == 0)) {
7641 PyErr_Format(PyExc_TypeError,
7642 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
7643 "instance instead)",
7644 GET_CALLABLE_NAME((PyObject *)method->m_function),
7645 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
7646 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
7651 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 9);
7653 CHECK_OBJECT_X(result);
7657 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7665 if (function->m_args_simple && 9 + 1 == function->m_args_positional_count) {
7666 PyObject *python_pars[9 + 1];
7668 python_pars[0] = method->m_object;
7669 Py_INCREF(method->m_object);
7671 for (Py_ssize_t i = 0; i < 9; i++) {
7672 python_pars[i + 1] = args[i];
7675 result = function->m_c_code(tstate, function, python_pars);
7676 }
else if (function->m_args_simple &&
7677 9 + 1 + function->m_defaults_given == function->m_args_positional_count) {
7678 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7680 python_pars[0] = method->m_object;
7681 Py_INCREF(method->m_object);
7683 memcpy(python_pars + 1, args, 9 *
sizeof(PyObject *));
7684 memcpy(python_pars + 1 + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7685 function->m_defaults_given *
sizeof(PyObject *));
7687 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
7688 Py_INCREF(python_pars[i]);
7691 result = function->m_c_code(tstate, function, python_pars);
7693 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 9);
7696 Py_LeaveRecursiveCall();
7698 CHECK_OBJECT_X(result);
7702#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
7703 }
else if (PyCFunction_CheckExact(called)) {
7704#if PYTHON_VERSION >= 0x380
7705#ifdef _NUITKA_FULL_COMPAT
7706 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7711 int flags = PyCFunction_GET_FLAGS(called);
7715 if (!(flags & METH_VARARGS)) {
7716 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7718 assert(func != NULL);
7719 result = func(called, args, 9, NULL);
7721 CHECK_OBJECT_X(result);
7723 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7724 PyObject *self = PyCFunction_GET_SELF(called);
7726 if (flags & METH_KEYWORDS) {
7727 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
7729 result = (*method)(self, pos_args);
7733#ifdef _NUITKA_FULL_COMPAT
7734 Py_LeaveRecursiveCall();
7736 CHECK_OBJECT_X(result);
7738 return Nuitka_CheckFunctionResult(tstate, called, result);
7741 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
7743 if (unlikely(flags & METH_NOARGS)) {
7744 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (9 given)",
7745 ((PyCFunctionObject *)called)->m_ml->ml_name);
7747 }
else if (unlikely(flags & METH_O)) {
7748 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (9 given)",
7749 ((PyCFunctionObject *)called)->m_ml->ml_name);
7751 }
else if (flags & METH_VARARGS) {
7754#ifdef _NUITKA_FULL_COMPAT
7755 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7759 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7760 PyObject *self = PyCFunction_GET_SELF(called);
7764#if PYTHON_VERSION < 0x360
7765 if (flags & METH_KEYWORDS) {
7766 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7768 result = (*method)(self, pos_args);
7772 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
7773 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7774 }
else if (flags == METH_FASTCALL) {
7775#if PYTHON_VERSION < 0x370
7776 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 9, NULL);
7778 result = (*(_PyCFunctionFast)method)(self, &pos_args, 9);
7781 result = (*method)(self, pos_args);
7785#ifdef _NUITKA_FULL_COMPAT
7786 Py_LeaveRecursiveCall();
7789 CHECK_OBJECT_X(result);
7791 return Nuitka_CheckFunctionResult(tstate, called, result);
7795#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
7796 }
else if (PyFunction_Check(called)) {
7797#if PYTHON_VERSION < 0x3b0
7798 PyObject *result = callPythonFunction(called, args, 9);
7800 PyObject *result = _PyFunction_Vectorcall(called, args, 9, NULL);
7802 CHECK_OBJECT_X(result);
7806#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
7807 }
else if (PyType_Check(called)) {
7808 PyTypeObject *type = Py_TYPE(called);
7810 if (type->tp_call == PyType_Type.tp_call) {
7811 PyTypeObject *called_type = (PyTypeObject *)(called);
7813 if (unlikely(called_type->tp_new == NULL)) {
7814 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
7820 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
7821 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
7822 formatCannotInstantiateAbstractClass(tstate, called_type);
7826 obj = called_type->tp_alloc(called_type, 0);
7829 obj = called_type->tp_new(called_type, pos_args, NULL);
7832 if (likely(obj != NULL)) {
7833 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
7838 type = Py_TYPE(obj);
7840 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
7841 if (type->tp_init == default_tp_init_wrapper) {
7843 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
7846 assert(init_method != NULL);
7848 bool is_compiled_function =
false;
7849 bool init_method_needs_release =
false;
7851 if (likely(init_method != NULL)) {
7852 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
7854 if (func == Nuitka_Function_Type.tp_descr_get) {
7855 is_compiled_function =
true;
7856 }
else if (func != NULL) {
7857 init_method = func(init_method, obj, (PyObject *)(type));
7858 init_method_needs_release =
true;
7862 if (unlikely(init_method == NULL)) {
7863 if (!HAS_ERROR_OCCURRED(tstate)) {
7864 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
7865 const_str_plain___init__);
7872 if (is_compiled_function) {
7873 result = Nuitka_CallMethodFunctionPosArgs(
7876 result = CALL_FUNCTION_WITH_POS_ARGS9(tstate, init_method, pos_args);
7877 if (init_method_needs_release) {
7878 Py_DECREF(init_method);
7882 if (unlikely(result == NULL)) {
7889 if (unlikely(result != Py_None)) {
7892 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7897 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
7905 CHECK_OBJECT_X(obj);
7910#if PYTHON_VERSION < 0x300
7911 }
else if (PyClass_Check(called)) {
7912 PyObject *obj = PyInstance_NewRaw(called, NULL);
7914 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
7916 if (unlikely(init_method == NULL)) {
7917 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
7924 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
7928 bool is_compiled_function =
false;
7930 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
7932 if (descr_get == NULL) {
7933 Py_INCREF(init_method);
7934 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
7935 is_compiled_function =
true;
7936 }
else if (descr_get != NULL) {
7937 PyObject *descr_method = descr_get(init_method, obj, called);
7939 if (unlikely(descr_method == NULL)) {
7943 init_method = descr_method;
7947 if (is_compiled_function) {
7948 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
7951 result = CALL_FUNCTION_WITH_POS_ARGS9(tstate, init_method, pos_args);
7952 Py_DECREF(init_method);
7954 if (unlikely(result == NULL)) {
7960 if (unlikely(result != Py_None)) {
7961 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7965 CHECK_OBJECT_X(obj);
7969#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
7970 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
7971 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7973 if (likely(func != NULL)) {
7974 PyObject *result = func(called, args, 9, NULL);
7976 CHECK_OBJECT_X(result);
7978 return Nuitka_CheckFunctionResult(tstate, called, result);
7985 PRINT_STRING(
"FALLBACK");
7990 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
7992 CHECK_OBJECT_X(result);
7996PyObject *CALL_FUNCTION_WITH_ARGS10(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
7997 CHECK_OBJECT(called);
7998 CHECK_OBJECTS(args, 10);
8000 if (Nuitka_Function_Check(called)) {
8001 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8008 if (function->m_args_simple && 10 == function->m_args_positional_count) {
8009 for (Py_ssize_t i = 0; i < 10; i++) {
8012 result = function->m_c_code(tstate, function, (PyObject **)args);
8013 }
else if (function->m_args_simple && 10 + function->m_defaults_given == function->m_args_positional_count) {
8014 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8016 memcpy(python_pars, args, 10 *
sizeof(PyObject *));
8017 memcpy(python_pars + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8018 function->m_defaults_given *
sizeof(PyObject *));
8020 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
8021 Py_INCREF(python_pars[i]);
8024 result = function->m_c_code(tstate, function, python_pars);
8026 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 10);
8029 Py_LeaveRecursiveCall();
8031 CHECK_OBJECT_X(result);
8034 }
else if (Nuitka_Method_Check(called)) {
8037 if (method->m_object == NULL) {
8038 PyObject *self = args[0];
8040 int res = PyObject_IsInstance(self, method->m_class);
8042 if (unlikely(res < 0)) {
8044 }
else if (unlikely(res == 0)) {
8045 PyErr_Format(PyExc_TypeError,
8046 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
8047 "instance instead)",
8048 GET_CALLABLE_NAME((PyObject *)method->m_function),
8049 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
8050 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
8055 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 10);
8057 CHECK_OBJECT_X(result);
8061 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8069 if (function->m_args_simple && 10 + 1 == function->m_args_positional_count) {
8070 PyObject *python_pars[10 + 1];
8072 python_pars[0] = method->m_object;
8073 Py_INCREF(method->m_object);
8075 for (Py_ssize_t i = 0; i < 10; i++) {
8076 python_pars[i + 1] = args[i];
8079 result = function->m_c_code(tstate, function, python_pars);
8080 }
else if (function->m_args_simple &&
8081 10 + 1 + function->m_defaults_given == function->m_args_positional_count) {
8082 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8084 python_pars[0] = method->m_object;
8085 Py_INCREF(method->m_object);
8087 memcpy(python_pars + 1, args, 10 *
sizeof(PyObject *));
8088 memcpy(python_pars + 1 + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8089 function->m_defaults_given *
sizeof(PyObject *));
8091 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
8092 Py_INCREF(python_pars[i]);
8095 result = function->m_c_code(tstate, function, python_pars);
8097 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 10);
8100 Py_LeaveRecursiveCall();
8102 CHECK_OBJECT_X(result);
8106#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
8107 }
else if (PyCFunction_CheckExact(called)) {
8108#if PYTHON_VERSION >= 0x380
8109#ifdef _NUITKA_FULL_COMPAT
8110 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8115 int flags = PyCFunction_GET_FLAGS(called);
8119 if (!(flags & METH_VARARGS)) {
8120 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8122 assert(func != NULL);
8123 result = func(called, args, 10, NULL);
8125 CHECK_OBJECT_X(result);
8127 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8128 PyObject *self = PyCFunction_GET_SELF(called);
8130 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8132 if (flags & METH_KEYWORDS) {
8133 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
8135 result = (*method)(self, pos_args);
8138 Py_DECREF(pos_args);
8141#ifdef _NUITKA_FULL_COMPAT
8142 Py_LeaveRecursiveCall();
8144 CHECK_OBJECT_X(result);
8146 return Nuitka_CheckFunctionResult(tstate, called, result);
8149 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
8151 if (unlikely(flags & METH_NOARGS)) {
8152 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (10 given)",
8153 ((PyCFunctionObject *)called)->m_ml->ml_name);
8155 }
else if (unlikely(flags & METH_O)) {
8156 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (10 given)",
8157 ((PyCFunctionObject *)called)->m_ml->ml_name);
8159 }
else if (flags & METH_VARARGS) {
8162#ifdef _NUITKA_FULL_COMPAT
8163 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8167 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8168 PyObject *self = PyCFunction_GET_SELF(called);
8172#if PYTHON_VERSION < 0x360
8173 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8174 if (flags & METH_KEYWORDS) {
8175 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8177 result = (*method)(self, pos_args);
8180 Py_DECREF(pos_args);
8182 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
8183 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8184 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8185 Py_DECREF(pos_args);
8186 }
else if (flags == METH_FASTCALL) {
8187#if PYTHON_VERSION < 0x370
8188 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 10, NULL);
8190 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8191 result = (*(_PyCFunctionFast)method)(self, &pos_args, 10);
8192 Py_DECREF(pos_args);
8195 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8196 result = (*method)(self, pos_args);
8197 Py_DECREF(pos_args);
8201#ifdef _NUITKA_FULL_COMPAT
8202 Py_LeaveRecursiveCall();
8205 CHECK_OBJECT_X(result);
8207 return Nuitka_CheckFunctionResult(tstate, called, result);
8211#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
8212 }
else if (PyFunction_Check(called)) {
8213#if PYTHON_VERSION < 0x3b0
8214 PyObject *result = callPythonFunction(called, args, 10);
8216 PyObject *result = _PyFunction_Vectorcall(called, args, 10, NULL);
8218 CHECK_OBJECT_X(result);
8222#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
8223 }
else if (PyType_Check(called)) {
8224 PyTypeObject *type = Py_TYPE(called);
8226 if (type->tp_call == PyType_Type.tp_call) {
8227 PyTypeObject *called_type = (PyTypeObject *)(called);
8229 if (unlikely(called_type->tp_new == NULL)) {
8230 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
8234 PyObject *pos_args = NULL;
8237 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
8238 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
8239 formatCannotInstantiateAbstractClass(tstate, called_type);
8243 obj = called_type->tp_alloc(called_type, 0);
8246 pos_args = MAKE_TUPLE(tstate, args, 10);
8247 obj = called_type->tp_new(called_type, pos_args, NULL);
8250 if (likely(obj != NULL)) {
8251 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
8252 Py_DECREF(pos_args);
8257 type = Py_TYPE(obj);
8259 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
8260 if (type->tp_init == default_tp_init_wrapper) {
8261 Py_XDECREF(pos_args);
8264 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
8267 assert(init_method != NULL);
8269 bool is_compiled_function =
false;
8270 bool init_method_needs_release =
false;
8272 if (likely(init_method != NULL)) {
8273 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
8275 if (func == Nuitka_Function_Type.tp_descr_get) {
8276 is_compiled_function =
true;
8277 }
else if (func != NULL) {
8278 init_method = func(init_method, obj, (PyObject *)(type));
8279 init_method_needs_release =
true;
8283 if (unlikely(init_method == NULL)) {
8284 if (!HAS_ERROR_OCCURRED(tstate)) {
8285 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
8286 const_str_plain___init__);
8293 if (is_compiled_function) {
8294 result = Nuitka_CallMethodFunctionPosArgs(
8297 result = CALL_FUNCTION_WITH_ARGS10(tstate, init_method, args);
8298 if (init_method_needs_release) {
8299 Py_DECREF(init_method);
8303 if (unlikely(result == NULL)) {
8310 if (unlikely(result != Py_None)) {
8313 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
8317 if (pos_args == NULL) {
8318 pos_args = MAKE_TUPLE(tstate, args, 10);
8321 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
8323 Py_XDECREF(pos_args);
8330 Py_XDECREF(pos_args);
8332 CHECK_OBJECT_X(obj);
8337#if PYTHON_VERSION < 0x300
8338 }
else if (PyClass_Check(called)) {
8339 PyObject *obj = PyInstance_NewRaw(called, NULL);
8341 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
8343 if (unlikely(init_method == NULL)) {
8344 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
8351 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
8355 bool is_compiled_function =
false;
8357 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
8359 if (descr_get == NULL) {
8360 Py_INCREF(init_method);
8361 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
8362 is_compiled_function =
true;
8363 }
else if (descr_get != NULL) {
8364 PyObject *descr_method = descr_get(init_method, obj, called);
8366 if (unlikely(descr_method == NULL)) {
8370 init_method = descr_method;
8374 if (is_compiled_function) {
8375 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
8378 result = CALL_FUNCTION_WITH_ARGS10(tstate, init_method, args);
8379 Py_DECREF(init_method);
8381 if (unlikely(result == NULL)) {
8387 if (unlikely(result != Py_None)) {
8388 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
8392 CHECK_OBJECT_X(obj);
8396#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8397 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8398 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8400 if (likely(func != NULL)) {
8401 PyObject *result = func(called, args, 10, NULL);
8403 CHECK_OBJECT_X(result);
8405 return Nuitka_CheckFunctionResult(tstate, called, result);
8412 PRINT_STRING(
"FALLBACK");
8417 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8419 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
8421 Py_DECREF(pos_args);
8423 CHECK_OBJECT_X(result);
8427PyObject *CALL_FUNCTION_WITH_POS_ARGS10(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
8428 assert(PyTuple_CheckExact(pos_args));
8429 assert(PyTuple_GET_SIZE(pos_args) == 10);
8430 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
8431 CHECK_OBJECT(called);
8432 CHECK_OBJECTS(args, 10);
8434 if (Nuitka_Function_Check(called)) {
8435 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8442 if (function->m_args_simple && 10 == function->m_args_positional_count) {
8443 for (Py_ssize_t i = 0; i < 10; i++) {
8446 result = function->m_c_code(tstate, function, (PyObject **)args);
8447 }
else if (function->m_args_simple && 10 + function->m_defaults_given == function->m_args_positional_count) {
8448 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8450 memcpy(python_pars, args, 10 *
sizeof(PyObject *));
8451 memcpy(python_pars + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8452 function->m_defaults_given *
sizeof(PyObject *));
8454 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
8455 Py_INCREF(python_pars[i]);
8458 result = function->m_c_code(tstate, function, python_pars);
8460 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 10);
8463 Py_LeaveRecursiveCall();
8465 CHECK_OBJECT_X(result);
8468 }
else if (Nuitka_Method_Check(called)) {
8471 if (method->m_object == NULL) {
8472 PyObject *self = args[0];
8474 int res = PyObject_IsInstance(self, method->m_class);
8476 if (unlikely(res < 0)) {
8478 }
else if (unlikely(res == 0)) {
8479 PyErr_Format(PyExc_TypeError,
8480 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
8481 "instance instead)",
8482 GET_CALLABLE_NAME((PyObject *)method->m_function),
8483 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
8484 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
8489 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 10);
8491 CHECK_OBJECT_X(result);
8495 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8503 if (function->m_args_simple && 10 + 1 == function->m_args_positional_count) {
8504 PyObject *python_pars[10 + 1];
8506 python_pars[0] = method->m_object;
8507 Py_INCREF(method->m_object);
8509 for (Py_ssize_t i = 0; i < 10; i++) {
8510 python_pars[i + 1] = args[i];
8513 result = function->m_c_code(tstate, function, python_pars);
8514 }
else if (function->m_args_simple &&
8515 10 + 1 + function->m_defaults_given == function->m_args_positional_count) {
8516 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8518 python_pars[0] = method->m_object;
8519 Py_INCREF(method->m_object);
8521 memcpy(python_pars + 1, args, 10 *
sizeof(PyObject *));
8522 memcpy(python_pars + 1 + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8523 function->m_defaults_given *
sizeof(PyObject *));
8525 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
8526 Py_INCREF(python_pars[i]);
8529 result = function->m_c_code(tstate, function, python_pars);
8531 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 10);
8534 Py_LeaveRecursiveCall();
8536 CHECK_OBJECT_X(result);
8540#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
8541 }
else if (PyCFunction_CheckExact(called)) {
8542#if PYTHON_VERSION >= 0x380
8543#ifdef _NUITKA_FULL_COMPAT
8544 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8549 int flags = PyCFunction_GET_FLAGS(called);
8553 if (!(flags & METH_VARARGS)) {
8554 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8556 assert(func != NULL);
8557 result = func(called, args, 10, NULL);
8559 CHECK_OBJECT_X(result);
8561 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8562 PyObject *self = PyCFunction_GET_SELF(called);
8564 if (flags & METH_KEYWORDS) {
8565 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
8567 result = (*method)(self, pos_args);
8571#ifdef _NUITKA_FULL_COMPAT
8572 Py_LeaveRecursiveCall();
8574 CHECK_OBJECT_X(result);
8576 return Nuitka_CheckFunctionResult(tstate, called, result);
8579 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
8581 if (unlikely(flags & METH_NOARGS)) {
8582 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (10 given)",
8583 ((PyCFunctionObject *)called)->m_ml->ml_name);
8585 }
else if (unlikely(flags & METH_O)) {
8586 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (10 given)",
8587 ((PyCFunctionObject *)called)->m_ml->ml_name);
8589 }
else if (flags & METH_VARARGS) {
8592#ifdef _NUITKA_FULL_COMPAT
8593 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8597 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8598 PyObject *self = PyCFunction_GET_SELF(called);
8602#if PYTHON_VERSION < 0x360
8603 if (flags & METH_KEYWORDS) {
8604 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8606 result = (*method)(self, pos_args);
8610 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
8611 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8612 }
else if (flags == METH_FASTCALL) {
8613#if PYTHON_VERSION < 0x370
8614 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 10, NULL);
8616 result = (*(_PyCFunctionFast)method)(self, &pos_args, 10);
8619 result = (*method)(self, pos_args);
8623#ifdef _NUITKA_FULL_COMPAT
8624 Py_LeaveRecursiveCall();
8627 CHECK_OBJECT_X(result);
8629 return Nuitka_CheckFunctionResult(tstate, called, result);
8633#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
8634 }
else if (PyFunction_Check(called)) {
8635#if PYTHON_VERSION < 0x3b0
8636 PyObject *result = callPythonFunction(called, args, 10);
8638 PyObject *result = _PyFunction_Vectorcall(called, args, 10, NULL);
8640 CHECK_OBJECT_X(result);
8644#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
8645 }
else if (PyType_Check(called)) {
8646 PyTypeObject *type = Py_TYPE(called);
8648 if (type->tp_call == PyType_Type.tp_call) {
8649 PyTypeObject *called_type = (PyTypeObject *)(called);
8651 if (unlikely(called_type->tp_new == NULL)) {
8652 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
8658 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
8659 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
8660 formatCannotInstantiateAbstractClass(tstate, called_type);
8664 obj = called_type->tp_alloc(called_type, 0);
8667 obj = called_type->tp_new(called_type, pos_args, NULL);
8670 if (likely(obj != NULL)) {
8671 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
8676 type = Py_TYPE(obj);
8678 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
8679 if (type->tp_init == default_tp_init_wrapper) {
8681 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
8684 assert(init_method != NULL);
8686 bool is_compiled_function =
false;
8687 bool init_method_needs_release =
false;
8689 if (likely(init_method != NULL)) {
8690 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
8692 if (func == Nuitka_Function_Type.tp_descr_get) {
8693 is_compiled_function =
true;
8694 }
else if (func != NULL) {
8695 init_method = func(init_method, obj, (PyObject *)(type));
8696 init_method_needs_release =
true;
8700 if (unlikely(init_method == NULL)) {
8701 if (!HAS_ERROR_OCCURRED(tstate)) {
8702 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
8703 const_str_plain___init__);
8710 if (is_compiled_function) {
8711 result = Nuitka_CallMethodFunctionPosArgs(
8714 result = CALL_FUNCTION_WITH_POS_ARGS10(tstate, init_method, pos_args);
8715 if (init_method_needs_release) {
8716 Py_DECREF(init_method);
8720 if (unlikely(result == NULL)) {
8727 if (unlikely(result != Py_None)) {
8730 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
8735 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
8743 CHECK_OBJECT_X(obj);
8748#if PYTHON_VERSION < 0x300
8749 }
else if (PyClass_Check(called)) {
8750 PyObject *obj = PyInstance_NewRaw(called, NULL);
8752 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
8754 if (unlikely(init_method == NULL)) {
8755 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
8762 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
8766 bool is_compiled_function =
false;
8768 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
8770 if (descr_get == NULL) {
8771 Py_INCREF(init_method);
8772 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
8773 is_compiled_function =
true;
8774 }
else if (descr_get != NULL) {
8775 PyObject *descr_method = descr_get(init_method, obj, called);
8777 if (unlikely(descr_method == NULL)) {
8781 init_method = descr_method;
8785 if (is_compiled_function) {
8786 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
8789 result = CALL_FUNCTION_WITH_POS_ARGS10(tstate, init_method, pos_args);
8790 Py_DECREF(init_method);
8792 if (unlikely(result == NULL)) {
8798 if (unlikely(result != Py_None)) {
8799 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
8803 CHECK_OBJECT_X(obj);
8807#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8808 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8809 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8811 if (likely(func != NULL)) {
8812 PyObject *result = func(called, args, 10, NULL);
8814 CHECK_OBJECT_X(result);
8816 return Nuitka_CheckFunctionResult(tstate, called, result);
8823 PRINT_STRING(
"FALLBACK");
8828 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
8830 CHECK_OBJECT_X(result);
8834PyObject *CALL_FUNCTION_WITH_NO_ARGS_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *kw_values,
8835 PyObject *kw_names) {
8837 CHECK_OBJECT(kw_names);
8838 assert(PyTuple_CheckExact(kw_names));
8839 CHECK_OBJECT(called);
8841 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
8843 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
8845 if (Nuitka_Function_Check(called)) {
8846 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8852 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, NULL, 0, kw_values, kw_names);
8854 Py_LeaveRecursiveCall();
8856 CHECK_OBJECT_X(result);
8859#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8860 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8861 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8863 if (likely(func != NULL)) {
8864 PyObject *result = func(called, kw_values, 0, kw_names);
8866 CHECK_OBJECT_X(result);
8868 return Nuitka_CheckFunctionResult(tstate, called, result);
8874 PRINT_STRING(
"FALLBACK");
8879 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
8881 if (unlikely(call_slot == NULL)) {
8882 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
8887 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8891 PyObject *pos_args = const_tuple_empty;
8893 PyObject *named_args = _PyDict_NewPresized(nkwargs);
8895 for (Py_ssize_t i = 0; i < nkwargs; i++) {
8896 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
8898 PyObject *value = kw_values[i];
8901 CHECK_OBJECT(value);
8903 DICT_SET_ITEM(named_args, key, value);
8906 PyObject *result = (*call_slot)(called, pos_args, named_args);
8908 Py_DECREF(named_args);
8910 Py_LeaveRecursiveCall();
8912 CHECK_OBJECT_X(result);
8914 return Nuitka_CheckFunctionResult(tstate, called, result);
8916PyObject *CALL_FUNCTION_WITH_ARGS1_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
8917 PyObject *kw_names) {
8918 CHECK_OBJECTS(args, 1);
8919 CHECK_OBJECT(kw_names);
8920 assert(PyTuple_CheckExact(kw_names));
8921 CHECK_OBJECT(called);
8923 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
8925 CHECK_OBJECTS(&args[1], nkwargs);
8927 if (Nuitka_Function_Check(called)) {
8928 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8935 Nuitka_CallFunctionVectorcall(tstate, function, args, 1, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
8937 Py_LeaveRecursiveCall();
8939 CHECK_OBJECT_X(result);
8942#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8943 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8944 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8946 if (likely(func != NULL)) {
8947 PyObject *result = func(called, args, 1, kw_names);
8949 CHECK_OBJECT_X(result);
8951 return Nuitka_CheckFunctionResult(tstate, called, result);
8957 PRINT_STRING(
"FALLBACK");
8962 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
8964 if (unlikely(call_slot == NULL)) {
8965 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
8970 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8974 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
8976 PyObject *named_args = _PyDict_NewPresized(nkwargs);
8978 for (Py_ssize_t i = 0; i < nkwargs; i++) {
8979 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
8981 PyObject *value = args[1 + i];
8984 CHECK_OBJECT(value);
8986 DICT_SET_ITEM(named_args, key, value);
8989 PyObject *result = (*call_slot)(called, pos_args, named_args);
8991 Py_DECREF(pos_args);
8992 Py_DECREF(named_args);
8994 Py_LeaveRecursiveCall();
8996 CHECK_OBJECT_X(result);
8998 return Nuitka_CheckFunctionResult(tstate, called, result);
9000PyObject *CALL_FUNCTION_WITH_ARGS1_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9001 PyObject *
const *kw_values, PyObject *kw_names) {
9002 CHECK_OBJECTS(args, 1);
9003 CHECK_OBJECT(kw_names);
9004 assert(PyTuple_CheckExact(kw_names));
9005 CHECK_OBJECT(called);
9007 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9009 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9011 if (Nuitka_Function_Check(called)) {
9012 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9018 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 1, kw_values, kw_names);
9020 Py_LeaveRecursiveCall();
9022 CHECK_OBJECT_X(result);
9025#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9026 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9027 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9029 if (likely(func != NULL)) {
9030 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 1 + nkwargs);
9032 memcpy(vectorcall_args, args, 1 *
sizeof(PyObject *));
9033 memcpy(&vectorcall_args[1], kw_values, nkwargs *
sizeof(PyObject *));
9035 PyObject *result = func(called, vectorcall_args, 1, kw_names);
9037 CHECK_OBJECT_X(result);
9039 return Nuitka_CheckFunctionResult(tstate, called, result);
9045 PRINT_STRING(
"FALLBACK");
9050 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9052 if (unlikely(call_slot == NULL)) {
9053 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9058 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9062 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
9064 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9066 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9067 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9069 PyObject *value = kw_values[i];
9072 CHECK_OBJECT(value);
9074 DICT_SET_ITEM(named_args, key, value);
9077 PyObject *result = (*call_slot)(called, pos_args, named_args);
9079 Py_DECREF(pos_args);
9080 Py_DECREF(named_args);
9082 Py_LeaveRecursiveCall();
9084 CHECK_OBJECT_X(result);
9086 return Nuitka_CheckFunctionResult(tstate, called, result);
9088PyObject *CALL_FUNCTION_WITH_POS_ARGS1_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9089 PyObject *
const *kw_values, PyObject *kw_names) {
9090 assert(PyTuple_CheckExact(pos_args));
9091 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
9092 CHECK_OBJECTS(args, 1);
9093 CHECK_OBJECT(kw_names);
9094 assert(PyTuple_CheckExact(kw_names));
9095 CHECK_OBJECT(called);
9097 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9099 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9101 if (Nuitka_Function_Check(called)) {
9102 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9108 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 1, kw_values, kw_names);
9110 Py_LeaveRecursiveCall();
9112 CHECK_OBJECT_X(result);
9115#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9116 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9117 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9119 if (likely(func != NULL)) {
9120 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 1 + nkwargs);
9122 memcpy(vectorcall_args, args, 1 *
sizeof(PyObject *));
9123 memcpy(&vectorcall_args[1], kw_values, nkwargs *
sizeof(PyObject *));
9125 PyObject *result = func(called, vectorcall_args, 1, kw_names);
9127 CHECK_OBJECT_X(result);
9129 return Nuitka_CheckFunctionResult(tstate, called, result);
9135 PRINT_STRING(
"FALLBACK");
9140 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9142 if (unlikely(call_slot == NULL)) {
9143 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9148 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9152 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9154 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9155 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9157 PyObject *value = kw_values[i];
9160 CHECK_OBJECT(value);
9162 DICT_SET_ITEM(named_args, key, value);
9165 PyObject *result = (*call_slot)(called, pos_args, named_args);
9167 Py_DECREF(named_args);
9169 Py_LeaveRecursiveCall();
9171 CHECK_OBJECT_X(result);
9173 return Nuitka_CheckFunctionResult(tstate, called, result);
9175PyObject *CALL_FUNCTION_WITH_ARGS2_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9176 PyObject *kw_names) {
9177 CHECK_OBJECTS(args, 2);
9178 CHECK_OBJECT(kw_names);
9179 assert(PyTuple_CheckExact(kw_names));
9180 CHECK_OBJECT(called);
9182 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9184 CHECK_OBJECTS(&args[2], nkwargs);
9186 if (Nuitka_Function_Check(called)) {
9187 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9194 Nuitka_CallFunctionVectorcall(tstate, function, args, 2, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
9196 Py_LeaveRecursiveCall();
9198 CHECK_OBJECT_X(result);
9201#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9202 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9203 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9205 if (likely(func != NULL)) {
9206 PyObject *result = func(called, args, 2, kw_names);
9208 CHECK_OBJECT_X(result);
9210 return Nuitka_CheckFunctionResult(tstate, called, result);
9216 PRINT_STRING(
"FALLBACK");
9221 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9223 if (unlikely(call_slot == NULL)) {
9224 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9229 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9233 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
9235 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9237 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9238 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9240 PyObject *value = args[2 + i];
9243 CHECK_OBJECT(value);
9245 DICT_SET_ITEM(named_args, key, value);
9248 PyObject *result = (*call_slot)(called, pos_args, named_args);
9250 Py_DECREF(pos_args);
9251 Py_DECREF(named_args);
9253 Py_LeaveRecursiveCall();
9255 CHECK_OBJECT_X(result);
9257 return Nuitka_CheckFunctionResult(tstate, called, result);
9259PyObject *CALL_FUNCTION_WITH_ARGS2_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9260 PyObject *
const *kw_values, PyObject *kw_names) {
9261 CHECK_OBJECTS(args, 2);
9262 CHECK_OBJECT(kw_names);
9263 assert(PyTuple_CheckExact(kw_names));
9264 CHECK_OBJECT(called);
9266 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9268 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9270 if (Nuitka_Function_Check(called)) {
9271 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9277 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 2, kw_values, kw_names);
9279 Py_LeaveRecursiveCall();
9281 CHECK_OBJECT_X(result);
9284#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9285 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9286 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9288 if (likely(func != NULL)) {
9289 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 2 + nkwargs);
9291 memcpy(vectorcall_args, args, 2 *
sizeof(PyObject *));
9292 memcpy(&vectorcall_args[2], kw_values, nkwargs *
sizeof(PyObject *));
9294 PyObject *result = func(called, vectorcall_args, 2, kw_names);
9296 CHECK_OBJECT_X(result);
9298 return Nuitka_CheckFunctionResult(tstate, called, result);
9304 PRINT_STRING(
"FALLBACK");
9309 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9311 if (unlikely(call_slot == NULL)) {
9312 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9317 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9321 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
9323 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9325 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9326 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9328 PyObject *value = kw_values[i];
9331 CHECK_OBJECT(value);
9333 DICT_SET_ITEM(named_args, key, value);
9336 PyObject *result = (*call_slot)(called, pos_args, named_args);
9338 Py_DECREF(pos_args);
9339 Py_DECREF(named_args);
9341 Py_LeaveRecursiveCall();
9343 CHECK_OBJECT_X(result);
9345 return Nuitka_CheckFunctionResult(tstate, called, result);
9347PyObject *CALL_FUNCTION_WITH_POS_ARGS2_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9348 PyObject *
const *kw_values, PyObject *kw_names) {
9349 assert(PyTuple_CheckExact(pos_args));
9350 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
9351 CHECK_OBJECTS(args, 2);
9352 CHECK_OBJECT(kw_names);
9353 assert(PyTuple_CheckExact(kw_names));
9354 CHECK_OBJECT(called);
9356 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9358 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9360 if (Nuitka_Function_Check(called)) {
9361 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9367 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 2, kw_values, kw_names);
9369 Py_LeaveRecursiveCall();
9371 CHECK_OBJECT_X(result);
9374#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9375 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9376 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9378 if (likely(func != NULL)) {
9379 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 2 + nkwargs);
9381 memcpy(vectorcall_args, args, 2 *
sizeof(PyObject *));
9382 memcpy(&vectorcall_args[2], kw_values, nkwargs *
sizeof(PyObject *));
9384 PyObject *result = func(called, vectorcall_args, 2, kw_names);
9386 CHECK_OBJECT_X(result);
9388 return Nuitka_CheckFunctionResult(tstate, called, result);
9394 PRINT_STRING(
"FALLBACK");
9399 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9401 if (unlikely(call_slot == NULL)) {
9402 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9407 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9411 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9413 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9414 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9416 PyObject *value = kw_values[i];
9419 CHECK_OBJECT(value);
9421 DICT_SET_ITEM(named_args, key, value);
9424 PyObject *result = (*call_slot)(called, pos_args, named_args);
9426 Py_DECREF(named_args);
9428 Py_LeaveRecursiveCall();
9430 CHECK_OBJECT_X(result);
9432 return Nuitka_CheckFunctionResult(tstate, called, result);
9434PyObject *CALL_FUNCTION_WITH_ARGS3_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9435 PyObject *kw_names) {
9436 CHECK_OBJECTS(args, 3);
9437 CHECK_OBJECT(kw_names);
9438 assert(PyTuple_CheckExact(kw_names));
9439 CHECK_OBJECT(called);
9441 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9443 CHECK_OBJECTS(&args[3], nkwargs);
9445 if (Nuitka_Function_Check(called)) {
9446 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9453 Nuitka_CallFunctionVectorcall(tstate, function, args, 3, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
9455 Py_LeaveRecursiveCall();
9457 CHECK_OBJECT_X(result);
9460#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9461 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9462 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9464 if (likely(func != NULL)) {
9465 PyObject *result = func(called, args, 3, kw_names);
9467 CHECK_OBJECT_X(result);
9469 return Nuitka_CheckFunctionResult(tstate, called, result);
9475 PRINT_STRING(
"FALLBACK");
9480 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9482 if (unlikely(call_slot == NULL)) {
9483 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9488 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9492 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
9494 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9496 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9497 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9499 PyObject *value = args[3 + i];
9502 CHECK_OBJECT(value);
9504 DICT_SET_ITEM(named_args, key, value);
9507 PyObject *result = (*call_slot)(called, pos_args, named_args);
9509 Py_DECREF(pos_args);
9510 Py_DECREF(named_args);
9512 Py_LeaveRecursiveCall();
9514 CHECK_OBJECT_X(result);
9516 return Nuitka_CheckFunctionResult(tstate, called, result);
9518PyObject *CALL_FUNCTION_WITH_ARGS3_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9519 PyObject *
const *kw_values, PyObject *kw_names) {
9520 CHECK_OBJECTS(args, 3);
9521 CHECK_OBJECT(kw_names);
9522 assert(PyTuple_CheckExact(kw_names));
9523 CHECK_OBJECT(called);
9525 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9527 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9529 if (Nuitka_Function_Check(called)) {
9530 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9536 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 3, kw_values, kw_names);
9538 Py_LeaveRecursiveCall();
9540 CHECK_OBJECT_X(result);
9543#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9544 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9545 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9547 if (likely(func != NULL)) {
9548 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 3 + nkwargs);
9550 memcpy(vectorcall_args, args, 3 *
sizeof(PyObject *));
9551 memcpy(&vectorcall_args[3], kw_values, nkwargs *
sizeof(PyObject *));
9553 PyObject *result = func(called, vectorcall_args, 3, kw_names);
9555 CHECK_OBJECT_X(result);
9557 return Nuitka_CheckFunctionResult(tstate, called, result);
9563 PRINT_STRING(
"FALLBACK");
9568 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9570 if (unlikely(call_slot == NULL)) {
9571 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9576 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9580 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
9582 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9584 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9585 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9587 PyObject *value = kw_values[i];
9590 CHECK_OBJECT(value);
9592 DICT_SET_ITEM(named_args, key, value);
9595 PyObject *result = (*call_slot)(called, pos_args, named_args);
9597 Py_DECREF(pos_args);
9598 Py_DECREF(named_args);
9600 Py_LeaveRecursiveCall();
9602 CHECK_OBJECT_X(result);
9604 return Nuitka_CheckFunctionResult(tstate, called, result);
9606PyObject *CALL_FUNCTION_WITH_POS_ARGS3_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9607 PyObject *
const *kw_values, PyObject *kw_names) {
9608 assert(PyTuple_CheckExact(pos_args));
9609 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
9610 CHECK_OBJECTS(args, 3);
9611 CHECK_OBJECT(kw_names);
9612 assert(PyTuple_CheckExact(kw_names));
9613 CHECK_OBJECT(called);
9615 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9617 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9619 if (Nuitka_Function_Check(called)) {
9620 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9626 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 3, kw_values, kw_names);
9628 Py_LeaveRecursiveCall();
9630 CHECK_OBJECT_X(result);
9633#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9634 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9635 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9637 if (likely(func != NULL)) {
9638 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 3 + nkwargs);
9640 memcpy(vectorcall_args, args, 3 *
sizeof(PyObject *));
9641 memcpy(&vectorcall_args[3], kw_values, nkwargs *
sizeof(PyObject *));
9643 PyObject *result = func(called, vectorcall_args, 3, kw_names);
9645 CHECK_OBJECT_X(result);
9647 return Nuitka_CheckFunctionResult(tstate, called, result);
9653 PRINT_STRING(
"FALLBACK");
9658 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9660 if (unlikely(call_slot == NULL)) {
9661 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9666 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9670 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9672 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9673 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9675 PyObject *value = kw_values[i];
9678 CHECK_OBJECT(value);
9680 DICT_SET_ITEM(named_args, key, value);
9683 PyObject *result = (*call_slot)(called, pos_args, named_args);
9685 Py_DECREF(named_args);
9687 Py_LeaveRecursiveCall();
9689 CHECK_OBJECT_X(result);
9691 return Nuitka_CheckFunctionResult(tstate, called, result);
9693PyObject *CALL_FUNCTION_WITH_ARGS4_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9694 PyObject *kw_names) {
9695 CHECK_OBJECTS(args, 4);
9696 CHECK_OBJECT(kw_names);
9697 assert(PyTuple_CheckExact(kw_names));
9698 CHECK_OBJECT(called);
9700 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9702 CHECK_OBJECTS(&args[4], nkwargs);
9704 if (Nuitka_Function_Check(called)) {
9705 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9712 Nuitka_CallFunctionVectorcall(tstate, function, args, 4, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
9714 Py_LeaveRecursiveCall();
9716 CHECK_OBJECT_X(result);
9719#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9720 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9721 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9723 if (likely(func != NULL)) {
9724 PyObject *result = func(called, args, 4, kw_names);
9726 CHECK_OBJECT_X(result);
9728 return Nuitka_CheckFunctionResult(tstate, called, result);
9734 PRINT_STRING(
"FALLBACK");
9739 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9741 if (unlikely(call_slot == NULL)) {
9742 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9747 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9751 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
9753 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9755 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9756 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9758 PyObject *value = args[4 + i];
9761 CHECK_OBJECT(value);
9763 DICT_SET_ITEM(named_args, key, value);
9766 PyObject *result = (*call_slot)(called, pos_args, named_args);
9768 Py_DECREF(pos_args);
9769 Py_DECREF(named_args);
9771 Py_LeaveRecursiveCall();
9773 CHECK_OBJECT_X(result);
9775 return Nuitka_CheckFunctionResult(tstate, called, result);
9777PyObject *CALL_FUNCTION_WITH_ARGS4_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9778 PyObject *
const *kw_values, PyObject *kw_names) {
9779 CHECK_OBJECTS(args, 4);
9780 CHECK_OBJECT(kw_names);
9781 assert(PyTuple_CheckExact(kw_names));
9782 CHECK_OBJECT(called);
9784 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9786 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9788 if (Nuitka_Function_Check(called)) {
9789 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9795 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 4, kw_values, kw_names);
9797 Py_LeaveRecursiveCall();
9799 CHECK_OBJECT_X(result);
9802#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9803 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9804 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9806 if (likely(func != NULL)) {
9807 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 4 + nkwargs);
9809 memcpy(vectorcall_args, args, 4 *
sizeof(PyObject *));
9810 memcpy(&vectorcall_args[4], kw_values, nkwargs *
sizeof(PyObject *));
9812 PyObject *result = func(called, vectorcall_args, 4, kw_names);
9814 CHECK_OBJECT_X(result);
9816 return Nuitka_CheckFunctionResult(tstate, called, result);
9822 PRINT_STRING(
"FALLBACK");
9827 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9829 if (unlikely(call_slot == NULL)) {
9830 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9835 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9839 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
9841 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9843 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9844 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9846 PyObject *value = kw_values[i];
9849 CHECK_OBJECT(value);
9851 DICT_SET_ITEM(named_args, key, value);
9854 PyObject *result = (*call_slot)(called, pos_args, named_args);
9856 Py_DECREF(pos_args);
9857 Py_DECREF(named_args);
9859 Py_LeaveRecursiveCall();
9861 CHECK_OBJECT_X(result);
9863 return Nuitka_CheckFunctionResult(tstate, called, result);
9865PyObject *CALL_FUNCTION_WITH_POS_ARGS4_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9866 PyObject *
const *kw_values, PyObject *kw_names) {
9867 assert(PyTuple_CheckExact(pos_args));
9868 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
9869 CHECK_OBJECTS(args, 4);
9870 CHECK_OBJECT(kw_names);
9871 assert(PyTuple_CheckExact(kw_names));
9872 CHECK_OBJECT(called);
9874 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9876 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9878 if (Nuitka_Function_Check(called)) {
9879 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9885 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 4, kw_values, kw_names);
9887 Py_LeaveRecursiveCall();
9889 CHECK_OBJECT_X(result);
9892#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9893 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9894 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9896 if (likely(func != NULL)) {
9897 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 4 + nkwargs);
9899 memcpy(vectorcall_args, args, 4 *
sizeof(PyObject *));
9900 memcpy(&vectorcall_args[4], kw_values, nkwargs *
sizeof(PyObject *));
9902 PyObject *result = func(called, vectorcall_args, 4, kw_names);
9904 CHECK_OBJECT_X(result);
9906 return Nuitka_CheckFunctionResult(tstate, called, result);
9912 PRINT_STRING(
"FALLBACK");
9917 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9919 if (unlikely(call_slot == NULL)) {
9920 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9925 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9929 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9931 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9932 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9934 PyObject *value = kw_values[i];
9937 CHECK_OBJECT(value);
9939 DICT_SET_ITEM(named_args, key, value);
9942 PyObject *result = (*call_slot)(called, pos_args, named_args);
9944 Py_DECREF(named_args);
9946 Py_LeaveRecursiveCall();
9948 CHECK_OBJECT_X(result);
9950 return Nuitka_CheckFunctionResult(tstate, called, result);
9952PyObject *CALL_FUNCTION_WITH_ARGS5_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9953 PyObject *kw_names) {
9954 CHECK_OBJECTS(args, 5);
9955 CHECK_OBJECT(kw_names);
9956 assert(PyTuple_CheckExact(kw_names));
9957 CHECK_OBJECT(called);
9959 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9961 CHECK_OBJECTS(&args[5], nkwargs);
9963 if (Nuitka_Function_Check(called)) {
9964 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9971 Nuitka_CallFunctionVectorcall(tstate, function, args, 5, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
9973 Py_LeaveRecursiveCall();
9975 CHECK_OBJECT_X(result);
9978#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9979 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9980 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9982 if (likely(func != NULL)) {
9983 PyObject *result = func(called, args, 5, kw_names);
9985 CHECK_OBJECT_X(result);
9987 return Nuitka_CheckFunctionResult(tstate, called, result);
9993 PRINT_STRING(
"FALLBACK");
9998 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10000 if (unlikely(call_slot == NULL)) {
10001 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10006 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10010 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
10012 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10014 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10015 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10017 PyObject *value = args[5 + i];
10020 CHECK_OBJECT(value);
10022 DICT_SET_ITEM(named_args, key, value);
10025 PyObject *result = (*call_slot)(called, pos_args, named_args);
10027 Py_DECREF(pos_args);
10028 Py_DECREF(named_args);
10030 Py_LeaveRecursiveCall();
10032 CHECK_OBJECT_X(result);
10034 return Nuitka_CheckFunctionResult(tstate, called, result);
10036PyObject *CALL_FUNCTION_WITH_ARGS5_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10037 PyObject *
const *kw_values, PyObject *kw_names) {
10038 CHECK_OBJECTS(args, 5);
10039 CHECK_OBJECT(kw_names);
10040 assert(PyTuple_CheckExact(kw_names));
10041 CHECK_OBJECT(called);
10043 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10045 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10047 if (Nuitka_Function_Check(called)) {
10048 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10054 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 5, kw_values, kw_names);
10056 Py_LeaveRecursiveCall();
10058 CHECK_OBJECT_X(result);
10061#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10062 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10063 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10065 if (likely(func != NULL)) {
10066 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 5 + nkwargs);
10068 memcpy(vectorcall_args, args, 5 *
sizeof(PyObject *));
10069 memcpy(&vectorcall_args[5], kw_values, nkwargs *
sizeof(PyObject *));
10071 PyObject *result = func(called, vectorcall_args, 5, kw_names);
10073 CHECK_OBJECT_X(result);
10075 return Nuitka_CheckFunctionResult(tstate, called, result);
10081 PRINT_STRING(
"FALLBACK");
10082 PRINT_ITEM(called);
10086 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10088 if (unlikely(call_slot == NULL)) {
10089 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10094 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10098 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
10100 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10102 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10103 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10105 PyObject *value = kw_values[i];
10108 CHECK_OBJECT(value);
10110 DICT_SET_ITEM(named_args, key, value);
10113 PyObject *result = (*call_slot)(called, pos_args, named_args);
10115 Py_DECREF(pos_args);
10116 Py_DECREF(named_args);
10118 Py_LeaveRecursiveCall();
10120 CHECK_OBJECT_X(result);
10122 return Nuitka_CheckFunctionResult(tstate, called, result);
10124PyObject *CALL_FUNCTION_WITH_POS_ARGS5_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10125 PyObject *
const *kw_values, PyObject *kw_names) {
10126 assert(PyTuple_CheckExact(pos_args));
10127 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
10128 CHECK_OBJECTS(args, 5);
10129 CHECK_OBJECT(kw_names);
10130 assert(PyTuple_CheckExact(kw_names));
10131 CHECK_OBJECT(called);
10133 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10135 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10137 if (Nuitka_Function_Check(called)) {
10138 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10144 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 5, kw_values, kw_names);
10146 Py_LeaveRecursiveCall();
10148 CHECK_OBJECT_X(result);
10151#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10152 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10153 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10155 if (likely(func != NULL)) {
10156 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 5 + nkwargs);
10158 memcpy(vectorcall_args, args, 5 *
sizeof(PyObject *));
10159 memcpy(&vectorcall_args[5], kw_values, nkwargs *
sizeof(PyObject *));
10161 PyObject *result = func(called, vectorcall_args, 5, kw_names);
10163 CHECK_OBJECT_X(result);
10165 return Nuitka_CheckFunctionResult(tstate, called, result);
10171 PRINT_STRING(
"FALLBACK");
10172 PRINT_ITEM(called);
10176 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10178 if (unlikely(call_slot == NULL)) {
10179 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10184 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10188 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10190 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10191 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10193 PyObject *value = kw_values[i];
10196 CHECK_OBJECT(value);
10198 DICT_SET_ITEM(named_args, key, value);
10201 PyObject *result = (*call_slot)(called, pos_args, named_args);
10203 Py_DECREF(named_args);
10205 Py_LeaveRecursiveCall();
10207 CHECK_OBJECT_X(result);
10209 return Nuitka_CheckFunctionResult(tstate, called, result);
10211PyObject *CALL_FUNCTION_WITH_ARGS6_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10212 PyObject *kw_names) {
10213 CHECK_OBJECTS(args, 6);
10214 CHECK_OBJECT(kw_names);
10215 assert(PyTuple_CheckExact(kw_names));
10216 CHECK_OBJECT(called);
10218 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10220 CHECK_OBJECTS(&args[6], nkwargs);
10222 if (Nuitka_Function_Check(called)) {
10223 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10230 Nuitka_CallFunctionVectorcall(tstate, function, args, 6, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
10232 Py_LeaveRecursiveCall();
10234 CHECK_OBJECT_X(result);
10237#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10238 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10239 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10241 if (likely(func != NULL)) {
10242 PyObject *result = func(called, args, 6, kw_names);
10244 CHECK_OBJECT_X(result);
10246 return Nuitka_CheckFunctionResult(tstate, called, result);
10252 PRINT_STRING(
"FALLBACK");
10253 PRINT_ITEM(called);
10257 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10259 if (unlikely(call_slot == NULL)) {
10260 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10265 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10269 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
10271 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10273 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10274 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10276 PyObject *value = args[6 + i];
10279 CHECK_OBJECT(value);
10281 DICT_SET_ITEM(named_args, key, value);
10284 PyObject *result = (*call_slot)(called, pos_args, named_args);
10286 Py_DECREF(pos_args);
10287 Py_DECREF(named_args);
10289 Py_LeaveRecursiveCall();
10291 CHECK_OBJECT_X(result);
10293 return Nuitka_CheckFunctionResult(tstate, called, result);
10295PyObject *CALL_FUNCTION_WITH_ARGS6_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10296 PyObject *
const *kw_values, PyObject *kw_names) {
10297 CHECK_OBJECTS(args, 6);
10298 CHECK_OBJECT(kw_names);
10299 assert(PyTuple_CheckExact(kw_names));
10300 CHECK_OBJECT(called);
10302 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10304 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10306 if (Nuitka_Function_Check(called)) {
10307 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10313 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 6, kw_values, kw_names);
10315 Py_LeaveRecursiveCall();
10317 CHECK_OBJECT_X(result);
10320#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10321 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10322 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10324 if (likely(func != NULL)) {
10325 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 6 + nkwargs);
10327 memcpy(vectorcall_args, args, 6 *
sizeof(PyObject *));
10328 memcpy(&vectorcall_args[6], kw_values, nkwargs *
sizeof(PyObject *));
10330 PyObject *result = func(called, vectorcall_args, 6, kw_names);
10332 CHECK_OBJECT_X(result);
10334 return Nuitka_CheckFunctionResult(tstate, called, result);
10340 PRINT_STRING(
"FALLBACK");
10341 PRINT_ITEM(called);
10345 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10347 if (unlikely(call_slot == NULL)) {
10348 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10353 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10357 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
10359 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10361 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10362 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10364 PyObject *value = kw_values[i];
10367 CHECK_OBJECT(value);
10369 DICT_SET_ITEM(named_args, key, value);
10372 PyObject *result = (*call_slot)(called, pos_args, named_args);
10374 Py_DECREF(pos_args);
10375 Py_DECREF(named_args);
10377 Py_LeaveRecursiveCall();
10379 CHECK_OBJECT_X(result);
10381 return Nuitka_CheckFunctionResult(tstate, called, result);
10383PyObject *CALL_FUNCTION_WITH_POS_ARGS6_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10384 PyObject *
const *kw_values, PyObject *kw_names) {
10385 assert(PyTuple_CheckExact(pos_args));
10386 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
10387 CHECK_OBJECTS(args, 6);
10388 CHECK_OBJECT(kw_names);
10389 assert(PyTuple_CheckExact(kw_names));
10390 CHECK_OBJECT(called);
10392 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10394 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10396 if (Nuitka_Function_Check(called)) {
10397 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10403 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 6, kw_values, kw_names);
10405 Py_LeaveRecursiveCall();
10407 CHECK_OBJECT_X(result);
10410#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10411 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10412 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10414 if (likely(func != NULL)) {
10415 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 6 + nkwargs);
10417 memcpy(vectorcall_args, args, 6 *
sizeof(PyObject *));
10418 memcpy(&vectorcall_args[6], kw_values, nkwargs *
sizeof(PyObject *));
10420 PyObject *result = func(called, vectorcall_args, 6, kw_names);
10422 CHECK_OBJECT_X(result);
10424 return Nuitka_CheckFunctionResult(tstate, called, result);
10430 PRINT_STRING(
"FALLBACK");
10431 PRINT_ITEM(called);
10435 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10437 if (unlikely(call_slot == NULL)) {
10438 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10443 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10447 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10449 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10450 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10452 PyObject *value = kw_values[i];
10455 CHECK_OBJECT(value);
10457 DICT_SET_ITEM(named_args, key, value);
10460 PyObject *result = (*call_slot)(called, pos_args, named_args);
10462 Py_DECREF(named_args);
10464 Py_LeaveRecursiveCall();
10466 CHECK_OBJECT_X(result);
10468 return Nuitka_CheckFunctionResult(tstate, called, result);
10470PyObject *CALL_FUNCTION_WITH_ARGS7_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10471 PyObject *kw_names) {
10472 CHECK_OBJECTS(args, 7);
10473 CHECK_OBJECT(kw_names);
10474 assert(PyTuple_CheckExact(kw_names));
10475 CHECK_OBJECT(called);
10477 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10479 CHECK_OBJECTS(&args[7], nkwargs);
10481 if (Nuitka_Function_Check(called)) {
10482 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10489 Nuitka_CallFunctionVectorcall(tstate, function, args, 7, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
10491 Py_LeaveRecursiveCall();
10493 CHECK_OBJECT_X(result);
10496#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10497 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10498 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10500 if (likely(func != NULL)) {
10501 PyObject *result = func(called, args, 7, kw_names);
10503 CHECK_OBJECT_X(result);
10505 return Nuitka_CheckFunctionResult(tstate, called, result);
10511 PRINT_STRING(
"FALLBACK");
10512 PRINT_ITEM(called);
10516 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10518 if (unlikely(call_slot == NULL)) {
10519 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10524 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10528 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
10530 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10532 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10533 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10535 PyObject *value = args[7 + i];
10538 CHECK_OBJECT(value);
10540 DICT_SET_ITEM(named_args, key, value);
10543 PyObject *result = (*call_slot)(called, pos_args, named_args);
10545 Py_DECREF(pos_args);
10546 Py_DECREF(named_args);
10548 Py_LeaveRecursiveCall();
10550 CHECK_OBJECT_X(result);
10552 return Nuitka_CheckFunctionResult(tstate, called, result);
10554PyObject *CALL_FUNCTION_WITH_ARGS7_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10555 PyObject *
const *kw_values, PyObject *kw_names) {
10556 CHECK_OBJECTS(args, 7);
10557 CHECK_OBJECT(kw_names);
10558 assert(PyTuple_CheckExact(kw_names));
10559 CHECK_OBJECT(called);
10561 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10563 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10565 if (Nuitka_Function_Check(called)) {
10566 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10572 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 7, kw_values, kw_names);
10574 Py_LeaveRecursiveCall();
10576 CHECK_OBJECT_X(result);
10579#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10580 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10581 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10583 if (likely(func != NULL)) {
10584 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 7 + nkwargs);
10586 memcpy(vectorcall_args, args, 7 *
sizeof(PyObject *));
10587 memcpy(&vectorcall_args[7], kw_values, nkwargs *
sizeof(PyObject *));
10589 PyObject *result = func(called, vectorcall_args, 7, kw_names);
10591 CHECK_OBJECT_X(result);
10593 return Nuitka_CheckFunctionResult(tstate, called, result);
10599 PRINT_STRING(
"FALLBACK");
10600 PRINT_ITEM(called);
10604 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10606 if (unlikely(call_slot == NULL)) {
10607 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10612 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10616 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
10618 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10620 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10621 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10623 PyObject *value = kw_values[i];
10626 CHECK_OBJECT(value);
10628 DICT_SET_ITEM(named_args, key, value);
10631 PyObject *result = (*call_slot)(called, pos_args, named_args);
10633 Py_DECREF(pos_args);
10634 Py_DECREF(named_args);
10636 Py_LeaveRecursiveCall();
10638 CHECK_OBJECT_X(result);
10640 return Nuitka_CheckFunctionResult(tstate, called, result);
10642PyObject *CALL_FUNCTION_WITH_POS_ARGS7_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10643 PyObject *
const *kw_values, PyObject *kw_names) {
10644 assert(PyTuple_CheckExact(pos_args));
10645 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
10646 CHECK_OBJECTS(args, 7);
10647 CHECK_OBJECT(kw_names);
10648 assert(PyTuple_CheckExact(kw_names));
10649 CHECK_OBJECT(called);
10651 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10653 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10655 if (Nuitka_Function_Check(called)) {
10656 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10662 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 7, kw_values, kw_names);
10664 Py_LeaveRecursiveCall();
10666 CHECK_OBJECT_X(result);
10669#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10670 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10671 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10673 if (likely(func != NULL)) {
10674 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 7 + nkwargs);
10676 memcpy(vectorcall_args, args, 7 *
sizeof(PyObject *));
10677 memcpy(&vectorcall_args[7], kw_values, nkwargs *
sizeof(PyObject *));
10679 PyObject *result = func(called, vectorcall_args, 7, kw_names);
10681 CHECK_OBJECT_X(result);
10683 return Nuitka_CheckFunctionResult(tstate, called, result);
10689 PRINT_STRING(
"FALLBACK");
10690 PRINT_ITEM(called);
10694 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10696 if (unlikely(call_slot == NULL)) {
10697 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10702 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10706 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10708 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10709 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10711 PyObject *value = kw_values[i];
10714 CHECK_OBJECT(value);
10716 DICT_SET_ITEM(named_args, key, value);
10719 PyObject *result = (*call_slot)(called, pos_args, named_args);
10721 Py_DECREF(named_args);
10723 Py_LeaveRecursiveCall();
10725 CHECK_OBJECT_X(result);
10727 return Nuitka_CheckFunctionResult(tstate, called, result);
10729PyObject *CALL_FUNCTION_WITH_ARGS8_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10730 PyObject *kw_names) {
10731 CHECK_OBJECTS(args, 8);
10732 CHECK_OBJECT(kw_names);
10733 assert(PyTuple_CheckExact(kw_names));
10734 CHECK_OBJECT(called);
10736 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10738 CHECK_OBJECTS(&args[8], nkwargs);
10740 if (Nuitka_Function_Check(called)) {
10741 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10748 Nuitka_CallFunctionVectorcall(tstate, function, args, 8, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
10750 Py_LeaveRecursiveCall();
10752 CHECK_OBJECT_X(result);
10755#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10756 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10757 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10759 if (likely(func != NULL)) {
10760 PyObject *result = func(called, args, 8, kw_names);
10762 CHECK_OBJECT_X(result);
10764 return Nuitka_CheckFunctionResult(tstate, called, result);
10770 PRINT_STRING(
"FALLBACK");
10771 PRINT_ITEM(called);
10775 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10777 if (unlikely(call_slot == NULL)) {
10778 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10783 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10787 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
10789 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10791 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10792 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10794 PyObject *value = args[8 + i];
10797 CHECK_OBJECT(value);
10799 DICT_SET_ITEM(named_args, key, value);
10802 PyObject *result = (*call_slot)(called, pos_args, named_args);
10804 Py_DECREF(pos_args);
10805 Py_DECREF(named_args);
10807 Py_LeaveRecursiveCall();
10809 CHECK_OBJECT_X(result);
10811 return Nuitka_CheckFunctionResult(tstate, called, result);
10813PyObject *CALL_FUNCTION_WITH_ARGS8_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10814 PyObject *
const *kw_values, PyObject *kw_names) {
10815 CHECK_OBJECTS(args, 8);
10816 CHECK_OBJECT(kw_names);
10817 assert(PyTuple_CheckExact(kw_names));
10818 CHECK_OBJECT(called);
10820 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10822 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10824 if (Nuitka_Function_Check(called)) {
10825 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10831 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 8, kw_values, kw_names);
10833 Py_LeaveRecursiveCall();
10835 CHECK_OBJECT_X(result);
10838#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10839 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10840 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10842 if (likely(func != NULL)) {
10843 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 8 + nkwargs);
10845 memcpy(vectorcall_args, args, 8 *
sizeof(PyObject *));
10846 memcpy(&vectorcall_args[8], kw_values, nkwargs *
sizeof(PyObject *));
10848 PyObject *result = func(called, vectorcall_args, 8, kw_names);
10850 CHECK_OBJECT_X(result);
10852 return Nuitka_CheckFunctionResult(tstate, called, result);
10858 PRINT_STRING(
"FALLBACK");
10859 PRINT_ITEM(called);
10863 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10865 if (unlikely(call_slot == NULL)) {
10866 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10871 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10875 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
10877 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10879 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10880 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10882 PyObject *value = kw_values[i];
10885 CHECK_OBJECT(value);
10887 DICT_SET_ITEM(named_args, key, value);
10890 PyObject *result = (*call_slot)(called, pos_args, named_args);
10892 Py_DECREF(pos_args);
10893 Py_DECREF(named_args);
10895 Py_LeaveRecursiveCall();
10897 CHECK_OBJECT_X(result);
10899 return Nuitka_CheckFunctionResult(tstate, called, result);
10901PyObject *CALL_FUNCTION_WITH_POS_ARGS8_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10902 PyObject *
const *kw_values, PyObject *kw_names) {
10903 assert(PyTuple_CheckExact(pos_args));
10904 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
10905 CHECK_OBJECTS(args, 8);
10906 CHECK_OBJECT(kw_names);
10907 assert(PyTuple_CheckExact(kw_names));
10908 CHECK_OBJECT(called);
10910 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10912 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10914 if (Nuitka_Function_Check(called)) {
10915 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10921 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 8, kw_values, kw_names);
10923 Py_LeaveRecursiveCall();
10925 CHECK_OBJECT_X(result);
10928#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10929 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10930 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10932 if (likely(func != NULL)) {
10933 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 8 + nkwargs);
10935 memcpy(vectorcall_args, args, 8 *
sizeof(PyObject *));
10936 memcpy(&vectorcall_args[8], kw_values, nkwargs *
sizeof(PyObject *));
10938 PyObject *result = func(called, vectorcall_args, 8, kw_names);
10940 CHECK_OBJECT_X(result);
10942 return Nuitka_CheckFunctionResult(tstate, called, result);
10948 PRINT_STRING(
"FALLBACK");
10949 PRINT_ITEM(called);
10953 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10955 if (unlikely(call_slot == NULL)) {
10956 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10961 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10965 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10967 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10968 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10970 PyObject *value = kw_values[i];
10973 CHECK_OBJECT(value);
10975 DICT_SET_ITEM(named_args, key, value);
10978 PyObject *result = (*call_slot)(called, pos_args, named_args);
10980 Py_DECREF(named_args);
10982 Py_LeaveRecursiveCall();
10984 CHECK_OBJECT_X(result);
10986 return Nuitka_CheckFunctionResult(tstate, called, result);
10988PyObject *CALL_FUNCTION_WITH_ARGS9_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10989 PyObject *kw_names) {
10990 CHECK_OBJECTS(args, 9);
10991 CHECK_OBJECT(kw_names);
10992 assert(PyTuple_CheckExact(kw_names));
10993 CHECK_OBJECT(called);
10995 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10997 CHECK_OBJECTS(&args[9], nkwargs);
10999 if (Nuitka_Function_Check(called)) {
11000 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11007 Nuitka_CallFunctionVectorcall(tstate, function, args, 9, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
11009 Py_LeaveRecursiveCall();
11011 CHECK_OBJECT_X(result);
11014#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11015 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11016 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11018 if (likely(func != NULL)) {
11019 PyObject *result = func(called, args, 9, kw_names);
11021 CHECK_OBJECT_X(result);
11023 return Nuitka_CheckFunctionResult(tstate, called, result);
11029 PRINT_STRING(
"FALLBACK");
11030 PRINT_ITEM(called);
11034 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11036 if (unlikely(call_slot == NULL)) {
11037 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11042 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11046 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
11048 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11050 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11051 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11053 PyObject *value = args[9 + i];
11056 CHECK_OBJECT(value);
11058 DICT_SET_ITEM(named_args, key, value);
11061 PyObject *result = (*call_slot)(called, pos_args, named_args);
11063 Py_DECREF(pos_args);
11064 Py_DECREF(named_args);
11066 Py_LeaveRecursiveCall();
11068 CHECK_OBJECT_X(result);
11070 return Nuitka_CheckFunctionResult(tstate, called, result);
11072PyObject *CALL_FUNCTION_WITH_ARGS9_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
11073 PyObject *
const *kw_values, PyObject *kw_names) {
11074 CHECK_OBJECTS(args, 9);
11075 CHECK_OBJECT(kw_names);
11076 assert(PyTuple_CheckExact(kw_names));
11077 CHECK_OBJECT(called);
11079 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11081 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11083 if (Nuitka_Function_Check(called)) {
11084 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11090 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 9, kw_values, kw_names);
11092 Py_LeaveRecursiveCall();
11094 CHECK_OBJECT_X(result);
11097#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11098 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11099 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11101 if (likely(func != NULL)) {
11102 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 9 + nkwargs);
11104 memcpy(vectorcall_args, args, 9 *
sizeof(PyObject *));
11105 memcpy(&vectorcall_args[9], kw_values, nkwargs *
sizeof(PyObject *));
11107 PyObject *result = func(called, vectorcall_args, 9, kw_names);
11109 CHECK_OBJECT_X(result);
11111 return Nuitka_CheckFunctionResult(tstate, called, result);
11117 PRINT_STRING(
"FALLBACK");
11118 PRINT_ITEM(called);
11122 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11124 if (unlikely(call_slot == NULL)) {
11125 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11130 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11134 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
11136 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11138 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11139 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11141 PyObject *value = kw_values[i];
11144 CHECK_OBJECT(value);
11146 DICT_SET_ITEM(named_args, key, value);
11149 PyObject *result = (*call_slot)(called, pos_args, named_args);
11151 Py_DECREF(pos_args);
11152 Py_DECREF(named_args);
11154 Py_LeaveRecursiveCall();
11156 CHECK_OBJECT_X(result);
11158 return Nuitka_CheckFunctionResult(tstate, called, result);
11160PyObject *CALL_FUNCTION_WITH_POS_ARGS9_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
11161 PyObject *
const *kw_values, PyObject *kw_names) {
11162 assert(PyTuple_CheckExact(pos_args));
11163 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
11164 CHECK_OBJECTS(args, 9);
11165 CHECK_OBJECT(kw_names);
11166 assert(PyTuple_CheckExact(kw_names));
11167 CHECK_OBJECT(called);
11169 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11171 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11173 if (Nuitka_Function_Check(called)) {
11174 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11180 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 9, kw_values, kw_names);
11182 Py_LeaveRecursiveCall();
11184 CHECK_OBJECT_X(result);
11187#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11188 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11189 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11191 if (likely(func != NULL)) {
11192 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 9 + nkwargs);
11194 memcpy(vectorcall_args, args, 9 *
sizeof(PyObject *));
11195 memcpy(&vectorcall_args[9], kw_values, nkwargs *
sizeof(PyObject *));
11197 PyObject *result = func(called, vectorcall_args, 9, kw_names);
11199 CHECK_OBJECT_X(result);
11201 return Nuitka_CheckFunctionResult(tstate, called, result);
11207 PRINT_STRING(
"FALLBACK");
11208 PRINT_ITEM(called);
11212 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11214 if (unlikely(call_slot == NULL)) {
11215 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11220 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11224 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11226 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11227 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11229 PyObject *value = kw_values[i];
11232 CHECK_OBJECT(value);
11234 DICT_SET_ITEM(named_args, key, value);
11237 PyObject *result = (*call_slot)(called, pos_args, named_args);
11239 Py_DECREF(named_args);
11241 Py_LeaveRecursiveCall();
11243 CHECK_OBJECT_X(result);
11245 return Nuitka_CheckFunctionResult(tstate, called, result);
11247PyObject *CALL_FUNCTION_WITH_ARGS10_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
11248 PyObject *kw_names) {
11249 CHECK_OBJECTS(args, 10);
11250 CHECK_OBJECT(kw_names);
11251 assert(PyTuple_CheckExact(kw_names));
11252 CHECK_OBJECT(called);
11254 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11256 CHECK_OBJECTS(&args[10], nkwargs);
11258 if (Nuitka_Function_Check(called)) {
11259 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11266 Nuitka_CallFunctionVectorcall(tstate, function, args, 10, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
11268 Py_LeaveRecursiveCall();
11270 CHECK_OBJECT_X(result);
11273#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11274 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11275 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11277 if (likely(func != NULL)) {
11278 PyObject *result = func(called, args, 10, kw_names);
11280 CHECK_OBJECT_X(result);
11282 return Nuitka_CheckFunctionResult(tstate, called, result);
11288 PRINT_STRING(
"FALLBACK");
11289 PRINT_ITEM(called);
11293 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11295 if (unlikely(call_slot == NULL)) {
11296 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11301 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11305 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
11307 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11309 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11310 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11312 PyObject *value = args[10 + i];
11315 CHECK_OBJECT(value);
11317 DICT_SET_ITEM(named_args, key, value);
11320 PyObject *result = (*call_slot)(called, pos_args, named_args);
11322 Py_DECREF(pos_args);
11323 Py_DECREF(named_args);
11325 Py_LeaveRecursiveCall();
11327 CHECK_OBJECT_X(result);
11329 return Nuitka_CheckFunctionResult(tstate, called, result);
11331PyObject *CALL_FUNCTION_WITH_ARGS10_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
11332 PyObject *
const *kw_values, PyObject *kw_names) {
11333 CHECK_OBJECTS(args, 10);
11334 CHECK_OBJECT(kw_names);
11335 assert(PyTuple_CheckExact(kw_names));
11336 CHECK_OBJECT(called);
11338 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11340 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11342 if (Nuitka_Function_Check(called)) {
11343 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11349 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 10, kw_values, kw_names);
11351 Py_LeaveRecursiveCall();
11353 CHECK_OBJECT_X(result);
11356#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11357 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11358 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11360 if (likely(func != NULL)) {
11361 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 10 + nkwargs);
11363 memcpy(vectorcall_args, args, 10 *
sizeof(PyObject *));
11364 memcpy(&vectorcall_args[10], kw_values, nkwargs *
sizeof(PyObject *));
11366 PyObject *result = func(called, vectorcall_args, 10, kw_names);
11368 CHECK_OBJECT_X(result);
11370 return Nuitka_CheckFunctionResult(tstate, called, result);
11376 PRINT_STRING(
"FALLBACK");
11377 PRINT_ITEM(called);
11381 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11383 if (unlikely(call_slot == NULL)) {
11384 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11389 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11393 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
11395 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11397 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11398 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11400 PyObject *value = kw_values[i];
11403 CHECK_OBJECT(value);
11405 DICT_SET_ITEM(named_args, key, value);
11408 PyObject *result = (*call_slot)(called, pos_args, named_args);
11410 Py_DECREF(pos_args);
11411 Py_DECREF(named_args);
11413 Py_LeaveRecursiveCall();
11415 CHECK_OBJECT_X(result);
11417 return Nuitka_CheckFunctionResult(tstate, called, result);
11419PyObject *CALL_FUNCTION_WITH_POS_ARGS10_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
11420 PyObject *
const *kw_values, PyObject *kw_names) {
11421 assert(PyTuple_CheckExact(pos_args));
11422 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
11423 CHECK_OBJECTS(args, 10);
11424 CHECK_OBJECT(kw_names);
11425 assert(PyTuple_CheckExact(kw_names));
11426 CHECK_OBJECT(called);
11428 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11430 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11432 if (Nuitka_Function_Check(called)) {
11433 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11439 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 10, kw_values, kw_names);
11441 Py_LeaveRecursiveCall();
11443 CHECK_OBJECT_X(result);
11446#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11447 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11448 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11450 if (likely(func != NULL)) {
11451 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 10 + nkwargs);
11453 memcpy(vectorcall_args, args, 10 *
sizeof(PyObject *));
11454 memcpy(&vectorcall_args[10], kw_values, nkwargs *
sizeof(PyObject *));
11456 PyObject *result = func(called, vectorcall_args, 10, kw_names);
11458 CHECK_OBJECT_X(result);
11460 return Nuitka_CheckFunctionResult(tstate, called, result);
11466 PRINT_STRING(
"FALLBACK");
11467 PRINT_ITEM(called);
11471 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11473 if (unlikely(call_slot == NULL)) {
11474 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11479 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11483 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11485 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11486 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11488 PyObject *value = kw_values[i];
11491 CHECK_OBJECT(value);
11493 DICT_SET_ITEM(named_args, key, value);
11496 PyObject *result = (*call_slot)(called, pos_args, named_args);
11498 Py_DECREF(named_args);
11500 Py_LeaveRecursiveCall();
11502 CHECK_OBJECT_X(result);
11504 return Nuitka_CheckFunctionResult(tstate, called, result);
11506PyObject *CALL_METHODDESCR_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *called, PyObject *arg) {
11507 PyObject *
const *args = &arg;
11508 CHECK_OBJECT(called);
11509 CHECK_OBJECTS(args, 1);
11511#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11512 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11513 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11514 assert(func != NULL);
11515 PyObject *result = func(called, args, 1, NULL);
11517#ifndef __NUITKA_NO_ASSERT__
11518 return Nuitka_CheckFunctionResult(tstate, called, result);
11523 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11524 PyMethodDef *method_def = called_descr->d_method;
11527 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11529 if (likely(flags & METH_NOARGS)) {
11530 PyCFunction method = method_def->ml_meth;
11531 PyObject *self = args[0];
11533 PyObject *result = (*method)(self, NULL);
11535#ifndef __NUITKA_NO_ASSERT__
11536 return Nuitka_CheckFunctionResult(tstate, called, result);
11540 }
else if ((flags & METH_O)) {
11541 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (1 given)",
11542 method_def->ml_name);
11544 }
else if (flags & METH_VARARGS) {
11545 PyCFunction method = method_def->ml_meth;
11546 PyObject *self = args[0];
11550#if PYTHON_VERSION < 0x360
11551 if (flags & METH_KEYWORDS) {
11552 result = (*(PyCFunctionWithKeywords)method)(self, const_tuple_empty, NULL);
11554 result = (*method)(self, const_tuple_empty);
11557 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11558 result = (*(PyCFunctionWithKeywords)method)(self, const_tuple_empty, NULL);
11559 }
else if (flags == METH_FASTCALL) {
11560#if PYTHON_VERSION < 0x370
11561 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 0, NULL);
11563 result = (*(_PyCFunctionFast)method)(self, &const_tuple_empty, 1);
11566 result = (*method)(self, const_tuple_empty);
11569#ifndef __NUITKA_NO_ASSERT__
11570 return Nuitka_CheckFunctionResult(tstate, called, result);
11578 PRINT_STRING(
"FALLBACK");
11579 PRINT_ITEM(called);
11583 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
11585 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11587 Py_DECREF(pos_args);
11592PyObject *CALL_METHODDESCR_WITH_ARGS2(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
11593 CHECK_OBJECT(called);
11594 CHECK_OBJECTS(args, 2);
11596#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11597 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11598 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11599 assert(func != NULL);
11600 PyObject *result = func(called, args, 2, NULL);
11602#ifndef __NUITKA_NO_ASSERT__
11603 return Nuitka_CheckFunctionResult(tstate, called, result);
11608 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11609 PyMethodDef *method_def = called_descr->d_method;
11612 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11614 if (unlikely(flags & METH_NOARGS)) {
11615 PyCFunction method = method_def->ml_meth;
11616 PyObject *self = args[0];
11618 PyObject *result = (*method)(self, NULL);
11620#ifndef __NUITKA_NO_ASSERT__
11621 return Nuitka_CheckFunctionResult(tstate, called, result);
11625 }
else if (unlikely(flags & METH_O)) {
11626 PyCFunction method = method_def->ml_meth;
11627 PyObject *self = args[0];
11629 PyObject *result = (*method)(self, args[1]);
11631#ifndef __NUITKA_NO_ASSERT__
11632 return Nuitka_CheckFunctionResult(tstate, called, result);
11636 }
else if (flags & METH_VARARGS) {
11637 PyCFunction method = method_def->ml_meth;
11638 PyObject *self = args[0];
11642#if PYTHON_VERSION < 0x360
11643 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11645 if (flags & METH_KEYWORDS) {
11646 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11648 result = (*method)(self, pos_args);
11651 Py_DECREF(pos_args);
11653 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11654 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11655 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11656 Py_DECREF(pos_args);
11657 }
else if (flags == METH_FASTCALL) {
11658#if PYTHON_VERSION < 0x370
11659 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 1, NULL);
11661 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11662 result = (*(_PyCFunctionFast)method)(self, &pos_args, 2);
11663 Py_DECREF(pos_args);
11666 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11667 result = (*method)(self, pos_args);
11668 Py_DECREF(pos_args);
11671#ifndef __NUITKA_NO_ASSERT__
11672 return Nuitka_CheckFunctionResult(tstate, called, result);
11680 PRINT_STRING(
"FALLBACK");
11681 PRINT_ITEM(called);
11685 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
11687 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11689 Py_DECREF(pos_args);
11694PyObject *CALL_METHODDESCR_WITH_ARGS3(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
11695 CHECK_OBJECT(called);
11696 CHECK_OBJECTS(args, 3);
11698#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11699 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11700 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11701 assert(func != NULL);
11702 PyObject *result = func(called, args, 3, NULL);
11704#ifndef __NUITKA_NO_ASSERT__
11705 return Nuitka_CheckFunctionResult(tstate, called, result);
11710 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11711 PyMethodDef *method_def = called_descr->d_method;
11714 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11716 if (unlikely(flags & METH_NOARGS)) {
11717 PyCFunction method = method_def->ml_meth;
11718 PyObject *self = args[0];
11720 PyObject *result = (*method)(self, NULL);
11722#ifndef __NUITKA_NO_ASSERT__
11723 return Nuitka_CheckFunctionResult(tstate, called, result);
11727 }
else if (unlikely(flags & METH_O)) {
11728 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (3 given)",
11729 method_def->ml_name);
11731 }
else if (flags & METH_VARARGS) {
11732 PyCFunction method = method_def->ml_meth;
11733 PyObject *self = args[0];
11737#if PYTHON_VERSION < 0x360
11738 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11740 if (flags & METH_KEYWORDS) {
11741 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11743 result = (*method)(self, pos_args);
11746 Py_DECREF(pos_args);
11748 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11749 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11750 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11751 Py_DECREF(pos_args);
11752 }
else if (flags == METH_FASTCALL) {
11753#if PYTHON_VERSION < 0x370
11754 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 2, NULL);
11756 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11757 result = (*(_PyCFunctionFast)method)(self, &pos_args, 3);
11758 Py_DECREF(pos_args);
11761 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11762 result = (*method)(self, pos_args);
11763 Py_DECREF(pos_args);
11766#ifndef __NUITKA_NO_ASSERT__
11767 return Nuitka_CheckFunctionResult(tstate, called, result);
11775 PRINT_STRING(
"FALLBACK");
11776 PRINT_ITEM(called);
11780 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
11782 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11784 Py_DECREF(pos_args);
11789PyObject *CALL_METHODDESCR_WITH_ARGS4(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
11790 CHECK_OBJECT(called);
11791 CHECK_OBJECTS(args, 4);
11793#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11794 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11795 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11796 assert(func != NULL);
11797 PyObject *result = func(called, args, 4, NULL);
11799#ifndef __NUITKA_NO_ASSERT__
11800 return Nuitka_CheckFunctionResult(tstate, called, result);
11805 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11806 PyMethodDef *method_def = called_descr->d_method;
11809 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11811 if (unlikely(flags & METH_NOARGS)) {
11812 PyCFunction method = method_def->ml_meth;
11813 PyObject *self = args[0];
11815 PyObject *result = (*method)(self, NULL);
11817#ifndef __NUITKA_NO_ASSERT__
11818 return Nuitka_CheckFunctionResult(tstate, called, result);
11822 }
else if (unlikely(flags & METH_O)) {
11823 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (4 given)",
11824 method_def->ml_name);
11826 }
else if (flags & METH_VARARGS) {
11827 PyCFunction method = method_def->ml_meth;
11828 PyObject *self = args[0];
11832#if PYTHON_VERSION < 0x360
11833 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11835 if (flags & METH_KEYWORDS) {
11836 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11838 result = (*method)(self, pos_args);
11841 Py_DECREF(pos_args);
11843 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11844 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11845 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11846 Py_DECREF(pos_args);
11847 }
else if (flags == METH_FASTCALL) {
11848#if PYTHON_VERSION < 0x370
11849 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 3, NULL);
11851 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11852 result = (*(_PyCFunctionFast)method)(self, &pos_args, 4);
11853 Py_DECREF(pos_args);
11856 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11857 result = (*method)(self, pos_args);
11858 Py_DECREF(pos_args);
11861#ifndef __NUITKA_NO_ASSERT__
11862 return Nuitka_CheckFunctionResult(tstate, called, result);
11870 PRINT_STRING(
"FALLBACK");
11871 PRINT_ITEM(called);
11875 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
11877 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11879 Py_DECREF(pos_args);
11884PyObject *CALL_METHOD_NO_ARGS(PyThreadState *tstate, PyObject *source, PyObject *attr_name) {
11885 CHECK_OBJECT(source);
11886 CHECK_OBJECT(attr_name);
11888 PyTypeObject *type = Py_TYPE(source);
11890 if (hasTypeGenericGetAttr(type)) {
11892 if (unlikely(type->tp_dict == NULL)) {
11893 if (unlikely(PyType_Ready(type) < 0)) {
11898 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
11899 descrgetfunc func = NULL;
11901 if (descr != NULL) {
11904 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
11905 func = Py_TYPE(descr)->tp_descr_get;
11907 if (func != NULL && Nuitka_Descr_IsData(descr)) {
11908 PyObject *called_object = func(descr, source, (PyObject *)type);
11911 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
11912 Py_DECREF(called_object);
11918 Py_ssize_t dictoffset = type->tp_dictoffset;
11919 PyObject *dict = NULL;
11921 if (dictoffset != 0) {
11923 if (dictoffset < 0) {
11927 tsize = ((PyVarObject *)source)->ob_size;
11931 size = _PyObject_VAR_SIZE(type, tsize);
11933 dictoffset += (long)size;
11936 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
11940 if (dict != NULL) {
11941 CHECK_OBJECT(dict);
11945 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
11947 if (called_object != NULL) {
11951 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
11952 Py_DECREF(called_object);
11959 if (func != NULL) {
11960 if (func == Nuitka_Function_Type.tp_descr_get) {
11967 PyObject *called_object = func(descr, source, (PyObject *)type);
11968 CHECK_OBJECT(called_object);
11972 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
11973 Py_DECREF(called_object);
11978 if (descr != NULL) {
11979 CHECK_OBJECT(descr);
11981 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, descr);
11986#if PYTHON_VERSION < 0x300
11987 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
11988 PyString_AS_STRING(attr_name));
11990 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
11994#if PYTHON_VERSION < 0x300
11995 else if (type == &PyInstance_Type) {
11996 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12000 assert(attr_name != const_str_plain___dict__);
12001 assert(attr_name != const_str_plain___class__);
12004 PyObject *called_object =
12005 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12009 if (called_object != NULL) {
12010 return CALL_FUNCTION_NO_ARGS(tstate, called_object);
12014 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12018 if (called_object != NULL) {
12019 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12021 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12022 return Nuitka_CallMethodFunctionNoArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12024 }
else if (descr_get != NULL) {
12025 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12027 if (unlikely(method == NULL)) {
12031 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, method);
12035 return CALL_FUNCTION_NO_ARGS(tstate, called_object);
12038 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12039 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12040 PyString_AS_STRING(source_instance->in_class->cl_name),
12041 PyString_AS_STRING(attr_name));
12048 PyObject *args2[] = {source, attr_name};
12050 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12052 if (unlikely(called_object == NULL)) {
12056 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
12057 Py_DECREF(called_object);
12062 else if (type->tp_getattro != NULL) {
12063 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12065 if (unlikely(descr == NULL)) {
12069 descrgetfunc func = NULL;
12070 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12071 func = Py_TYPE(descr)->tp_descr_get;
12073 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12074 PyObject *called_object = func(descr, source, (PyObject *)type);
12077 if (unlikely(called_object == NULL)) {
12081 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
12082 Py_DECREF(called_object);
12087 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, descr);
12090 }
else if (type->tp_getattr != NULL) {
12091 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12093 if (unlikely(called_object == NULL)) {
12097 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
12098 Py_DECREF(called_object);
12101 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12102 Nuitka_String_AsString_Unchecked(attr_name));
12107PyObject *CALL_METHOD_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *arg) {
12108 PyObject *
const *args = &arg;
12109 CHECK_OBJECT(source);
12110 CHECK_OBJECT(attr_name);
12112 CHECK_OBJECTS(args, 1);
12114 PyTypeObject *type = Py_TYPE(source);
12116 if (hasTypeGenericGetAttr(type)) {
12118 if (unlikely(type->tp_dict == NULL)) {
12119 if (unlikely(PyType_Ready(type) < 0)) {
12124 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12125 descrgetfunc func = NULL;
12127 if (descr != NULL) {
12130 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12131 func = Py_TYPE(descr)->tp_descr_get;
12133 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12134 PyObject *called_object = func(descr, source, (PyObject *)type);
12137 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12138 Py_DECREF(called_object);
12144 Py_ssize_t dictoffset = type->tp_dictoffset;
12145 PyObject *dict = NULL;
12147 if (dictoffset != 0) {
12149 if (dictoffset < 0) {
12153 tsize = ((PyVarObject *)source)->ob_size;
12157 size = _PyObject_VAR_SIZE(type, tsize);
12159 dictoffset += (long)size;
12162 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
12166 if (dict != NULL) {
12167 CHECK_OBJECT(dict);
12171 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12173 if (called_object != NULL) {
12177 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12178 Py_DECREF(called_object);
12185 if (func != NULL) {
12186 if (func == Nuitka_Function_Type.tp_descr_get) {
12187 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
12193 PyObject *called_object = func(descr, source, (PyObject *)type);
12194 CHECK_OBJECT(called_object);
12198 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12199 Py_DECREF(called_object);
12204 if (descr != NULL) {
12205 CHECK_OBJECT(descr);
12207 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, descr, args[0]);
12212#if PYTHON_VERSION < 0x300
12213 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12214 PyString_AS_STRING(attr_name));
12216 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
12220#if PYTHON_VERSION < 0x300
12221 else if (type == &PyInstance_Type) {
12222 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12226 assert(attr_name != const_str_plain___dict__);
12227 assert(attr_name != const_str_plain___class__);
12230 PyObject *called_object =
12231 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12235 if (called_object != NULL) {
12236 return CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12240 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12244 if (called_object != NULL) {
12245 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12247 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12248 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12250 }
else if (descr_get != NULL) {
12251 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12253 if (unlikely(method == NULL)) {
12257 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, method, args[0]);
12261 return CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12264 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12265 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12266 PyString_AS_STRING(source_instance->in_class->cl_name),
12267 PyString_AS_STRING(attr_name));
12274 PyObject *args2[] = {source, attr_name};
12276 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12278 if (unlikely(called_object == NULL)) {
12282 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12283 Py_DECREF(called_object);
12288 else if (type->tp_getattro != NULL) {
12289 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12291 if (unlikely(descr == NULL)) {
12295 descrgetfunc func = NULL;
12296 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12297 func = Py_TYPE(descr)->tp_descr_get;
12299 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12300 PyObject *called_object = func(descr, source, (PyObject *)type);
12303 if (unlikely(called_object == NULL)) {
12307 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12308 Py_DECREF(called_object);
12313 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, descr, args[0]);
12316 }
else if (type->tp_getattr != NULL) {
12317 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12319 if (unlikely(called_object == NULL)) {
12323 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12324 Py_DECREF(called_object);
12327 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12328 Nuitka_String_AsString_Unchecked(attr_name));
12333PyObject *CALL_METHOD_WITH_ARGS2(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
12334 CHECK_OBJECT(source);
12335 CHECK_OBJECT(attr_name);
12337 CHECK_OBJECTS(args, 2);
12339 PyTypeObject *type = Py_TYPE(source);
12341 if (hasTypeGenericGetAttr(type)) {
12343 if (unlikely(type->tp_dict == NULL)) {
12344 if (unlikely(PyType_Ready(type) < 0)) {
12349 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12350 descrgetfunc func = NULL;
12352 if (descr != NULL) {
12355 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12356 func = Py_TYPE(descr)->tp_descr_get;
12358 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12359 PyObject *called_object = func(descr, source, (PyObject *)type);
12362 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12363 Py_DECREF(called_object);
12369 Py_ssize_t dictoffset = type->tp_dictoffset;
12370 PyObject *dict = NULL;
12372 if (dictoffset != 0) {
12374 if (dictoffset < 0) {
12378 tsize = ((PyVarObject *)source)->ob_size;
12382 size = _PyObject_VAR_SIZE(type, tsize);
12384 dictoffset += (long)size;
12387 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
12391 if (dict != NULL) {
12392 CHECK_OBJECT(dict);
12396 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12398 if (called_object != NULL) {
12402 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12403 Py_DECREF(called_object);
12410 if (func != NULL) {
12411 if (func == Nuitka_Function_Type.tp_descr_get) {
12412 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
12418 PyObject *called_object = func(descr, source, (PyObject *)type);
12419 CHECK_OBJECT(called_object);
12423 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12424 Py_DECREF(called_object);
12429 if (descr != NULL) {
12430 CHECK_OBJECT(descr);
12432 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, descr, args);
12437#if PYTHON_VERSION < 0x300
12438 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12439 PyString_AS_STRING(attr_name));
12441 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
12445#if PYTHON_VERSION < 0x300
12446 else if (type == &PyInstance_Type) {
12447 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12451 assert(attr_name != const_str_plain___dict__);
12452 assert(attr_name != const_str_plain___class__);
12455 PyObject *called_object =
12456 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12460 if (called_object != NULL) {
12461 return CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12465 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12469 if (called_object != NULL) {
12470 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12472 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12473 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12475 }
else if (descr_get != NULL) {
12476 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12478 if (unlikely(method == NULL)) {
12482 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, method, args);
12486 return CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12489 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12490 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12491 PyString_AS_STRING(source_instance->in_class->cl_name),
12492 PyString_AS_STRING(attr_name));
12499 PyObject *args2[] = {source, attr_name};
12501 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12503 if (unlikely(called_object == NULL)) {
12507 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12508 Py_DECREF(called_object);
12513 else if (type->tp_getattro != NULL) {
12514 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12516 if (unlikely(descr == NULL)) {
12520 descrgetfunc func = NULL;
12521 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12522 func = Py_TYPE(descr)->tp_descr_get;
12524 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12525 PyObject *called_object = func(descr, source, (PyObject *)type);
12528 if (unlikely(called_object == NULL)) {
12532 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12533 Py_DECREF(called_object);
12538 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, descr, args);
12541 }
else if (type->tp_getattr != NULL) {
12542 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12544 if (unlikely(called_object == NULL)) {
12548 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12549 Py_DECREF(called_object);
12552 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12553 Nuitka_String_AsString_Unchecked(attr_name));
12558PyObject *CALL_METHOD_WITH_ARGS3(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
12559 CHECK_OBJECT(source);
12560 CHECK_OBJECT(attr_name);
12562 CHECK_OBJECTS(args, 3);
12564 PyTypeObject *type = Py_TYPE(source);
12566 if (hasTypeGenericGetAttr(type)) {
12568 if (unlikely(type->tp_dict == NULL)) {
12569 if (unlikely(PyType_Ready(type) < 0)) {
12574 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12575 descrgetfunc func = NULL;
12577 if (descr != NULL) {
12580 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12581 func = Py_TYPE(descr)->tp_descr_get;
12583 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12584 PyObject *called_object = func(descr, source, (PyObject *)type);
12587 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12588 Py_DECREF(called_object);
12594 Py_ssize_t dictoffset = type->tp_dictoffset;
12595 PyObject *dict = NULL;
12597 if (dictoffset != 0) {
12599 if (dictoffset < 0) {
12603 tsize = ((PyVarObject *)source)->ob_size;
12607 size = _PyObject_VAR_SIZE(type, tsize);
12609 dictoffset += (long)size;
12612 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
12616 if (dict != NULL) {
12617 CHECK_OBJECT(dict);
12621 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12623 if (called_object != NULL) {
12627 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12628 Py_DECREF(called_object);
12635 if (func != NULL) {
12636 if (func == Nuitka_Function_Type.tp_descr_get) {
12637 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
12643 PyObject *called_object = func(descr, source, (PyObject *)type);
12644 CHECK_OBJECT(called_object);
12648 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12649 Py_DECREF(called_object);
12654 if (descr != NULL) {
12655 CHECK_OBJECT(descr);
12657 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, descr, args);
12662#if PYTHON_VERSION < 0x300
12663 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12664 PyString_AS_STRING(attr_name));
12666 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
12670#if PYTHON_VERSION < 0x300
12671 else if (type == &PyInstance_Type) {
12672 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12676 assert(attr_name != const_str_plain___dict__);
12677 assert(attr_name != const_str_plain___class__);
12680 PyObject *called_object =
12681 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12685 if (called_object != NULL) {
12686 return CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12690 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12694 if (called_object != NULL) {
12695 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12697 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12698 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12700 }
else if (descr_get != NULL) {
12701 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12703 if (unlikely(method == NULL)) {
12707 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, method, args);
12711 return CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12714 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12715 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12716 PyString_AS_STRING(source_instance->in_class->cl_name),
12717 PyString_AS_STRING(attr_name));
12724 PyObject *args2[] = {source, attr_name};
12726 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12728 if (unlikely(called_object == NULL)) {
12732 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12733 Py_DECREF(called_object);
12738 else if (type->tp_getattro != NULL) {
12739 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12741 if (unlikely(descr == NULL)) {
12745 descrgetfunc func = NULL;
12746 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12747 func = Py_TYPE(descr)->tp_descr_get;
12749 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12750 PyObject *called_object = func(descr, source, (PyObject *)type);
12753 if (unlikely(called_object == NULL)) {
12757 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12758 Py_DECREF(called_object);
12763 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, descr, args);
12766 }
else if (type->tp_getattr != NULL) {
12767 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12769 if (unlikely(called_object == NULL)) {
12773 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12774 Py_DECREF(called_object);
12777 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12778 Nuitka_String_AsString_Unchecked(attr_name));
12783PyObject *CALL_METHOD_WITH_ARGS4(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
12784 CHECK_OBJECT(source);
12785 CHECK_OBJECT(attr_name);
12787 CHECK_OBJECTS(args, 4);
12789 PyTypeObject *type = Py_TYPE(source);
12791 if (hasTypeGenericGetAttr(type)) {
12793 if (unlikely(type->tp_dict == NULL)) {
12794 if (unlikely(PyType_Ready(type) < 0)) {
12799 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12800 descrgetfunc func = NULL;
12802 if (descr != NULL) {
12805 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12806 func = Py_TYPE(descr)->tp_descr_get;
12808 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12809 PyObject *called_object = func(descr, source, (PyObject *)type);
12812 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12813 Py_DECREF(called_object);
12819 Py_ssize_t dictoffset = type->tp_dictoffset;
12820 PyObject *dict = NULL;
12822 if (dictoffset != 0) {
12824 if (dictoffset < 0) {
12828 tsize = ((PyVarObject *)source)->ob_size;
12832 size = _PyObject_VAR_SIZE(type, tsize);
12834 dictoffset += (long)size;
12837 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
12841 if (dict != NULL) {
12842 CHECK_OBJECT(dict);
12846 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12848 if (called_object != NULL) {
12852 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12853 Py_DECREF(called_object);
12860 if (func != NULL) {
12861 if (func == Nuitka_Function_Type.tp_descr_get) {
12862 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
12868 PyObject *called_object = func(descr, source, (PyObject *)type);
12869 CHECK_OBJECT(called_object);
12873 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12874 Py_DECREF(called_object);
12879 if (descr != NULL) {
12880 CHECK_OBJECT(descr);
12882 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, descr, args);
12887#if PYTHON_VERSION < 0x300
12888 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12889 PyString_AS_STRING(attr_name));
12891 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
12895#if PYTHON_VERSION < 0x300
12896 else if (type == &PyInstance_Type) {
12897 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12901 assert(attr_name != const_str_plain___dict__);
12902 assert(attr_name != const_str_plain___class__);
12905 PyObject *called_object =
12906 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12910 if (called_object != NULL) {
12911 return CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12915 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12919 if (called_object != NULL) {
12920 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12922 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12923 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12925 }
else if (descr_get != NULL) {
12926 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12928 if (unlikely(method == NULL)) {
12932 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, method, args);
12936 return CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12939 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12940 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12941 PyString_AS_STRING(source_instance->in_class->cl_name),
12942 PyString_AS_STRING(attr_name));
12949 PyObject *args2[] = {source, attr_name};
12951 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12953 if (unlikely(called_object == NULL)) {
12957 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12958 Py_DECREF(called_object);
12963 else if (type->tp_getattro != NULL) {
12964 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12966 if (unlikely(descr == NULL)) {
12970 descrgetfunc func = NULL;
12971 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12972 func = Py_TYPE(descr)->tp_descr_get;
12974 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12975 PyObject *called_object = func(descr, source, (PyObject *)type);
12978 if (unlikely(called_object == NULL)) {
12982 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12983 Py_DECREF(called_object);
12988 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, descr, args);
12991 }
else if (type->tp_getattr != NULL) {
12992 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12994 if (unlikely(called_object == NULL)) {
12998 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12999 Py_DECREF(called_object);
13002 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13003 Nuitka_String_AsString_Unchecked(attr_name));
13008PyObject *CALL_METHOD_WITH_ARGS5(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13009 CHECK_OBJECT(source);
13010 CHECK_OBJECT(attr_name);
13012 CHECK_OBJECTS(args, 5);
13014 PyTypeObject *type = Py_TYPE(source);
13016 if (hasTypeGenericGetAttr(type)) {
13018 if (unlikely(type->tp_dict == NULL)) {
13019 if (unlikely(PyType_Ready(type) < 0)) {
13024 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13025 descrgetfunc func = NULL;
13027 if (descr != NULL) {
13030 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13031 func = Py_TYPE(descr)->tp_descr_get;
13033 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13034 PyObject *called_object = func(descr, source, (PyObject *)type);
13037 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13038 Py_DECREF(called_object);
13044 Py_ssize_t dictoffset = type->tp_dictoffset;
13045 PyObject *dict = NULL;
13047 if (dictoffset != 0) {
13049 if (dictoffset < 0) {
13053 tsize = ((PyVarObject *)source)->ob_size;
13057 size = _PyObject_VAR_SIZE(type, tsize);
13059 dictoffset += (long)size;
13062 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13066 if (dict != NULL) {
13067 CHECK_OBJECT(dict);
13071 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13073 if (called_object != NULL) {
13077 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13078 Py_DECREF(called_object);
13085 if (func != NULL) {
13086 if (func == Nuitka_Function_Type.tp_descr_get) {
13087 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13093 PyObject *called_object = func(descr, source, (PyObject *)type);
13094 CHECK_OBJECT(called_object);
13098 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13099 Py_DECREF(called_object);
13104 if (descr != NULL) {
13105 CHECK_OBJECT(descr);
13107 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, descr, args);
13112#if PYTHON_VERSION < 0x300
13113 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13114 PyString_AS_STRING(attr_name));
13116 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
13120#if PYTHON_VERSION < 0x300
13121 else if (type == &PyInstance_Type) {
13122 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13126 assert(attr_name != const_str_plain___dict__);
13127 assert(attr_name != const_str_plain___class__);
13130 PyObject *called_object =
13131 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13135 if (called_object != NULL) {
13136 return CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13140 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13144 if (called_object != NULL) {
13145 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13147 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13148 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
13150 }
else if (descr_get != NULL) {
13151 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13153 if (unlikely(method == NULL)) {
13157 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, method, args);
13161 return CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13164 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13165 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
13166 PyString_AS_STRING(source_instance->in_class->cl_name),
13167 PyString_AS_STRING(attr_name));
13174 PyObject *args2[] = {source, attr_name};
13176 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13178 if (unlikely(called_object == NULL)) {
13182 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13183 Py_DECREF(called_object);
13188 else if (type->tp_getattro != NULL) {
13189 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13191 if (unlikely(descr == NULL)) {
13195 descrgetfunc func = NULL;
13196 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13197 func = Py_TYPE(descr)->tp_descr_get;
13199 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13200 PyObject *called_object = func(descr, source, (PyObject *)type);
13203 if (unlikely(called_object == NULL)) {
13207 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13208 Py_DECREF(called_object);
13213 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, descr, args);
13216 }
else if (type->tp_getattr != NULL) {
13217 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
13219 if (unlikely(called_object == NULL)) {
13223 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13224 Py_DECREF(called_object);
13227 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13228 Nuitka_String_AsString_Unchecked(attr_name));
13233PyObject *CALL_METHOD_WITH_ARGS6(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13234 CHECK_OBJECT(source);
13235 CHECK_OBJECT(attr_name);
13237 CHECK_OBJECTS(args, 6);
13239 PyTypeObject *type = Py_TYPE(source);
13241 if (hasTypeGenericGetAttr(type)) {
13243 if (unlikely(type->tp_dict == NULL)) {
13244 if (unlikely(PyType_Ready(type) < 0)) {
13249 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13250 descrgetfunc func = NULL;
13252 if (descr != NULL) {
13255 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13256 func = Py_TYPE(descr)->tp_descr_get;
13258 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13259 PyObject *called_object = func(descr, source, (PyObject *)type);
13262 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13263 Py_DECREF(called_object);
13269 Py_ssize_t dictoffset = type->tp_dictoffset;
13270 PyObject *dict = NULL;
13272 if (dictoffset != 0) {
13274 if (dictoffset < 0) {
13278 tsize = ((PyVarObject *)source)->ob_size;
13282 size = _PyObject_VAR_SIZE(type, tsize);
13284 dictoffset += (long)size;
13287 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13291 if (dict != NULL) {
13292 CHECK_OBJECT(dict);
13296 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13298 if (called_object != NULL) {
13302 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13303 Py_DECREF(called_object);
13310 if (func != NULL) {
13311 if (func == Nuitka_Function_Type.tp_descr_get) {
13312 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13318 PyObject *called_object = func(descr, source, (PyObject *)type);
13319 CHECK_OBJECT(called_object);
13323 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13324 Py_DECREF(called_object);
13329 if (descr != NULL) {
13330 CHECK_OBJECT(descr);
13332 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, descr, args);
13337#if PYTHON_VERSION < 0x300
13338 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13339 PyString_AS_STRING(attr_name));
13341 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
13345#if PYTHON_VERSION < 0x300
13346 else if (type == &PyInstance_Type) {
13347 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13351 assert(attr_name != const_str_plain___dict__);
13352 assert(attr_name != const_str_plain___class__);
13355 PyObject *called_object =
13356 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13360 if (called_object != NULL) {
13361 return CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13365 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13369 if (called_object != NULL) {
13370 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13372 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13373 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
13375 }
else if (descr_get != NULL) {
13376 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13378 if (unlikely(method == NULL)) {
13382 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, method, args);
13386 return CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13389 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13390 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
13391 PyString_AS_STRING(source_instance->in_class->cl_name),
13392 PyString_AS_STRING(attr_name));
13399 PyObject *args2[] = {source, attr_name};
13401 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13403 if (unlikely(called_object == NULL)) {
13407 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13408 Py_DECREF(called_object);
13413 else if (type->tp_getattro != NULL) {
13414 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13416 if (unlikely(descr == NULL)) {
13420 descrgetfunc func = NULL;
13421 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13422 func = Py_TYPE(descr)->tp_descr_get;
13424 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13425 PyObject *called_object = func(descr, source, (PyObject *)type);
13428 if (unlikely(called_object == NULL)) {
13432 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13433 Py_DECREF(called_object);
13438 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, descr, args);
13441 }
else if (type->tp_getattr != NULL) {
13442 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
13444 if (unlikely(called_object == NULL)) {
13448 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13449 Py_DECREF(called_object);
13452 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13453 Nuitka_String_AsString_Unchecked(attr_name));
13458PyObject *CALL_METHOD_WITH_ARGS7(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13459 CHECK_OBJECT(source);
13460 CHECK_OBJECT(attr_name);
13462 CHECK_OBJECTS(args, 7);
13464 PyTypeObject *type = Py_TYPE(source);
13466 if (hasTypeGenericGetAttr(type)) {
13468 if (unlikely(type->tp_dict == NULL)) {
13469 if (unlikely(PyType_Ready(type) < 0)) {
13474 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13475 descrgetfunc func = NULL;
13477 if (descr != NULL) {
13480 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13481 func = Py_TYPE(descr)->tp_descr_get;
13483 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13484 PyObject *called_object = func(descr, source, (PyObject *)type);
13487 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13488 Py_DECREF(called_object);
13494 Py_ssize_t dictoffset = type->tp_dictoffset;
13495 PyObject *dict = NULL;
13497 if (dictoffset != 0) {
13499 if (dictoffset < 0) {
13503 tsize = ((PyVarObject *)source)->ob_size;
13507 size = _PyObject_VAR_SIZE(type, tsize);
13509 dictoffset += (long)size;
13512 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13516 if (dict != NULL) {
13517 CHECK_OBJECT(dict);
13521 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13523 if (called_object != NULL) {
13527 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13528 Py_DECREF(called_object);
13535 if (func != NULL) {
13536 if (func == Nuitka_Function_Type.tp_descr_get) {
13537 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13543 PyObject *called_object = func(descr, source, (PyObject *)type);
13544 CHECK_OBJECT(called_object);
13548 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13549 Py_DECREF(called_object);
13554 if (descr != NULL) {
13555 CHECK_OBJECT(descr);
13557 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, descr, args);
13562#if PYTHON_VERSION < 0x300
13563 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13564 PyString_AS_STRING(attr_name));
13566 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
13570#if PYTHON_VERSION < 0x300
13571 else if (type == &PyInstance_Type) {
13572 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13576 assert(attr_name != const_str_plain___dict__);
13577 assert(attr_name != const_str_plain___class__);
13580 PyObject *called_object =
13581 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13585 if (called_object != NULL) {
13586 return CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13590 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13594 if (called_object != NULL) {
13595 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13597 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13598 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
13600 }
else if (descr_get != NULL) {
13601 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13603 if (unlikely(method == NULL)) {
13607 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, method, args);
13611 return CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13614 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13615 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
13616 PyString_AS_STRING(source_instance->in_class->cl_name),
13617 PyString_AS_STRING(attr_name));
13624 PyObject *args2[] = {source, attr_name};
13626 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13628 if (unlikely(called_object == NULL)) {
13632 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13633 Py_DECREF(called_object);
13638 else if (type->tp_getattro != NULL) {
13639 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13641 if (unlikely(descr == NULL)) {
13645 descrgetfunc func = NULL;
13646 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13647 func = Py_TYPE(descr)->tp_descr_get;
13649 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13650 PyObject *called_object = func(descr, source, (PyObject *)type);
13653 if (unlikely(called_object == NULL)) {
13657 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13658 Py_DECREF(called_object);
13663 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, descr, args);
13666 }
else if (type->tp_getattr != NULL) {
13667 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
13669 if (unlikely(called_object == NULL)) {
13673 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13674 Py_DECREF(called_object);
13677 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13678 Nuitka_String_AsString_Unchecked(attr_name));
13683PyObject *CALL_METHOD_WITH_ARGS8(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13684 CHECK_OBJECT(source);
13685 CHECK_OBJECT(attr_name);
13687 CHECK_OBJECTS(args, 8);
13689 PyTypeObject *type = Py_TYPE(source);
13691 if (hasTypeGenericGetAttr(type)) {
13693 if (unlikely(type->tp_dict == NULL)) {
13694 if (unlikely(PyType_Ready(type) < 0)) {
13699 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13700 descrgetfunc func = NULL;
13702 if (descr != NULL) {
13705 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13706 func = Py_TYPE(descr)->tp_descr_get;
13708 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13709 PyObject *called_object = func(descr, source, (PyObject *)type);
13712 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13713 Py_DECREF(called_object);
13719 Py_ssize_t dictoffset = type->tp_dictoffset;
13720 PyObject *dict = NULL;
13722 if (dictoffset != 0) {
13724 if (dictoffset < 0) {
13728 tsize = ((PyVarObject *)source)->ob_size;
13732 size = _PyObject_VAR_SIZE(type, tsize);
13734 dictoffset += (long)size;
13737 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13741 if (dict != NULL) {
13742 CHECK_OBJECT(dict);
13746 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13748 if (called_object != NULL) {
13752 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13753 Py_DECREF(called_object);
13760 if (func != NULL) {
13761 if (func == Nuitka_Function_Type.tp_descr_get) {
13762 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13768 PyObject *called_object = func(descr, source, (PyObject *)type);
13769 CHECK_OBJECT(called_object);
13773 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13774 Py_DECREF(called_object);
13779 if (descr != NULL) {
13780 CHECK_OBJECT(descr);
13782 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, descr, args);
13787#if PYTHON_VERSION < 0x300
13788 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13789 PyString_AS_STRING(attr_name));
13791 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
13795#if PYTHON_VERSION < 0x300
13796 else if (type == &PyInstance_Type) {
13797 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13801 assert(attr_name != const_str_plain___dict__);
13802 assert(attr_name != const_str_plain___class__);
13805 PyObject *called_object =
13806 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13810 if (called_object != NULL) {
13811 return CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13815 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13819 if (called_object != NULL) {
13820 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13822 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13823 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
13825 }
else if (descr_get != NULL) {
13826 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13828 if (unlikely(method == NULL)) {
13832 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, method, args);
13836 return CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13839 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13840 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
13841 PyString_AS_STRING(source_instance->in_class->cl_name),
13842 PyString_AS_STRING(attr_name));
13849 PyObject *args2[] = {source, attr_name};
13851 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13853 if (unlikely(called_object == NULL)) {
13857 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13858 Py_DECREF(called_object);
13863 else if (type->tp_getattro != NULL) {
13864 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13866 if (unlikely(descr == NULL)) {
13870 descrgetfunc func = NULL;
13871 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13872 func = Py_TYPE(descr)->tp_descr_get;
13874 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13875 PyObject *called_object = func(descr, source, (PyObject *)type);
13878 if (unlikely(called_object == NULL)) {
13882 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13883 Py_DECREF(called_object);
13888 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, descr, args);
13891 }
else if (type->tp_getattr != NULL) {
13892 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
13894 if (unlikely(called_object == NULL)) {
13898 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13899 Py_DECREF(called_object);
13902 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13903 Nuitka_String_AsString_Unchecked(attr_name));
13908PyObject *CALL_METHOD_WITH_ARGS9(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13909 CHECK_OBJECT(source);
13910 CHECK_OBJECT(attr_name);
13912 CHECK_OBJECTS(args, 9);
13914 PyTypeObject *type = Py_TYPE(source);
13916 if (hasTypeGenericGetAttr(type)) {
13918 if (unlikely(type->tp_dict == NULL)) {
13919 if (unlikely(PyType_Ready(type) < 0)) {
13924 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13925 descrgetfunc func = NULL;
13927 if (descr != NULL) {
13930 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13931 func = Py_TYPE(descr)->tp_descr_get;
13933 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13934 PyObject *called_object = func(descr, source, (PyObject *)type);
13937 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
13938 Py_DECREF(called_object);
13944 Py_ssize_t dictoffset = type->tp_dictoffset;
13945 PyObject *dict = NULL;
13947 if (dictoffset != 0) {
13949 if (dictoffset < 0) {
13953 tsize = ((PyVarObject *)source)->ob_size;
13957 size = _PyObject_VAR_SIZE(type, tsize);
13959 dictoffset += (long)size;
13962 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13966 if (dict != NULL) {
13967 CHECK_OBJECT(dict);
13971 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13973 if (called_object != NULL) {
13977 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
13978 Py_DECREF(called_object);
13985 if (func != NULL) {
13986 if (func == Nuitka_Function_Type.tp_descr_get) {
13987 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13993 PyObject *called_object = func(descr, source, (PyObject *)type);
13994 CHECK_OBJECT(called_object);
13998 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
13999 Py_DECREF(called_object);
14004 if (descr != NULL) {
14005 CHECK_OBJECT(descr);
14007 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, descr, args);
14012#if PYTHON_VERSION < 0x300
14013 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
14014 PyString_AS_STRING(attr_name));
14016 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
14020#if PYTHON_VERSION < 0x300
14021 else if (type == &PyInstance_Type) {
14022 PyInstanceObject *source_instance = (PyInstanceObject *)source;
14026 assert(attr_name != const_str_plain___dict__);
14027 assert(attr_name != const_str_plain___class__);
14030 PyObject *called_object =
14031 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
14035 if (called_object != NULL) {
14036 return CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14040 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
14044 if (called_object != NULL) {
14045 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
14047 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
14048 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
14050 }
else if (descr_get != NULL) {
14051 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
14053 if (unlikely(method == NULL)) {
14057 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, method, args);
14061 return CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14064 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
14065 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
14066 PyString_AS_STRING(source_instance->in_class->cl_name),
14067 PyString_AS_STRING(attr_name));
14074 PyObject *args2[] = {source, attr_name};
14076 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
14078 if (unlikely(called_object == NULL)) {
14082 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14083 Py_DECREF(called_object);
14088 else if (type->tp_getattro != NULL) {
14089 PyObject *descr = (*type->tp_getattro)(source, attr_name);
14091 if (unlikely(descr == NULL)) {
14095 descrgetfunc func = NULL;
14096 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
14097 func = Py_TYPE(descr)->tp_descr_get;
14099 if (func != NULL && Nuitka_Descr_IsData(descr)) {
14100 PyObject *called_object = func(descr, source, (PyObject *)type);
14103 if (unlikely(called_object == NULL)) {
14107 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14108 Py_DECREF(called_object);
14113 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, descr, args);
14116 }
else if (type->tp_getattr != NULL) {
14117 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
14119 if (unlikely(called_object == NULL)) {
14123 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14124 Py_DECREF(called_object);
14127 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
14128 Nuitka_String_AsString_Unchecked(attr_name));
14133PyObject *CALL_METHOD_WITH_ARGS10(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
14134 CHECK_OBJECT(source);
14135 CHECK_OBJECT(attr_name);
14137 CHECK_OBJECTS(args, 10);
14139 PyTypeObject *type = Py_TYPE(source);
14141 if (hasTypeGenericGetAttr(type)) {
14143 if (unlikely(type->tp_dict == NULL)) {
14144 if (unlikely(PyType_Ready(type) < 0)) {
14149 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
14150 descrgetfunc func = NULL;
14152 if (descr != NULL) {
14155 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
14156 func = Py_TYPE(descr)->tp_descr_get;
14158 if (func != NULL && Nuitka_Descr_IsData(descr)) {
14159 PyObject *called_object = func(descr, source, (PyObject *)type);
14162 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14163 Py_DECREF(called_object);
14169 Py_ssize_t dictoffset = type->tp_dictoffset;
14170 PyObject *dict = NULL;
14172 if (dictoffset != 0) {
14174 if (dictoffset < 0) {
14178 tsize = ((PyVarObject *)source)->ob_size;
14182 size = _PyObject_VAR_SIZE(type, tsize);
14184 dictoffset += (long)size;
14187 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
14191 if (dict != NULL) {
14192 CHECK_OBJECT(dict);
14196 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
14198 if (called_object != NULL) {
14202 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14203 Py_DECREF(called_object);
14210 if (func != NULL) {
14211 if (func == Nuitka_Function_Type.tp_descr_get) {
14212 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
14218 PyObject *called_object = func(descr, source, (PyObject *)type);
14219 CHECK_OBJECT(called_object);
14223 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14224 Py_DECREF(called_object);
14229 if (descr != NULL) {
14230 CHECK_OBJECT(descr);
14232 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, descr, args);
14237#if PYTHON_VERSION < 0x300
14238 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
14239 PyString_AS_STRING(attr_name));
14241 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
14245#if PYTHON_VERSION < 0x300
14246 else if (type == &PyInstance_Type) {
14247 PyInstanceObject *source_instance = (PyInstanceObject *)source;
14251 assert(attr_name != const_str_plain___dict__);
14252 assert(attr_name != const_str_plain___class__);
14255 PyObject *called_object =
14256 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
14260 if (called_object != NULL) {
14261 return CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14265 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
14269 if (called_object != NULL) {
14270 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
14272 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
14273 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
14275 }
else if (descr_get != NULL) {
14276 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
14278 if (unlikely(method == NULL)) {
14282 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, method, args);
14286 return CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14289 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
14290 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
14291 PyString_AS_STRING(source_instance->in_class->cl_name),
14292 PyString_AS_STRING(attr_name));
14299 PyObject *args2[] = {source, attr_name};
14301 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
14303 if (unlikely(called_object == NULL)) {
14307 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14308 Py_DECREF(called_object);
14313 else if (type->tp_getattro != NULL) {
14314 PyObject *descr = (*type->tp_getattro)(source, attr_name);
14316 if (unlikely(descr == NULL)) {
14320 descrgetfunc func = NULL;
14321 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
14322 func = Py_TYPE(descr)->tp_descr_get;
14324 if (func != NULL && Nuitka_Descr_IsData(descr)) {
14325 PyObject *called_object = func(descr, source, (PyObject *)type);
14328 if (unlikely(called_object == NULL)) {
14332 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14333 Py_DECREF(called_object);
14338 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, descr, args);
14341 }
else if (type->tp_getattr != NULL) {
14342 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
14344 if (unlikely(called_object == NULL)) {
14348 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14349 Py_DECREF(called_object);
14352 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
14353 Nuitka_String_AsString_Unchecked(attr_name));
14358#if defined(__clang__)
14359#pragma clang diagnostic pop
14360#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
14361#pragma GCC diagnostic pop
Definition compiled_function.h:22
Definition compiled_method.h:16