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#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
18#pragma GCC diagnostic push
20#pragma GCC diagnostic ignored "-Wparentheses"
23PyObject *CALL_FUNCTION_NO_ARGS(PyThreadState *tstate, PyObject *called) {
26 if (Nuitka_Function_Check(called)) {
27 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
34 if (function->m_args_simple && 0 == function->m_args_positional_count) {
35 result = function->m_c_code(tstate, function, NULL);
36 }
else if (function->m_args_simple && 0 + function->m_defaults_given == function->m_args_positional_count) {
37 PyObject **python_pars = &PyTuple_GET_ITEM(function->m_defaults, 0);
39 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
40 Py_INCREF(python_pars[i]);
43 result = function->m_c_code(tstate, function, python_pars);
45 result = Nuitka_CallFunctionNoArgs(tstate, function);
48 Py_LeaveRecursiveCall();
50 CHECK_OBJECT_X(result);
53 }
else if (Nuitka_Method_Check(called)) {
56 if (method->m_object == NULL) {
59 "unbound compiled_method %s%s must be called with %s instance as first argument (got nothing instead)",
60 GET_CALLABLE_NAME((PyObject *)method->m_function), GET_CALLABLE_DESC((PyObject *)method->m_function),
61 GET_CLASS_NAME(method->m_class));
64 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
72 if (function->m_args_simple && 0 + 1 == function->m_args_positional_count) {
73 PyObject *python_pars[0 + 1];
75 python_pars[0] = method->m_object;
76 Py_INCREF(method->m_object);
78 result = function->m_c_code(tstate, function, python_pars);
79 }
else if (function->m_args_simple &&
80 0 + 1 + function->m_defaults_given == function->m_args_positional_count) {
81 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
83 python_pars[0] = method->m_object;
84 Py_INCREF(method->m_object);
86 memcpy(python_pars + 1 + 0, &PyTuple_GET_ITEM(function->m_defaults, 0),
87 function->m_defaults_given *
sizeof(PyObject *));
89 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
90 Py_INCREF(python_pars[i]);
93 result = function->m_c_code(tstate, function, python_pars);
95 result = Nuitka_CallMethodFunctionNoArgs(tstate, function, method->m_object);
98 Py_LeaveRecursiveCall();
100 CHECK_OBJECT_X(result);
104#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
105 }
else if (PyCFunction_CheckExact(called)) {
106#if PYTHON_VERSION >= 0x380
107#ifdef _NUITKA_FULL_COMPAT
108 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
113 int flags = PyCFunction_GET_FLAGS(called);
117 if (!(flags & METH_VARARGS)) {
118 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
120 assert(func != NULL);
121 result = func(called, NULL, 0, NULL);
123 CHECK_OBJECT_X(result);
125 PyCFunction method = PyCFunction_GET_FUNCTION(called);
126 PyObject *self = PyCFunction_GET_SELF(called);
128 PyObject *pos_args = const_tuple_empty;
130 if (flags & METH_KEYWORDS) {
131 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
133 result = (*method)(self, pos_args);
137#ifdef _NUITKA_FULL_COMPAT
138 Py_LeaveRecursiveCall();
140 CHECK_OBJECT_X(result);
142 return Nuitka_CheckFunctionResult(tstate, called, result);
145 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
147 if (likely(flags & METH_NOARGS)) {
150#ifdef _NUITKA_FULL_COMPAT
151 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
155 PyCFunction method = PyCFunction_GET_FUNCTION(called);
156 PyObject *self = PyCFunction_GET_SELF(called);
158 PyObject *result = (*method)(self, NULL);
160#ifdef _NUITKA_FULL_COMPAT
161 Py_LeaveRecursiveCall();
163 CHECK_OBJECT_X(result);
165 return Nuitka_CheckFunctionResult(tstate, called, result);
166 }
else if (unlikely(flags & METH_O)) {
167 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (0 given)",
168 ((PyCFunctionObject *)called)->m_ml->ml_name);
170 }
else if (flags & METH_VARARGS) {
173#ifdef _NUITKA_FULL_COMPAT
174 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
178 PyCFunction method = PyCFunction_GET_FUNCTION(called);
179 PyObject *self = PyCFunction_GET_SELF(called);
183#if PYTHON_VERSION < 0x360
184 PyObject *pos_args = const_tuple_empty;
185 if (flags & METH_KEYWORDS) {
186 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
188 result = (*method)(self, pos_args);
192 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
193 PyObject *pos_args = const_tuple_empty;
194 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
195 }
else if (flags == METH_FASTCALL) {
196#if PYTHON_VERSION < 0x370
197 result = (*(_PyCFunctionFast)method)(self, NULL, 0, NULL);
199 PyObject *pos_args = const_tuple_empty;
200 result = (*(_PyCFunctionFast)method)(self, &pos_args, 0);
203 PyObject *pos_args = const_tuple_empty;
204 result = (*method)(self, pos_args);
208#ifdef _NUITKA_FULL_COMPAT
209 Py_LeaveRecursiveCall();
212 CHECK_OBJECT_X(result);
214 return Nuitka_CheckFunctionResult(tstate, called, result);
218#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
219 }
else if (PyFunction_Check(called)) {
220#if PYTHON_VERSION < 0x3b0
221 PyObject *result = callPythonFunctionNoArgs(called);
223 PyObject *result = _PyFunction_Vectorcall(called, NULL, 0, NULL);
225 CHECK_OBJECT_X(result);
229#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
230 }
else if (PyType_Check(called)) {
231 PyTypeObject *type = Py_TYPE(called);
233 if (type->tp_call == PyType_Type.tp_call) {
234 PyTypeObject *called_type = (PyTypeObject *)(called);
236 if (unlikely(called_type->tp_new == NULL)) {
237 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
241 PyObject *pos_args = const_tuple_empty;
244 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
245 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
246 formatCannotInstantiateAbstractClass(tstate, called_type);
250 obj = called_type->tp_alloc(called_type, 0);
253 obj = called_type->tp_new(called_type, pos_args, NULL);
256 if (likely(obj != NULL)) {
257 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
264 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
265 if (type->tp_init == default_tp_init_wrapper) {
267 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
270 assert(init_method != NULL);
272 bool is_compiled_function =
false;
273 bool init_method_needs_release =
false;
275 if (likely(init_method != NULL)) {
276 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
278 if (func == Nuitka_Function_Type.tp_descr_get) {
279 is_compiled_function =
true;
280 }
else if (func != NULL) {
281 init_method = func(init_method, obj, (PyObject *)(type));
282 init_method_needs_release =
true;
286 if (unlikely(init_method == NULL)) {
287 if (!HAS_ERROR_OCCURRED(tstate)) {
288 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
289 const_str_plain___init__);
296 if (is_compiled_function) {
297 result = Nuitka_CallMethodFunctionNoArgs(
300 result = CALL_FUNCTION_NO_ARGS(tstate, init_method);
302 if (init_method_needs_release) {
303 Py_DECREF(init_method);
307 if (unlikely(result == NULL)) {
314 if (unlikely(result != Py_None)) {
317 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
322 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
335#if PYTHON_VERSION < 0x300
336 }
else if (PyClass_Check(called)) {
337 PyObject *obj = PyInstance_NewRaw(called, NULL);
339 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
341 if ((init_method == NULL)) {
342 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
350 bool is_compiled_function =
false;
352 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
354 if (descr_get == NULL) {
355 Py_INCREF(init_method);
356 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
357 is_compiled_function =
true;
358 }
else if (descr_get != NULL) {
359 PyObject *descr_method = descr_get(init_method, obj, called);
361 if (unlikely(descr_method == NULL)) {
365 init_method = descr_method;
369 if (is_compiled_function) {
370 result = Nuitka_CallMethodFunctionNoArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj);
372 result = CALL_FUNCTION_NO_ARGS(tstate, init_method);
373 Py_DECREF(init_method);
375 if (unlikely(result == NULL)) {
381 if (unlikely(result != Py_None)) {
382 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
390#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
391 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
392 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
394 if (likely(func != NULL)) {
395 PyObject *result = func(called, NULL, 0, NULL);
397 CHECK_OBJECT_X(result);
399 return Nuitka_CheckFunctionResult(tstate, called, result);
406 PRINT_STRING(
"FALLBACK");
411 PyObject *result = CALL_FUNCTION(tstate, called, const_tuple_empty, NULL);
413 CHECK_OBJECT_X(result);
417PyObject *CALL_FUNCTION_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *called, PyObject *arg) {
418 PyObject *
const *args = &arg;
419 CHECK_OBJECT(called);
420 CHECK_OBJECTS(args, 1);
422 if (Nuitka_Function_Check(called)) {
423 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
430 if (function->m_args_simple && 1 == function->m_args_positional_count) {
432 result = function->m_c_code(tstate, function, (PyObject **)args);
433 }
else if (function->m_args_simple && 1 + function->m_defaults_given == function->m_args_positional_count) {
434 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
436 memcpy(python_pars, args, 1 *
sizeof(PyObject *));
437 memcpy(python_pars + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
438 function->m_defaults_given *
sizeof(PyObject *));
440 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
441 Py_INCREF(python_pars[i]);
444 result = function->m_c_code(tstate, function, python_pars);
446 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 1);
449 Py_LeaveRecursiveCall();
451 CHECK_OBJECT_X(result);
454 }
else if (Nuitka_Method_Check(called)) {
457 if (method->m_object == NULL) {
458 PyObject *self = args[0];
460 int res = PyObject_IsInstance(self, method->m_class);
462 if (unlikely(res < 0)) {
464 }
else if (unlikely(res == 0)) {
465 PyErr_Format(PyExc_TypeError,
466 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
468 GET_CALLABLE_NAME((PyObject *)method->m_function),
469 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
470 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
475 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 1);
477 CHECK_OBJECT_X(result);
481 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
489 if (function->m_args_simple && 1 + 1 == function->m_args_positional_count) {
490 PyObject *python_pars[1 + 1];
492 python_pars[0] = method->m_object;
493 Py_INCREF(method->m_object);
495 python_pars[1] = args[0];
497 result = function->m_c_code(tstate, function, python_pars);
498 }
else if (function->m_args_simple &&
499 1 + 1 + function->m_defaults_given == function->m_args_positional_count) {
500 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
502 python_pars[0] = method->m_object;
503 Py_INCREF(method->m_object);
505 memcpy(python_pars + 1, args, 1 *
sizeof(PyObject *));
506 memcpy(python_pars + 1 + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
507 function->m_defaults_given *
sizeof(PyObject *));
509 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
510 Py_INCREF(python_pars[i]);
513 result = function->m_c_code(tstate, function, python_pars);
515 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 1);
518 Py_LeaveRecursiveCall();
520 CHECK_OBJECT_X(result);
524#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
525 }
else if (PyCFunction_CheckExact(called)) {
526#if PYTHON_VERSION >= 0x380
527#ifdef _NUITKA_FULL_COMPAT
528 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
533 int flags = PyCFunction_GET_FLAGS(called);
537 if (!(flags & METH_VARARGS)) {
538 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
540 assert(func != NULL);
541 result = func(called, args, 1, NULL);
543 CHECK_OBJECT_X(result);
545 PyCFunction method = PyCFunction_GET_FUNCTION(called);
546 PyObject *self = PyCFunction_GET_SELF(called);
548 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
550 if (flags & METH_KEYWORDS) {
551 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
553 result = (*method)(self, pos_args);
559#ifdef _NUITKA_FULL_COMPAT
560 Py_LeaveRecursiveCall();
562 CHECK_OBJECT_X(result);
564 return Nuitka_CheckFunctionResult(tstate, called, result);
567 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
569 if (unlikely(flags & METH_NOARGS)) {
570 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (1 given)",
571 ((PyCFunctionObject *)called)->m_ml->ml_name);
573 }
else if ((flags & METH_O)) {
576#ifdef _NUITKA_FULL_COMPAT
577 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
581 PyCFunction method = PyCFunction_GET_FUNCTION(called);
582 PyObject *self = PyCFunction_GET_SELF(called);
584 PyObject *result = (*method)(self, args[0]);
586#ifdef _NUITKA_FULL_COMPAT
587 Py_LeaveRecursiveCall();
590 CHECK_OBJECT_X(result);
592 return Nuitka_CheckFunctionResult(tstate, called, result);
593 }
else if (flags & METH_VARARGS) {
596#ifdef _NUITKA_FULL_COMPAT
597 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
601 PyCFunction method = PyCFunction_GET_FUNCTION(called);
602 PyObject *self = PyCFunction_GET_SELF(called);
606#if PYTHON_VERSION < 0x360
607 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
608 if (flags & METH_KEYWORDS) {
609 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
611 result = (*method)(self, pos_args);
616 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
617 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
618 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
620 }
else if (flags == METH_FASTCALL) {
621#if PYTHON_VERSION < 0x370
622 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 1, NULL);
624 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
625 result = (*(_PyCFunctionFast)method)(self, &pos_args, 1);
629 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
630 result = (*method)(self, pos_args);
635#ifdef _NUITKA_FULL_COMPAT
636 Py_LeaveRecursiveCall();
639 CHECK_OBJECT_X(result);
641 return Nuitka_CheckFunctionResult(tstate, called, result);
645#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
646 }
else if (PyFunction_Check(called)) {
647#if PYTHON_VERSION < 0x3b0
648 PyObject *result = callPythonFunction(called, args, 1);
650 PyObject *result = _PyFunction_Vectorcall(called, args, 1, NULL);
652 CHECK_OBJECT_X(result);
656#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
657 }
else if (PyType_Check(called)) {
658 PyTypeObject *type = Py_TYPE(called);
660 if (type->tp_call == PyType_Type.tp_call) {
661 PyTypeObject *called_type = (PyTypeObject *)(called);
663 if (unlikely(called == (PyObject *)&PyType_Type)) {
664 PyObject *result = (PyObject *)Py_TYPE(args[0]);
669 if (unlikely(called_type->tp_new == NULL)) {
670 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
674 PyObject *pos_args = NULL;
677 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
678 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
679 formatCannotInstantiateAbstractClass(tstate, called_type);
683 obj = called_type->tp_alloc(called_type, 0);
686 pos_args = MAKE_TUPLE(tstate, args, 1);
687 obj = called_type->tp_new(called_type, pos_args, NULL);
690 if (likely(obj != NULL)) {
691 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
699 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
700 if (type->tp_init == default_tp_init_wrapper) {
701 Py_XDECREF(pos_args);
704 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
707 assert(init_method != NULL);
709 bool is_compiled_function =
false;
710 bool init_method_needs_release =
false;
712 if (likely(init_method != NULL)) {
713 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
715 if (func == Nuitka_Function_Type.tp_descr_get) {
716 is_compiled_function =
true;
717 }
else if (func != NULL) {
718 init_method = func(init_method, obj, (PyObject *)(type));
719 init_method_needs_release =
true;
723 if (unlikely(init_method == NULL)) {
724 if (!HAS_ERROR_OCCURRED(tstate)) {
725 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
726 const_str_plain___init__);
733 if (is_compiled_function) {
734 result = Nuitka_CallMethodFunctionPosArgs(
737 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
739 if (init_method_needs_release) {
740 Py_DECREF(init_method);
744 if (unlikely(result == NULL)) {
751 if (unlikely(result != Py_None)) {
754 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
758 if (pos_args == NULL) {
759 pos_args = MAKE_TUPLE(tstate, args, 1);
762 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
764 Py_XDECREF(pos_args);
771 Py_XDECREF(pos_args);
778#if PYTHON_VERSION < 0x300
779 }
else if (PyClass_Check(called)) {
780 PyObject *obj = PyInstance_NewRaw(called, NULL);
782 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
784 if (unlikely(init_method == NULL)) {
785 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
792 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
796 bool is_compiled_function =
false;
798 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
800 if (descr_get == NULL) {
801 Py_INCREF(init_method);
802 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
803 is_compiled_function =
true;
804 }
else if (descr_get != NULL) {
805 PyObject *descr_method = descr_get(init_method, obj, called);
807 if (unlikely(descr_method == NULL)) {
811 init_method = descr_method;
815 if (is_compiled_function) {
816 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
819 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
820 Py_DECREF(init_method);
822 if (unlikely(result == NULL)) {
828 if (unlikely(result != Py_None)) {
829 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
837#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
838 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
839 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
841 if (likely(func != NULL)) {
842 PyObject *result = func(called, args, 1, NULL);
844 CHECK_OBJECT_X(result);
846 return Nuitka_CheckFunctionResult(tstate, called, result);
853 PRINT_STRING(
"FALLBACK");
858 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
860 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
864 CHECK_OBJECT_X(result);
868PyObject *CALL_FUNCTION_WITH_POS_ARGS1(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
869 assert(PyTuple_CheckExact(pos_args));
870 assert(PyTuple_GET_SIZE(pos_args) == 1);
871 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
872 CHECK_OBJECT(called);
873 CHECK_OBJECTS(args, 1);
875 if (Nuitka_Function_Check(called)) {
876 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
883 if (function->m_args_simple && 1 == function->m_args_positional_count) {
885 result = function->m_c_code(tstate, function, (PyObject **)args);
886 }
else if (function->m_args_simple && 1 + function->m_defaults_given == function->m_args_positional_count) {
887 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
889 memcpy(python_pars, args, 1 *
sizeof(PyObject *));
890 memcpy(python_pars + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
891 function->m_defaults_given *
sizeof(PyObject *));
893 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
894 Py_INCREF(python_pars[i]);
897 result = function->m_c_code(tstate, function, python_pars);
899 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 1);
902 Py_LeaveRecursiveCall();
904 CHECK_OBJECT_X(result);
907 }
else if (Nuitka_Method_Check(called)) {
910 if (method->m_object == NULL) {
911 PyObject *self = args[0];
913 int res = PyObject_IsInstance(self, method->m_class);
915 if (unlikely(res < 0)) {
917 }
else if (unlikely(res == 0)) {
918 PyErr_Format(PyExc_TypeError,
919 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
921 GET_CALLABLE_NAME((PyObject *)method->m_function),
922 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
923 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
928 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 1);
930 CHECK_OBJECT_X(result);
934 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
942 if (function->m_args_simple && 1 + 1 == function->m_args_positional_count) {
943 PyObject *python_pars[1 + 1];
945 python_pars[0] = method->m_object;
946 Py_INCREF(method->m_object);
948 python_pars[1] = args[0];
950 result = function->m_c_code(tstate, function, python_pars);
951 }
else if (function->m_args_simple &&
952 1 + 1 + function->m_defaults_given == function->m_args_positional_count) {
953 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
955 python_pars[0] = method->m_object;
956 Py_INCREF(method->m_object);
958 memcpy(python_pars + 1, args, 1 *
sizeof(PyObject *));
959 memcpy(python_pars + 1 + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
960 function->m_defaults_given *
sizeof(PyObject *));
962 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
963 Py_INCREF(python_pars[i]);
966 result = function->m_c_code(tstate, function, python_pars);
968 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 1);
971 Py_LeaveRecursiveCall();
973 CHECK_OBJECT_X(result);
977#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
978 }
else if (PyCFunction_CheckExact(called)) {
979#if PYTHON_VERSION >= 0x380
980#ifdef _NUITKA_FULL_COMPAT
981 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
986 int flags = PyCFunction_GET_FLAGS(called);
990 if (!(flags & METH_VARARGS)) {
991 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
993 assert(func != NULL);
994 result = func(called, args, 1, NULL);
996 CHECK_OBJECT_X(result);
998 PyCFunction method = PyCFunction_GET_FUNCTION(called);
999 PyObject *self = PyCFunction_GET_SELF(called);
1001 if (flags & METH_KEYWORDS) {
1002 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
1004 result = (*method)(self, pos_args);
1008#ifdef _NUITKA_FULL_COMPAT
1009 Py_LeaveRecursiveCall();
1011 CHECK_OBJECT_X(result);
1013 return Nuitka_CheckFunctionResult(tstate, called, result);
1016 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
1018 if (unlikely(flags & METH_NOARGS)) {
1019 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (1 given)",
1020 ((PyCFunctionObject *)called)->m_ml->ml_name);
1022 }
else if ((flags & METH_O)) {
1025#ifdef _NUITKA_FULL_COMPAT
1026 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1030 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1031 PyObject *self = PyCFunction_GET_SELF(called);
1033 PyObject *result = (*method)(self, args[0]);
1035#ifdef _NUITKA_FULL_COMPAT
1036 Py_LeaveRecursiveCall();
1039 CHECK_OBJECT_X(result);
1041 return Nuitka_CheckFunctionResult(tstate, called, result);
1042 }
else if (flags & METH_VARARGS) {
1045#ifdef _NUITKA_FULL_COMPAT
1046 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1050 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1051 PyObject *self = PyCFunction_GET_SELF(called);
1055#if PYTHON_VERSION < 0x360
1056 if (flags & METH_KEYWORDS) {
1057 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1059 result = (*method)(self, pos_args);
1063 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
1064 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1065 }
else if (flags == METH_FASTCALL) {
1066#if PYTHON_VERSION < 0x370
1067 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 1, NULL);
1069 result = (*(_PyCFunctionFast)method)(self, &pos_args, 1);
1072 result = (*method)(self, pos_args);
1076#ifdef _NUITKA_FULL_COMPAT
1077 Py_LeaveRecursiveCall();
1080 CHECK_OBJECT_X(result);
1082 return Nuitka_CheckFunctionResult(tstate, called, result);
1086#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
1087 }
else if (PyFunction_Check(called)) {
1088#if PYTHON_VERSION < 0x3b0
1089 PyObject *result = callPythonFunction(called, args, 1);
1091 PyObject *result = _PyFunction_Vectorcall(called, args, 1, NULL);
1093 CHECK_OBJECT_X(result);
1097#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
1098 }
else if (PyType_Check(called)) {
1099 PyTypeObject *type = Py_TYPE(called);
1101 if (type->tp_call == PyType_Type.tp_call) {
1102 PyTypeObject *called_type = (PyTypeObject *)(called);
1104 if (unlikely(called == (PyObject *)&PyType_Type)) {
1105 PyObject *result = (PyObject *)Py_TYPE(args[0]);
1110 if (unlikely(called_type->tp_new == NULL)) {
1111 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
1117 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
1118 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
1119 formatCannotInstantiateAbstractClass(tstate, called_type);
1123 obj = called_type->tp_alloc(called_type, 0);
1126 obj = called_type->tp_new(called_type, pos_args, NULL);
1129 if (likely(obj != NULL)) {
1130 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
1135 type = Py_TYPE(obj);
1137 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
1138 if (type->tp_init == default_tp_init_wrapper) {
1140 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
1143 assert(init_method != NULL);
1145 bool is_compiled_function =
false;
1146 bool init_method_needs_release =
false;
1148 if (likely(init_method != NULL)) {
1149 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
1151 if (func == Nuitka_Function_Type.tp_descr_get) {
1152 is_compiled_function =
true;
1153 }
else if (func != NULL) {
1154 init_method = func(init_method, obj, (PyObject *)(type));
1155 init_method_needs_release =
true;
1159 if (unlikely(init_method == NULL)) {
1160 if (!HAS_ERROR_OCCURRED(tstate)) {
1161 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
1162 const_str_plain___init__);
1169 if (is_compiled_function) {
1170 result = Nuitka_CallMethodFunctionPosArgs(
1173 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
1175 if (init_method_needs_release) {
1176 Py_DECREF(init_method);
1180 if (unlikely(result == NULL)) {
1187 if (unlikely(result != Py_None)) {
1190 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
1195 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
1203 CHECK_OBJECT_X(obj);
1208#if PYTHON_VERSION < 0x300
1209 }
else if (PyClass_Check(called)) {
1210 PyObject *obj = PyInstance_NewRaw(called, NULL);
1212 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
1214 if (unlikely(init_method == NULL)) {
1215 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
1222 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
1226 bool is_compiled_function =
false;
1228 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
1230 if (descr_get == NULL) {
1231 Py_INCREF(init_method);
1232 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
1233 is_compiled_function =
true;
1234 }
else if (descr_get != NULL) {
1235 PyObject *descr_method = descr_get(init_method, obj, called);
1237 if (unlikely(descr_method == NULL)) {
1241 init_method = descr_method;
1245 if (is_compiled_function) {
1246 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
1249 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
1250 Py_DECREF(init_method);
1252 if (unlikely(result == NULL)) {
1258 if (unlikely(result != Py_None)) {
1259 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
1263 CHECK_OBJECT_X(obj);
1267#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
1268 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
1269 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1271 if (likely(func != NULL)) {
1272 PyObject *result = func(called, args, 1, NULL);
1274 CHECK_OBJECT_X(result);
1276 return Nuitka_CheckFunctionResult(tstate, called, result);
1283 PRINT_STRING(
"FALLBACK");
1288 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
1290 CHECK_OBJECT_X(result);
1294PyObject *CALL_FUNCTION_WITH_ARGS2(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
1295 CHECK_OBJECT(called);
1296 CHECK_OBJECTS(args, 2);
1298 if (Nuitka_Function_Check(called)) {
1299 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1306 if (function->m_args_simple && 2 == function->m_args_positional_count) {
1307 for (Py_ssize_t i = 0; i < 2; i++) {
1310 result = function->m_c_code(tstate, function, (PyObject **)args);
1311 }
else if (function->m_args_simple && 2 + function->m_defaults_given == function->m_args_positional_count) {
1312 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1314 memcpy(python_pars, args, 2 *
sizeof(PyObject *));
1315 memcpy(python_pars + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1316 function->m_defaults_given *
sizeof(PyObject *));
1318 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
1319 Py_INCREF(python_pars[i]);
1322 result = function->m_c_code(tstate, function, python_pars);
1324 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 2);
1327 Py_LeaveRecursiveCall();
1329 CHECK_OBJECT_X(result);
1332 }
else if (Nuitka_Method_Check(called)) {
1335 if (method->m_object == NULL) {
1336 PyObject *self = args[0];
1338 int res = PyObject_IsInstance(self, method->m_class);
1340 if (unlikely(res < 0)) {
1342 }
else if (unlikely(res == 0)) {
1343 PyErr_Format(PyExc_TypeError,
1344 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
1345 "instance instead)",
1346 GET_CALLABLE_NAME((PyObject *)method->m_function),
1347 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
1348 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
1353 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 2);
1355 CHECK_OBJECT_X(result);
1359 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1367 if (function->m_args_simple && 2 + 1 == function->m_args_positional_count) {
1368 PyObject *python_pars[2 + 1];
1370 python_pars[0] = method->m_object;
1371 Py_INCREF(method->m_object);
1373 for (Py_ssize_t i = 0; i < 2; i++) {
1374 python_pars[i + 1] = args[i];
1377 result = function->m_c_code(tstate, function, python_pars);
1378 }
else if (function->m_args_simple &&
1379 2 + 1 + function->m_defaults_given == function->m_args_positional_count) {
1380 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1382 python_pars[0] = method->m_object;
1383 Py_INCREF(method->m_object);
1385 memcpy(python_pars + 1, args, 2 *
sizeof(PyObject *));
1386 memcpy(python_pars + 1 + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1387 function->m_defaults_given *
sizeof(PyObject *));
1389 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
1390 Py_INCREF(python_pars[i]);
1393 result = function->m_c_code(tstate, function, python_pars);
1395 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 2);
1398 Py_LeaveRecursiveCall();
1400 CHECK_OBJECT_X(result);
1404#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
1405 }
else if (PyCFunction_CheckExact(called)) {
1406#if PYTHON_VERSION >= 0x380
1407#ifdef _NUITKA_FULL_COMPAT
1408 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1413 int flags = PyCFunction_GET_FLAGS(called);
1417 if (!(flags & METH_VARARGS)) {
1418 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1420 assert(func != NULL);
1421 result = func(called, args, 2, NULL);
1423 CHECK_OBJECT_X(result);
1425 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1426 PyObject *self = PyCFunction_GET_SELF(called);
1428 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1430 if (flags & METH_KEYWORDS) {
1431 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
1433 result = (*method)(self, pos_args);
1436 Py_DECREF(pos_args);
1439#ifdef _NUITKA_FULL_COMPAT
1440 Py_LeaveRecursiveCall();
1442 CHECK_OBJECT_X(result);
1444 return Nuitka_CheckFunctionResult(tstate, called, result);
1447 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
1449 if (unlikely(flags & METH_NOARGS)) {
1450 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (2 given)",
1451 ((PyCFunctionObject *)called)->m_ml->ml_name);
1453 }
else if (unlikely(flags & METH_O)) {
1454 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (2 given)",
1455 ((PyCFunctionObject *)called)->m_ml->ml_name);
1457 }
else if (flags & METH_VARARGS) {
1460#ifdef _NUITKA_FULL_COMPAT
1461 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1465 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1466 PyObject *self = PyCFunction_GET_SELF(called);
1470#if PYTHON_VERSION < 0x360
1471 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1472 if (flags & METH_KEYWORDS) {
1473 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1475 result = (*method)(self, pos_args);
1478 Py_DECREF(pos_args);
1480 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
1481 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1482 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1483 Py_DECREF(pos_args);
1484 }
else if (flags == METH_FASTCALL) {
1485#if PYTHON_VERSION < 0x370
1486 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 2, NULL);
1488 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1489 result = (*(_PyCFunctionFast)method)(self, &pos_args, 2);
1490 Py_DECREF(pos_args);
1493 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1494 result = (*method)(self, pos_args);
1495 Py_DECREF(pos_args);
1499#ifdef _NUITKA_FULL_COMPAT
1500 Py_LeaveRecursiveCall();
1503 CHECK_OBJECT_X(result);
1505 return Nuitka_CheckFunctionResult(tstate, called, result);
1509#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
1510 }
else if (PyFunction_Check(called)) {
1511#if PYTHON_VERSION < 0x3b0
1512 PyObject *result = callPythonFunction(called, args, 2);
1514 PyObject *result = _PyFunction_Vectorcall(called, args, 2, NULL);
1516 CHECK_OBJECT_X(result);
1520#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
1521 }
else if (PyType_Check(called)) {
1522 PyTypeObject *type = Py_TYPE(called);
1524 if (type->tp_call == PyType_Type.tp_call) {
1525 PyTypeObject *called_type = (PyTypeObject *)(called);
1527 if (unlikely(called_type->tp_new == NULL)) {
1528 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
1532 PyObject *pos_args = NULL;
1535 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
1536 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
1537 formatCannotInstantiateAbstractClass(tstate, called_type);
1541 obj = called_type->tp_alloc(called_type, 0);
1544 pos_args = MAKE_TUPLE(tstate, args, 2);
1545 obj = called_type->tp_new(called_type, pos_args, NULL);
1548 if (likely(obj != NULL)) {
1549 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
1550 Py_DECREF(pos_args);
1555 type = Py_TYPE(obj);
1557 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
1558 if (type->tp_init == default_tp_init_wrapper) {
1559 Py_XDECREF(pos_args);
1562 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
1565 assert(init_method != NULL);
1567 bool is_compiled_function =
false;
1568 bool init_method_needs_release =
false;
1570 if (likely(init_method != NULL)) {
1571 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
1573 if (func == Nuitka_Function_Type.tp_descr_get) {
1574 is_compiled_function =
true;
1575 }
else if (func != NULL) {
1576 init_method = func(init_method, obj, (PyObject *)(type));
1577 init_method_needs_release =
true;
1581 if (unlikely(init_method == NULL)) {
1582 if (!HAS_ERROR_OCCURRED(tstate)) {
1583 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
1584 const_str_plain___init__);
1591 if (is_compiled_function) {
1592 result = Nuitka_CallMethodFunctionPosArgs(
1595 result = CALL_FUNCTION_WITH_ARGS2(tstate, init_method, args);
1596 if (init_method_needs_release) {
1597 Py_DECREF(init_method);
1601 if (unlikely(result == NULL)) {
1608 if (unlikely(result != Py_None)) {
1611 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
1615 if (pos_args == NULL) {
1616 pos_args = MAKE_TUPLE(tstate, args, 2);
1619 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
1621 Py_XDECREF(pos_args);
1628 Py_XDECREF(pos_args);
1630 CHECK_OBJECT_X(obj);
1635#if PYTHON_VERSION < 0x300
1636 }
else if (PyClass_Check(called)) {
1637 PyObject *obj = PyInstance_NewRaw(called, NULL);
1639 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
1641 if (unlikely(init_method == NULL)) {
1642 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
1649 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
1653 bool is_compiled_function =
false;
1655 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
1657 if (descr_get == NULL) {
1658 Py_INCREF(init_method);
1659 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
1660 is_compiled_function =
true;
1661 }
else if (descr_get != NULL) {
1662 PyObject *descr_method = descr_get(init_method, obj, called);
1664 if (unlikely(descr_method == NULL)) {
1668 init_method = descr_method;
1672 if (is_compiled_function) {
1673 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
1676 result = CALL_FUNCTION_WITH_ARGS2(tstate, init_method, args);
1677 Py_DECREF(init_method);
1679 if (unlikely(result == NULL)) {
1685 if (unlikely(result != Py_None)) {
1686 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
1690 CHECK_OBJECT_X(obj);
1694#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
1695 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
1696 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1698 if (likely(func != NULL)) {
1699 PyObject *result = func(called, args, 2, NULL);
1701 CHECK_OBJECT_X(result);
1703 return Nuitka_CheckFunctionResult(tstate, called, result);
1710 PRINT_STRING(
"FALLBACK");
1715 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1717 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
1719 Py_DECREF(pos_args);
1721 CHECK_OBJECT_X(result);
1725PyObject *CALL_FUNCTION_WITH_POS_ARGS2(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
1726 assert(PyTuple_CheckExact(pos_args));
1727 assert(PyTuple_GET_SIZE(pos_args) == 2);
1728 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
1729 CHECK_OBJECT(called);
1730 CHECK_OBJECTS(args, 2);
1732 if (Nuitka_Function_Check(called)) {
1733 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1740 if (function->m_args_simple && 2 == function->m_args_positional_count) {
1741 for (Py_ssize_t i = 0; i < 2; i++) {
1744 result = function->m_c_code(tstate, function, (PyObject **)args);
1745 }
else if (function->m_args_simple && 2 + function->m_defaults_given == function->m_args_positional_count) {
1746 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1748 memcpy(python_pars, args, 2 *
sizeof(PyObject *));
1749 memcpy(python_pars + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1750 function->m_defaults_given *
sizeof(PyObject *));
1752 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
1753 Py_INCREF(python_pars[i]);
1756 result = function->m_c_code(tstate, function, python_pars);
1758 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 2);
1761 Py_LeaveRecursiveCall();
1763 CHECK_OBJECT_X(result);
1766 }
else if (Nuitka_Method_Check(called)) {
1769 if (method->m_object == NULL) {
1770 PyObject *self = args[0];
1772 int res = PyObject_IsInstance(self, method->m_class);
1774 if (unlikely(res < 0)) {
1776 }
else if (unlikely(res == 0)) {
1777 PyErr_Format(PyExc_TypeError,
1778 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
1779 "instance instead)",
1780 GET_CALLABLE_NAME((PyObject *)method->m_function),
1781 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
1782 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
1787 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 2);
1789 CHECK_OBJECT_X(result);
1793 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1801 if (function->m_args_simple && 2 + 1 == function->m_args_positional_count) {
1802 PyObject *python_pars[2 + 1];
1804 python_pars[0] = method->m_object;
1805 Py_INCREF(method->m_object);
1807 for (Py_ssize_t i = 0; i < 2; i++) {
1808 python_pars[i + 1] = args[i];
1811 result = function->m_c_code(tstate, function, python_pars);
1812 }
else if (function->m_args_simple &&
1813 2 + 1 + function->m_defaults_given == function->m_args_positional_count) {
1814 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1816 python_pars[0] = method->m_object;
1817 Py_INCREF(method->m_object);
1819 memcpy(python_pars + 1, args, 2 *
sizeof(PyObject *));
1820 memcpy(python_pars + 1 + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1821 function->m_defaults_given *
sizeof(PyObject *));
1823 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
1824 Py_INCREF(python_pars[i]);
1827 result = function->m_c_code(tstate, function, python_pars);
1829 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 2);
1832 Py_LeaveRecursiveCall();
1834 CHECK_OBJECT_X(result);
1838#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
1839 }
else if (PyCFunction_CheckExact(called)) {
1840#if PYTHON_VERSION >= 0x380
1841#ifdef _NUITKA_FULL_COMPAT
1842 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1847 int flags = PyCFunction_GET_FLAGS(called);
1851 if (!(flags & METH_VARARGS)) {
1852 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1854 assert(func != NULL);
1855 result = func(called, args, 2, NULL);
1857 CHECK_OBJECT_X(result);
1859 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1860 PyObject *self = PyCFunction_GET_SELF(called);
1862 if (flags & METH_KEYWORDS) {
1863 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
1865 result = (*method)(self, pos_args);
1869#ifdef _NUITKA_FULL_COMPAT
1870 Py_LeaveRecursiveCall();
1872 CHECK_OBJECT_X(result);
1874 return Nuitka_CheckFunctionResult(tstate, called, result);
1877 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
1879 if (unlikely(flags & METH_NOARGS)) {
1880 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (2 given)",
1881 ((PyCFunctionObject *)called)->m_ml->ml_name);
1883 }
else if (unlikely(flags & METH_O)) {
1884 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (2 given)",
1885 ((PyCFunctionObject *)called)->m_ml->ml_name);
1887 }
else if (flags & METH_VARARGS) {
1890#ifdef _NUITKA_FULL_COMPAT
1891 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1895 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1896 PyObject *self = PyCFunction_GET_SELF(called);
1900#if PYTHON_VERSION < 0x360
1901 if (flags & METH_KEYWORDS) {
1902 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1904 result = (*method)(self, pos_args);
1908 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
1909 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1910 }
else if (flags == METH_FASTCALL) {
1911#if PYTHON_VERSION < 0x370
1912 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 2, NULL);
1914 result = (*(_PyCFunctionFast)method)(self, &pos_args, 2);
1917 result = (*method)(self, pos_args);
1921#ifdef _NUITKA_FULL_COMPAT
1922 Py_LeaveRecursiveCall();
1925 CHECK_OBJECT_X(result);
1927 return Nuitka_CheckFunctionResult(tstate, called, result);
1931#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
1932 }
else if (PyFunction_Check(called)) {
1933#if PYTHON_VERSION < 0x3b0
1934 PyObject *result = callPythonFunction(called, args, 2);
1936 PyObject *result = _PyFunction_Vectorcall(called, args, 2, NULL);
1938 CHECK_OBJECT_X(result);
1942#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
1943 }
else if (PyType_Check(called)) {
1944 PyTypeObject *type = Py_TYPE(called);
1946 if (type->tp_call == PyType_Type.tp_call) {
1947 PyTypeObject *called_type = (PyTypeObject *)(called);
1949 if (unlikely(called_type->tp_new == NULL)) {
1950 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
1956 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
1957 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
1958 formatCannotInstantiateAbstractClass(tstate, called_type);
1962 obj = called_type->tp_alloc(called_type, 0);
1965 obj = called_type->tp_new(called_type, pos_args, NULL);
1968 if (likely(obj != NULL)) {
1969 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
1974 type = Py_TYPE(obj);
1976 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
1977 if (type->tp_init == default_tp_init_wrapper) {
1979 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
1982 assert(init_method != NULL);
1984 bool is_compiled_function =
false;
1985 bool init_method_needs_release =
false;
1987 if (likely(init_method != NULL)) {
1988 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
1990 if (func == Nuitka_Function_Type.tp_descr_get) {
1991 is_compiled_function =
true;
1992 }
else if (func != NULL) {
1993 init_method = func(init_method, obj, (PyObject *)(type));
1994 init_method_needs_release =
true;
1998 if (unlikely(init_method == NULL)) {
1999 if (!HAS_ERROR_OCCURRED(tstate)) {
2000 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
2001 const_str_plain___init__);
2008 if (is_compiled_function) {
2009 result = Nuitka_CallMethodFunctionPosArgs(
2012 result = CALL_FUNCTION_WITH_POS_ARGS2(tstate, init_method, pos_args);
2013 if (init_method_needs_release) {
2014 Py_DECREF(init_method);
2018 if (unlikely(result == NULL)) {
2025 if (unlikely(result != Py_None)) {
2028 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2033 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
2041 CHECK_OBJECT_X(obj);
2046#if PYTHON_VERSION < 0x300
2047 }
else if (PyClass_Check(called)) {
2048 PyObject *obj = PyInstance_NewRaw(called, NULL);
2050 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
2052 if (unlikely(init_method == NULL)) {
2053 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
2060 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
2064 bool is_compiled_function =
false;
2066 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
2068 if (descr_get == NULL) {
2069 Py_INCREF(init_method);
2070 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
2071 is_compiled_function =
true;
2072 }
else if (descr_get != NULL) {
2073 PyObject *descr_method = descr_get(init_method, obj, called);
2075 if (unlikely(descr_method == NULL)) {
2079 init_method = descr_method;
2083 if (is_compiled_function) {
2084 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
2087 result = CALL_FUNCTION_WITH_POS_ARGS2(tstate, init_method, pos_args);
2088 Py_DECREF(init_method);
2090 if (unlikely(result == NULL)) {
2096 if (unlikely(result != Py_None)) {
2097 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2101 CHECK_OBJECT_X(obj);
2105#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
2106 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
2107 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2109 if (likely(func != NULL)) {
2110 PyObject *result = func(called, args, 2, NULL);
2112 CHECK_OBJECT_X(result);
2114 return Nuitka_CheckFunctionResult(tstate, called, result);
2121 PRINT_STRING(
"FALLBACK");
2126 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
2128 CHECK_OBJECT_X(result);
2132PyObject *CALL_FUNCTION_WITH_ARGS3(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
2133 CHECK_OBJECT(called);
2134 CHECK_OBJECTS(args, 3);
2136 if (Nuitka_Function_Check(called)) {
2137 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2144 if (function->m_args_simple && 3 == function->m_args_positional_count) {
2145 for (Py_ssize_t i = 0; i < 3; i++) {
2148 result = function->m_c_code(tstate, function, (PyObject **)args);
2149 }
else if (function->m_args_simple && 3 + function->m_defaults_given == function->m_args_positional_count) {
2150 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2152 memcpy(python_pars, args, 3 *
sizeof(PyObject *));
2153 memcpy(python_pars + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2154 function->m_defaults_given *
sizeof(PyObject *));
2156 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
2157 Py_INCREF(python_pars[i]);
2160 result = function->m_c_code(tstate, function, python_pars);
2162 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 3);
2165 Py_LeaveRecursiveCall();
2167 CHECK_OBJECT_X(result);
2170 }
else if (Nuitka_Method_Check(called)) {
2173 if (method->m_object == NULL) {
2174 PyObject *self = args[0];
2176 int res = PyObject_IsInstance(self, method->m_class);
2178 if (unlikely(res < 0)) {
2180 }
else if (unlikely(res == 0)) {
2181 PyErr_Format(PyExc_TypeError,
2182 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
2183 "instance instead)",
2184 GET_CALLABLE_NAME((PyObject *)method->m_function),
2185 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
2186 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
2191 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 3);
2193 CHECK_OBJECT_X(result);
2197 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2205 if (function->m_args_simple && 3 + 1 == function->m_args_positional_count) {
2206 PyObject *python_pars[3 + 1];
2208 python_pars[0] = method->m_object;
2209 Py_INCREF(method->m_object);
2211 for (Py_ssize_t i = 0; i < 3; i++) {
2212 python_pars[i + 1] = args[i];
2215 result = function->m_c_code(tstate, function, python_pars);
2216 }
else if (function->m_args_simple &&
2217 3 + 1 + function->m_defaults_given == function->m_args_positional_count) {
2218 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2220 python_pars[0] = method->m_object;
2221 Py_INCREF(method->m_object);
2223 memcpy(python_pars + 1, args, 3 *
sizeof(PyObject *));
2224 memcpy(python_pars + 1 + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2225 function->m_defaults_given *
sizeof(PyObject *));
2227 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
2228 Py_INCREF(python_pars[i]);
2231 result = function->m_c_code(tstate, function, python_pars);
2233 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 3);
2236 Py_LeaveRecursiveCall();
2238 CHECK_OBJECT_X(result);
2242#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
2243 }
else if (PyCFunction_CheckExact(called)) {
2244#if PYTHON_VERSION >= 0x380
2245#ifdef _NUITKA_FULL_COMPAT
2246 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2251 int flags = PyCFunction_GET_FLAGS(called);
2255 if (!(flags & METH_VARARGS)) {
2256 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2258 assert(func != NULL);
2259 result = func(called, args, 3, NULL);
2261 CHECK_OBJECT_X(result);
2263 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2264 PyObject *self = PyCFunction_GET_SELF(called);
2266 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2268 if (flags & METH_KEYWORDS) {
2269 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
2271 result = (*method)(self, pos_args);
2274 Py_DECREF(pos_args);
2277#ifdef _NUITKA_FULL_COMPAT
2278 Py_LeaveRecursiveCall();
2280 CHECK_OBJECT_X(result);
2282 return Nuitka_CheckFunctionResult(tstate, called, result);
2285 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
2287 if (unlikely(flags & METH_NOARGS)) {
2288 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (3 given)",
2289 ((PyCFunctionObject *)called)->m_ml->ml_name);
2291 }
else if (unlikely(flags & METH_O)) {
2292 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (3 given)",
2293 ((PyCFunctionObject *)called)->m_ml->ml_name);
2295 }
else if (flags & METH_VARARGS) {
2298#ifdef _NUITKA_FULL_COMPAT
2299 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2303 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2304 PyObject *self = PyCFunction_GET_SELF(called);
2308#if PYTHON_VERSION < 0x360
2309 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2310 if (flags & METH_KEYWORDS) {
2311 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2313 result = (*method)(self, pos_args);
2316 Py_DECREF(pos_args);
2318 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
2319 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2320 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2321 Py_DECREF(pos_args);
2322 }
else if (flags == METH_FASTCALL) {
2323#if PYTHON_VERSION < 0x370
2324 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 3, NULL);
2326 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2327 result = (*(_PyCFunctionFast)method)(self, &pos_args, 3);
2328 Py_DECREF(pos_args);
2331 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2332 result = (*method)(self, pos_args);
2333 Py_DECREF(pos_args);
2337#ifdef _NUITKA_FULL_COMPAT
2338 Py_LeaveRecursiveCall();
2341 CHECK_OBJECT_X(result);
2343 return Nuitka_CheckFunctionResult(tstate, called, result);
2347#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
2348 }
else if (PyFunction_Check(called)) {
2349#if PYTHON_VERSION < 0x3b0
2350 PyObject *result = callPythonFunction(called, args, 3);
2352 PyObject *result = _PyFunction_Vectorcall(called, args, 3, NULL);
2354 CHECK_OBJECT_X(result);
2358#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
2359 }
else if (PyType_Check(called)) {
2360 PyTypeObject *type = Py_TYPE(called);
2362 if (type->tp_call == PyType_Type.tp_call) {
2363 PyTypeObject *called_type = (PyTypeObject *)(called);
2365 if (unlikely(called_type->tp_new == NULL)) {
2366 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
2370 PyObject *pos_args = NULL;
2373 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
2374 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
2375 formatCannotInstantiateAbstractClass(tstate, called_type);
2379 obj = called_type->tp_alloc(called_type, 0);
2382 pos_args = MAKE_TUPLE(tstate, args, 3);
2383 obj = called_type->tp_new(called_type, pos_args, NULL);
2386 if (likely(obj != NULL)) {
2387 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
2388 Py_DECREF(pos_args);
2393 type = Py_TYPE(obj);
2395 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
2396 if (type->tp_init == default_tp_init_wrapper) {
2397 Py_XDECREF(pos_args);
2400 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
2403 assert(init_method != NULL);
2405 bool is_compiled_function =
false;
2406 bool init_method_needs_release =
false;
2408 if (likely(init_method != NULL)) {
2409 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
2411 if (func == Nuitka_Function_Type.tp_descr_get) {
2412 is_compiled_function =
true;
2413 }
else if (func != NULL) {
2414 init_method = func(init_method, obj, (PyObject *)(type));
2415 init_method_needs_release =
true;
2419 if (unlikely(init_method == NULL)) {
2420 if (!HAS_ERROR_OCCURRED(tstate)) {
2421 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
2422 const_str_plain___init__);
2429 if (is_compiled_function) {
2430 result = Nuitka_CallMethodFunctionPosArgs(
2433 result = CALL_FUNCTION_WITH_ARGS3(tstate, init_method, args);
2434 if (init_method_needs_release) {
2435 Py_DECREF(init_method);
2439 if (unlikely(result == NULL)) {
2446 if (unlikely(result != Py_None)) {
2449 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2453 if (pos_args == NULL) {
2454 pos_args = MAKE_TUPLE(tstate, args, 3);
2457 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
2459 Py_XDECREF(pos_args);
2466 Py_XDECREF(pos_args);
2468 CHECK_OBJECT_X(obj);
2473#if PYTHON_VERSION < 0x300
2474 }
else if (PyClass_Check(called)) {
2475 PyObject *obj = PyInstance_NewRaw(called, NULL);
2477 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
2479 if (unlikely(init_method == NULL)) {
2480 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
2487 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
2491 bool is_compiled_function =
false;
2493 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
2495 if (descr_get == NULL) {
2496 Py_INCREF(init_method);
2497 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
2498 is_compiled_function =
true;
2499 }
else if (descr_get != NULL) {
2500 PyObject *descr_method = descr_get(init_method, obj, called);
2502 if (unlikely(descr_method == NULL)) {
2506 init_method = descr_method;
2510 if (is_compiled_function) {
2511 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
2514 result = CALL_FUNCTION_WITH_ARGS3(tstate, init_method, args);
2515 Py_DECREF(init_method);
2517 if (unlikely(result == NULL)) {
2523 if (unlikely(result != Py_None)) {
2524 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2528 CHECK_OBJECT_X(obj);
2532#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
2533 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
2534 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2536 if (likely(func != NULL)) {
2537 PyObject *result = func(called, args, 3, NULL);
2539 CHECK_OBJECT_X(result);
2541 return Nuitka_CheckFunctionResult(tstate, called, result);
2548 PRINT_STRING(
"FALLBACK");
2553 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2555 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
2557 Py_DECREF(pos_args);
2559 CHECK_OBJECT_X(result);
2563PyObject *CALL_FUNCTION_WITH_POS_ARGS3(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
2564 assert(PyTuple_CheckExact(pos_args));
2565 assert(PyTuple_GET_SIZE(pos_args) == 3);
2566 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
2567 CHECK_OBJECT(called);
2568 CHECK_OBJECTS(args, 3);
2570 if (Nuitka_Function_Check(called)) {
2571 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2578 if (function->m_args_simple && 3 == function->m_args_positional_count) {
2579 for (Py_ssize_t i = 0; i < 3; i++) {
2582 result = function->m_c_code(tstate, function, (PyObject **)args);
2583 }
else if (function->m_args_simple && 3 + function->m_defaults_given == function->m_args_positional_count) {
2584 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2586 memcpy(python_pars, args, 3 *
sizeof(PyObject *));
2587 memcpy(python_pars + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2588 function->m_defaults_given *
sizeof(PyObject *));
2590 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
2591 Py_INCREF(python_pars[i]);
2594 result = function->m_c_code(tstate, function, python_pars);
2596 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 3);
2599 Py_LeaveRecursiveCall();
2601 CHECK_OBJECT_X(result);
2604 }
else if (Nuitka_Method_Check(called)) {
2607 if (method->m_object == NULL) {
2608 PyObject *self = args[0];
2610 int res = PyObject_IsInstance(self, method->m_class);
2612 if (unlikely(res < 0)) {
2614 }
else if (unlikely(res == 0)) {
2615 PyErr_Format(PyExc_TypeError,
2616 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
2617 "instance instead)",
2618 GET_CALLABLE_NAME((PyObject *)method->m_function),
2619 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
2620 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
2625 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 3);
2627 CHECK_OBJECT_X(result);
2631 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2639 if (function->m_args_simple && 3 + 1 == function->m_args_positional_count) {
2640 PyObject *python_pars[3 + 1];
2642 python_pars[0] = method->m_object;
2643 Py_INCREF(method->m_object);
2645 for (Py_ssize_t i = 0; i < 3; i++) {
2646 python_pars[i + 1] = args[i];
2649 result = function->m_c_code(tstate, function, python_pars);
2650 }
else if (function->m_args_simple &&
2651 3 + 1 + function->m_defaults_given == function->m_args_positional_count) {
2652 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2654 python_pars[0] = method->m_object;
2655 Py_INCREF(method->m_object);
2657 memcpy(python_pars + 1, args, 3 *
sizeof(PyObject *));
2658 memcpy(python_pars + 1 + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2659 function->m_defaults_given *
sizeof(PyObject *));
2661 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
2662 Py_INCREF(python_pars[i]);
2665 result = function->m_c_code(tstate, function, python_pars);
2667 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 3);
2670 Py_LeaveRecursiveCall();
2672 CHECK_OBJECT_X(result);
2676#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
2677 }
else if (PyCFunction_CheckExact(called)) {
2678#if PYTHON_VERSION >= 0x380
2679#ifdef _NUITKA_FULL_COMPAT
2680 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2685 int flags = PyCFunction_GET_FLAGS(called);
2689 if (!(flags & METH_VARARGS)) {
2690 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2692 assert(func != NULL);
2693 result = func(called, args, 3, NULL);
2695 CHECK_OBJECT_X(result);
2697 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2698 PyObject *self = PyCFunction_GET_SELF(called);
2700 if (flags & METH_KEYWORDS) {
2701 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
2703 result = (*method)(self, pos_args);
2707#ifdef _NUITKA_FULL_COMPAT
2708 Py_LeaveRecursiveCall();
2710 CHECK_OBJECT_X(result);
2712 return Nuitka_CheckFunctionResult(tstate, called, result);
2715 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
2717 if (unlikely(flags & METH_NOARGS)) {
2718 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (3 given)",
2719 ((PyCFunctionObject *)called)->m_ml->ml_name);
2721 }
else if (unlikely(flags & METH_O)) {
2722 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (3 given)",
2723 ((PyCFunctionObject *)called)->m_ml->ml_name);
2725 }
else if (flags & METH_VARARGS) {
2728#ifdef _NUITKA_FULL_COMPAT
2729 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2733 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2734 PyObject *self = PyCFunction_GET_SELF(called);
2738#if PYTHON_VERSION < 0x360
2739 if (flags & METH_KEYWORDS) {
2740 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2742 result = (*method)(self, pos_args);
2746 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
2747 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2748 }
else if (flags == METH_FASTCALL) {
2749#if PYTHON_VERSION < 0x370
2750 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 3, NULL);
2752 result = (*(_PyCFunctionFast)method)(self, &pos_args, 3);
2755 result = (*method)(self, pos_args);
2759#ifdef _NUITKA_FULL_COMPAT
2760 Py_LeaveRecursiveCall();
2763 CHECK_OBJECT_X(result);
2765 return Nuitka_CheckFunctionResult(tstate, called, result);
2769#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
2770 }
else if (PyFunction_Check(called)) {
2771#if PYTHON_VERSION < 0x3b0
2772 PyObject *result = callPythonFunction(called, args, 3);
2774 PyObject *result = _PyFunction_Vectorcall(called, args, 3, NULL);
2776 CHECK_OBJECT_X(result);
2780#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
2781 }
else if (PyType_Check(called)) {
2782 PyTypeObject *type = Py_TYPE(called);
2784 if (type->tp_call == PyType_Type.tp_call) {
2785 PyTypeObject *called_type = (PyTypeObject *)(called);
2787 if (unlikely(called_type->tp_new == NULL)) {
2788 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
2794 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
2795 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
2796 formatCannotInstantiateAbstractClass(tstate, called_type);
2800 obj = called_type->tp_alloc(called_type, 0);
2803 obj = called_type->tp_new(called_type, pos_args, NULL);
2806 if (likely(obj != NULL)) {
2807 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
2812 type = Py_TYPE(obj);
2814 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
2815 if (type->tp_init == default_tp_init_wrapper) {
2817 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
2820 assert(init_method != NULL);
2822 bool is_compiled_function =
false;
2823 bool init_method_needs_release =
false;
2825 if (likely(init_method != NULL)) {
2826 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
2828 if (func == Nuitka_Function_Type.tp_descr_get) {
2829 is_compiled_function =
true;
2830 }
else if (func != NULL) {
2831 init_method = func(init_method, obj, (PyObject *)(type));
2832 init_method_needs_release =
true;
2836 if (unlikely(init_method == NULL)) {
2837 if (!HAS_ERROR_OCCURRED(tstate)) {
2838 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
2839 const_str_plain___init__);
2846 if (is_compiled_function) {
2847 result = Nuitka_CallMethodFunctionPosArgs(
2850 result = CALL_FUNCTION_WITH_POS_ARGS3(tstate, init_method, pos_args);
2851 if (init_method_needs_release) {
2852 Py_DECREF(init_method);
2856 if (unlikely(result == NULL)) {
2863 if (unlikely(result != Py_None)) {
2866 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2871 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
2879 CHECK_OBJECT_X(obj);
2884#if PYTHON_VERSION < 0x300
2885 }
else if (PyClass_Check(called)) {
2886 PyObject *obj = PyInstance_NewRaw(called, NULL);
2888 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
2890 if (unlikely(init_method == NULL)) {
2891 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
2898 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
2902 bool is_compiled_function =
false;
2904 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
2906 if (descr_get == NULL) {
2907 Py_INCREF(init_method);
2908 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
2909 is_compiled_function =
true;
2910 }
else if (descr_get != NULL) {
2911 PyObject *descr_method = descr_get(init_method, obj, called);
2913 if (unlikely(descr_method == NULL)) {
2917 init_method = descr_method;
2921 if (is_compiled_function) {
2922 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
2925 result = CALL_FUNCTION_WITH_POS_ARGS3(tstate, init_method, pos_args);
2926 Py_DECREF(init_method);
2928 if (unlikely(result == NULL)) {
2934 if (unlikely(result != Py_None)) {
2935 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2939 CHECK_OBJECT_X(obj);
2943#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
2944 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
2945 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2947 if (likely(func != NULL)) {
2948 PyObject *result = func(called, args, 3, NULL);
2950 CHECK_OBJECT_X(result);
2952 return Nuitka_CheckFunctionResult(tstate, called, result);
2959 PRINT_STRING(
"FALLBACK");
2964 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
2966 CHECK_OBJECT_X(result);
2970PyObject *CALL_FUNCTION_WITH_ARGS4(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
2971 CHECK_OBJECT(called);
2972 CHECK_OBJECTS(args, 4);
2974 if (Nuitka_Function_Check(called)) {
2975 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2982 if (function->m_args_simple && 4 == function->m_args_positional_count) {
2983 for (Py_ssize_t i = 0; i < 4; i++) {
2986 result = function->m_c_code(tstate, function, (PyObject **)args);
2987 }
else if (function->m_args_simple && 4 + function->m_defaults_given == function->m_args_positional_count) {
2988 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2990 memcpy(python_pars, args, 4 *
sizeof(PyObject *));
2991 memcpy(python_pars + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
2992 function->m_defaults_given *
sizeof(PyObject *));
2994 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
2995 Py_INCREF(python_pars[i]);
2998 result = function->m_c_code(tstate, function, python_pars);
3000 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 4);
3003 Py_LeaveRecursiveCall();
3005 CHECK_OBJECT_X(result);
3008 }
else if (Nuitka_Method_Check(called)) {
3011 if (method->m_object == NULL) {
3012 PyObject *self = args[0];
3014 int res = PyObject_IsInstance(self, method->m_class);
3016 if (unlikely(res < 0)) {
3018 }
else if (unlikely(res == 0)) {
3019 PyErr_Format(PyExc_TypeError,
3020 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
3021 "instance instead)",
3022 GET_CALLABLE_NAME((PyObject *)method->m_function),
3023 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
3024 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
3029 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 4);
3031 CHECK_OBJECT_X(result);
3035 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3043 if (function->m_args_simple && 4 + 1 == function->m_args_positional_count) {
3044 PyObject *python_pars[4 + 1];
3046 python_pars[0] = method->m_object;
3047 Py_INCREF(method->m_object);
3049 for (Py_ssize_t i = 0; i < 4; i++) {
3050 python_pars[i + 1] = args[i];
3053 result = function->m_c_code(tstate, function, python_pars);
3054 }
else if (function->m_args_simple &&
3055 4 + 1 + function->m_defaults_given == function->m_args_positional_count) {
3056 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3058 python_pars[0] = method->m_object;
3059 Py_INCREF(method->m_object);
3061 memcpy(python_pars + 1, args, 4 *
sizeof(PyObject *));
3062 memcpy(python_pars + 1 + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
3063 function->m_defaults_given *
sizeof(PyObject *));
3065 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
3066 Py_INCREF(python_pars[i]);
3069 result = function->m_c_code(tstate, function, python_pars);
3071 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 4);
3074 Py_LeaveRecursiveCall();
3076 CHECK_OBJECT_X(result);
3080#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
3081 }
else if (PyCFunction_CheckExact(called)) {
3082#if PYTHON_VERSION >= 0x380
3083#ifdef _NUITKA_FULL_COMPAT
3084 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3089 int flags = PyCFunction_GET_FLAGS(called);
3093 if (!(flags & METH_VARARGS)) {
3094 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3096 assert(func != NULL);
3097 result = func(called, args, 4, NULL);
3099 CHECK_OBJECT_X(result);
3101 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3102 PyObject *self = PyCFunction_GET_SELF(called);
3104 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3106 if (flags & METH_KEYWORDS) {
3107 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
3109 result = (*method)(self, pos_args);
3112 Py_DECREF(pos_args);
3115#ifdef _NUITKA_FULL_COMPAT
3116 Py_LeaveRecursiveCall();
3118 CHECK_OBJECT_X(result);
3120 return Nuitka_CheckFunctionResult(tstate, called, result);
3123 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
3125 if (unlikely(flags & METH_NOARGS)) {
3126 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (4 given)",
3127 ((PyCFunctionObject *)called)->m_ml->ml_name);
3129 }
else if (unlikely(flags & METH_O)) {
3130 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (4 given)",
3131 ((PyCFunctionObject *)called)->m_ml->ml_name);
3133 }
else if (flags & METH_VARARGS) {
3136#ifdef _NUITKA_FULL_COMPAT
3137 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3141 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3142 PyObject *self = PyCFunction_GET_SELF(called);
3146#if PYTHON_VERSION < 0x360
3147 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3148 if (flags & METH_KEYWORDS) {
3149 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3151 result = (*method)(self, pos_args);
3154 Py_DECREF(pos_args);
3156 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
3157 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3158 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3159 Py_DECREF(pos_args);
3160 }
else if (flags == METH_FASTCALL) {
3161#if PYTHON_VERSION < 0x370
3162 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 4, NULL);
3164 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3165 result = (*(_PyCFunctionFast)method)(self, &pos_args, 4);
3166 Py_DECREF(pos_args);
3169 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3170 result = (*method)(self, pos_args);
3171 Py_DECREF(pos_args);
3175#ifdef _NUITKA_FULL_COMPAT
3176 Py_LeaveRecursiveCall();
3179 CHECK_OBJECT_X(result);
3181 return Nuitka_CheckFunctionResult(tstate, called, result);
3185#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
3186 }
else if (PyFunction_Check(called)) {
3187#if PYTHON_VERSION < 0x3b0
3188 PyObject *result = callPythonFunction(called, args, 4);
3190 PyObject *result = _PyFunction_Vectorcall(called, args, 4, NULL);
3192 CHECK_OBJECT_X(result);
3196#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
3197 }
else if (PyType_Check(called)) {
3198 PyTypeObject *type = Py_TYPE(called);
3200 if (type->tp_call == PyType_Type.tp_call) {
3201 PyTypeObject *called_type = (PyTypeObject *)(called);
3203 if (unlikely(called_type->tp_new == NULL)) {
3204 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
3208 PyObject *pos_args = NULL;
3211 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
3212 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
3213 formatCannotInstantiateAbstractClass(tstate, called_type);
3217 obj = called_type->tp_alloc(called_type, 0);
3220 pos_args = MAKE_TUPLE(tstate, args, 4);
3221 obj = called_type->tp_new(called_type, pos_args, NULL);
3224 if (likely(obj != NULL)) {
3225 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
3226 Py_DECREF(pos_args);
3231 type = Py_TYPE(obj);
3233 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
3234 if (type->tp_init == default_tp_init_wrapper) {
3235 Py_XDECREF(pos_args);
3238 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
3241 assert(init_method != NULL);
3243 bool is_compiled_function =
false;
3244 bool init_method_needs_release =
false;
3246 if (likely(init_method != NULL)) {
3247 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
3249 if (func == Nuitka_Function_Type.tp_descr_get) {
3250 is_compiled_function =
true;
3251 }
else if (func != NULL) {
3252 init_method = func(init_method, obj, (PyObject *)(type));
3253 init_method_needs_release =
true;
3257 if (unlikely(init_method == NULL)) {
3258 if (!HAS_ERROR_OCCURRED(tstate)) {
3259 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
3260 const_str_plain___init__);
3267 if (is_compiled_function) {
3268 result = Nuitka_CallMethodFunctionPosArgs(
3271 result = CALL_FUNCTION_WITH_ARGS4(tstate, init_method, args);
3272 if (init_method_needs_release) {
3273 Py_DECREF(init_method);
3277 if (unlikely(result == NULL)) {
3284 if (unlikely(result != Py_None)) {
3287 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
3291 if (pos_args == NULL) {
3292 pos_args = MAKE_TUPLE(tstate, args, 4);
3295 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
3297 Py_XDECREF(pos_args);
3304 Py_XDECREF(pos_args);
3306 CHECK_OBJECT_X(obj);
3311#if PYTHON_VERSION < 0x300
3312 }
else if (PyClass_Check(called)) {
3313 PyObject *obj = PyInstance_NewRaw(called, NULL);
3315 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
3317 if (unlikely(init_method == NULL)) {
3318 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
3325 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
3329 bool is_compiled_function =
false;
3331 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
3333 if (descr_get == NULL) {
3334 Py_INCREF(init_method);
3335 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
3336 is_compiled_function =
true;
3337 }
else if (descr_get != NULL) {
3338 PyObject *descr_method = descr_get(init_method, obj, called);
3340 if (unlikely(descr_method == NULL)) {
3344 init_method = descr_method;
3348 if (is_compiled_function) {
3349 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
3352 result = CALL_FUNCTION_WITH_ARGS4(tstate, init_method, args);
3353 Py_DECREF(init_method);
3355 if (unlikely(result == NULL)) {
3361 if (unlikely(result != Py_None)) {
3362 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
3366 CHECK_OBJECT_X(obj);
3370#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
3371 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
3372 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3374 if (likely(func != NULL)) {
3375 PyObject *result = func(called, args, 4, NULL);
3377 CHECK_OBJECT_X(result);
3379 return Nuitka_CheckFunctionResult(tstate, called, result);
3386 PRINT_STRING(
"FALLBACK");
3391 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3393 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
3395 Py_DECREF(pos_args);
3397 CHECK_OBJECT_X(result);
3401PyObject *CALL_FUNCTION_WITH_POS_ARGS4(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
3402 assert(PyTuple_CheckExact(pos_args));
3403 assert(PyTuple_GET_SIZE(pos_args) == 4);
3404 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
3405 CHECK_OBJECT(called);
3406 CHECK_OBJECTS(args, 4);
3408 if (Nuitka_Function_Check(called)) {
3409 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3416 if (function->m_args_simple && 4 == function->m_args_positional_count) {
3417 for (Py_ssize_t i = 0; i < 4; i++) {
3420 result = function->m_c_code(tstate, function, (PyObject **)args);
3421 }
else if (function->m_args_simple && 4 + function->m_defaults_given == function->m_args_positional_count) {
3422 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3424 memcpy(python_pars, args, 4 *
sizeof(PyObject *));
3425 memcpy(python_pars + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
3426 function->m_defaults_given *
sizeof(PyObject *));
3428 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
3429 Py_INCREF(python_pars[i]);
3432 result = function->m_c_code(tstate, function, python_pars);
3434 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 4);
3437 Py_LeaveRecursiveCall();
3439 CHECK_OBJECT_X(result);
3442 }
else if (Nuitka_Method_Check(called)) {
3445 if (method->m_object == NULL) {
3446 PyObject *self = args[0];
3448 int res = PyObject_IsInstance(self, method->m_class);
3450 if (unlikely(res < 0)) {
3452 }
else if (unlikely(res == 0)) {
3453 PyErr_Format(PyExc_TypeError,
3454 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
3455 "instance instead)",
3456 GET_CALLABLE_NAME((PyObject *)method->m_function),
3457 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
3458 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
3463 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 4);
3465 CHECK_OBJECT_X(result);
3469 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3477 if (function->m_args_simple && 4 + 1 == function->m_args_positional_count) {
3478 PyObject *python_pars[4 + 1];
3480 python_pars[0] = method->m_object;
3481 Py_INCREF(method->m_object);
3483 for (Py_ssize_t i = 0; i < 4; i++) {
3484 python_pars[i + 1] = args[i];
3487 result = function->m_c_code(tstate, function, python_pars);
3488 }
else if (function->m_args_simple &&
3489 4 + 1 + function->m_defaults_given == function->m_args_positional_count) {
3490 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3492 python_pars[0] = method->m_object;
3493 Py_INCREF(method->m_object);
3495 memcpy(python_pars + 1, args, 4 *
sizeof(PyObject *));
3496 memcpy(python_pars + 1 + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
3497 function->m_defaults_given *
sizeof(PyObject *));
3499 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
3500 Py_INCREF(python_pars[i]);
3503 result = function->m_c_code(tstate, function, python_pars);
3505 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 4);
3508 Py_LeaveRecursiveCall();
3510 CHECK_OBJECT_X(result);
3514#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
3515 }
else if (PyCFunction_CheckExact(called)) {
3516#if PYTHON_VERSION >= 0x380
3517#ifdef _NUITKA_FULL_COMPAT
3518 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3523 int flags = PyCFunction_GET_FLAGS(called);
3527 if (!(flags & METH_VARARGS)) {
3528 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3530 assert(func != NULL);
3531 result = func(called, args, 4, NULL);
3533 CHECK_OBJECT_X(result);
3535 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3536 PyObject *self = PyCFunction_GET_SELF(called);
3538 if (flags & METH_KEYWORDS) {
3539 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
3541 result = (*method)(self, pos_args);
3545#ifdef _NUITKA_FULL_COMPAT
3546 Py_LeaveRecursiveCall();
3548 CHECK_OBJECT_X(result);
3550 return Nuitka_CheckFunctionResult(tstate, called, result);
3553 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
3555 if (unlikely(flags & METH_NOARGS)) {
3556 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (4 given)",
3557 ((PyCFunctionObject *)called)->m_ml->ml_name);
3559 }
else if (unlikely(flags & METH_O)) {
3560 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (4 given)",
3561 ((PyCFunctionObject *)called)->m_ml->ml_name);
3563 }
else if (flags & METH_VARARGS) {
3566#ifdef _NUITKA_FULL_COMPAT
3567 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3571 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3572 PyObject *self = PyCFunction_GET_SELF(called);
3576#if PYTHON_VERSION < 0x360
3577 if (flags & METH_KEYWORDS) {
3578 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3580 result = (*method)(self, pos_args);
3584 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
3585 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3586 }
else if (flags == METH_FASTCALL) {
3587#if PYTHON_VERSION < 0x370
3588 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 4, NULL);
3590 result = (*(_PyCFunctionFast)method)(self, &pos_args, 4);
3593 result = (*method)(self, pos_args);
3597#ifdef _NUITKA_FULL_COMPAT
3598 Py_LeaveRecursiveCall();
3601 CHECK_OBJECT_X(result);
3603 return Nuitka_CheckFunctionResult(tstate, called, result);
3607#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
3608 }
else if (PyFunction_Check(called)) {
3609#if PYTHON_VERSION < 0x3b0
3610 PyObject *result = callPythonFunction(called, args, 4);
3612 PyObject *result = _PyFunction_Vectorcall(called, args, 4, NULL);
3614 CHECK_OBJECT_X(result);
3618#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
3619 }
else if (PyType_Check(called)) {
3620 PyTypeObject *type = Py_TYPE(called);
3622 if (type->tp_call == PyType_Type.tp_call) {
3623 PyTypeObject *called_type = (PyTypeObject *)(called);
3625 if (unlikely(called_type->tp_new == NULL)) {
3626 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
3632 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
3633 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
3634 formatCannotInstantiateAbstractClass(tstate, called_type);
3638 obj = called_type->tp_alloc(called_type, 0);
3641 obj = called_type->tp_new(called_type, pos_args, NULL);
3644 if (likely(obj != NULL)) {
3645 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
3650 type = Py_TYPE(obj);
3652 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
3653 if (type->tp_init == default_tp_init_wrapper) {
3655 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
3658 assert(init_method != NULL);
3660 bool is_compiled_function =
false;
3661 bool init_method_needs_release =
false;
3663 if (likely(init_method != NULL)) {
3664 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
3666 if (func == Nuitka_Function_Type.tp_descr_get) {
3667 is_compiled_function =
true;
3668 }
else if (func != NULL) {
3669 init_method = func(init_method, obj, (PyObject *)(type));
3670 init_method_needs_release =
true;
3674 if (unlikely(init_method == NULL)) {
3675 if (!HAS_ERROR_OCCURRED(tstate)) {
3676 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
3677 const_str_plain___init__);
3684 if (is_compiled_function) {
3685 result = Nuitka_CallMethodFunctionPosArgs(
3688 result = CALL_FUNCTION_WITH_POS_ARGS4(tstate, init_method, pos_args);
3689 if (init_method_needs_release) {
3690 Py_DECREF(init_method);
3694 if (unlikely(result == NULL)) {
3701 if (unlikely(result != Py_None)) {
3704 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
3709 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
3717 CHECK_OBJECT_X(obj);
3722#if PYTHON_VERSION < 0x300
3723 }
else if (PyClass_Check(called)) {
3724 PyObject *obj = PyInstance_NewRaw(called, NULL);
3726 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
3728 if (unlikely(init_method == NULL)) {
3729 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
3736 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
3740 bool is_compiled_function =
false;
3742 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
3744 if (descr_get == NULL) {
3745 Py_INCREF(init_method);
3746 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
3747 is_compiled_function =
true;
3748 }
else if (descr_get != NULL) {
3749 PyObject *descr_method = descr_get(init_method, obj, called);
3751 if (unlikely(descr_method == NULL)) {
3755 init_method = descr_method;
3759 if (is_compiled_function) {
3760 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
3763 result = CALL_FUNCTION_WITH_POS_ARGS4(tstate, init_method, pos_args);
3764 Py_DECREF(init_method);
3766 if (unlikely(result == NULL)) {
3772 if (unlikely(result != Py_None)) {
3773 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
3777 CHECK_OBJECT_X(obj);
3781#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
3782 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
3783 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3785 if (likely(func != NULL)) {
3786 PyObject *result = func(called, args, 4, NULL);
3788 CHECK_OBJECT_X(result);
3790 return Nuitka_CheckFunctionResult(tstate, called, result);
3797 PRINT_STRING(
"FALLBACK");
3802 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
3804 CHECK_OBJECT_X(result);
3808PyObject *CALL_FUNCTION_WITH_ARGS5(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
3809 CHECK_OBJECT(called);
3810 CHECK_OBJECTS(args, 5);
3812 if (Nuitka_Function_Check(called)) {
3813 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3820 if (function->m_args_simple && 5 == function->m_args_positional_count) {
3821 for (Py_ssize_t i = 0; i < 5; i++) {
3824 result = function->m_c_code(tstate, function, (PyObject **)args);
3825 }
else if (function->m_args_simple && 5 + function->m_defaults_given == function->m_args_positional_count) {
3826 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3828 memcpy(python_pars, args, 5 *
sizeof(PyObject *));
3829 memcpy(python_pars + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
3830 function->m_defaults_given *
sizeof(PyObject *));
3832 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
3833 Py_INCREF(python_pars[i]);
3836 result = function->m_c_code(tstate, function, python_pars);
3838 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 5);
3841 Py_LeaveRecursiveCall();
3843 CHECK_OBJECT_X(result);
3846 }
else if (Nuitka_Method_Check(called)) {
3849 if (method->m_object == NULL) {
3850 PyObject *self = args[0];
3852 int res = PyObject_IsInstance(self, method->m_class);
3854 if (unlikely(res < 0)) {
3856 }
else if (unlikely(res == 0)) {
3857 PyErr_Format(PyExc_TypeError,
3858 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
3859 "instance instead)",
3860 GET_CALLABLE_NAME((PyObject *)method->m_function),
3861 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
3862 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
3867 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 5);
3869 CHECK_OBJECT_X(result);
3873 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3881 if (function->m_args_simple && 5 + 1 == function->m_args_positional_count) {
3882 PyObject *python_pars[5 + 1];
3884 python_pars[0] = method->m_object;
3885 Py_INCREF(method->m_object);
3887 for (Py_ssize_t i = 0; i < 5; i++) {
3888 python_pars[i + 1] = args[i];
3891 result = function->m_c_code(tstate, function, python_pars);
3892 }
else if (function->m_args_simple &&
3893 5 + 1 + function->m_defaults_given == function->m_args_positional_count) {
3894 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3896 python_pars[0] = method->m_object;
3897 Py_INCREF(method->m_object);
3899 memcpy(python_pars + 1, args, 5 *
sizeof(PyObject *));
3900 memcpy(python_pars + 1 + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
3901 function->m_defaults_given *
sizeof(PyObject *));
3903 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
3904 Py_INCREF(python_pars[i]);
3907 result = function->m_c_code(tstate, function, python_pars);
3909 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 5);
3912 Py_LeaveRecursiveCall();
3914 CHECK_OBJECT_X(result);
3918#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
3919 }
else if (PyCFunction_CheckExact(called)) {
3920#if PYTHON_VERSION >= 0x380
3921#ifdef _NUITKA_FULL_COMPAT
3922 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3927 int flags = PyCFunction_GET_FLAGS(called);
3931 if (!(flags & METH_VARARGS)) {
3932 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3934 assert(func != NULL);
3935 result = func(called, args, 5, NULL);
3937 CHECK_OBJECT_X(result);
3939 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3940 PyObject *self = PyCFunction_GET_SELF(called);
3942 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3944 if (flags & METH_KEYWORDS) {
3945 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
3947 result = (*method)(self, pos_args);
3950 Py_DECREF(pos_args);
3953#ifdef _NUITKA_FULL_COMPAT
3954 Py_LeaveRecursiveCall();
3956 CHECK_OBJECT_X(result);
3958 return Nuitka_CheckFunctionResult(tstate, called, result);
3961 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
3963 if (unlikely(flags & METH_NOARGS)) {
3964 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (5 given)",
3965 ((PyCFunctionObject *)called)->m_ml->ml_name);
3967 }
else if (unlikely(flags & METH_O)) {
3968 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (5 given)",
3969 ((PyCFunctionObject *)called)->m_ml->ml_name);
3971 }
else if (flags & METH_VARARGS) {
3974#ifdef _NUITKA_FULL_COMPAT
3975 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3979 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3980 PyObject *self = PyCFunction_GET_SELF(called);
3984#if PYTHON_VERSION < 0x360
3985 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3986 if (flags & METH_KEYWORDS) {
3987 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3989 result = (*method)(self, pos_args);
3992 Py_DECREF(pos_args);
3994 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
3995 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3996 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3997 Py_DECREF(pos_args);
3998 }
else if (flags == METH_FASTCALL) {
3999#if PYTHON_VERSION < 0x370
4000 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 5, NULL);
4002 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
4003 result = (*(_PyCFunctionFast)method)(self, &pos_args, 5);
4004 Py_DECREF(pos_args);
4007 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
4008 result = (*method)(self, pos_args);
4009 Py_DECREF(pos_args);
4013#ifdef _NUITKA_FULL_COMPAT
4014 Py_LeaveRecursiveCall();
4017 CHECK_OBJECT_X(result);
4019 return Nuitka_CheckFunctionResult(tstate, called, result);
4023#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
4024 }
else if (PyFunction_Check(called)) {
4025#if PYTHON_VERSION < 0x3b0
4026 PyObject *result = callPythonFunction(called, args, 5);
4028 PyObject *result = _PyFunction_Vectorcall(called, args, 5, NULL);
4030 CHECK_OBJECT_X(result);
4034#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
4035 }
else if (PyType_Check(called)) {
4036 PyTypeObject *type = Py_TYPE(called);
4038 if (type->tp_call == PyType_Type.tp_call) {
4039 PyTypeObject *called_type = (PyTypeObject *)(called);
4041 if (unlikely(called_type->tp_new == NULL)) {
4042 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
4046 PyObject *pos_args = NULL;
4049 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
4050 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
4051 formatCannotInstantiateAbstractClass(tstate, called_type);
4055 obj = called_type->tp_alloc(called_type, 0);
4058 pos_args = MAKE_TUPLE(tstate, args, 5);
4059 obj = called_type->tp_new(called_type, pos_args, NULL);
4062 if (likely(obj != NULL)) {
4063 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
4064 Py_DECREF(pos_args);
4069 type = Py_TYPE(obj);
4071 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
4072 if (type->tp_init == default_tp_init_wrapper) {
4073 Py_XDECREF(pos_args);
4076 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
4079 assert(init_method != NULL);
4081 bool is_compiled_function =
false;
4082 bool init_method_needs_release =
false;
4084 if (likely(init_method != NULL)) {
4085 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
4087 if (func == Nuitka_Function_Type.tp_descr_get) {
4088 is_compiled_function =
true;
4089 }
else if (func != NULL) {
4090 init_method = func(init_method, obj, (PyObject *)(type));
4091 init_method_needs_release =
true;
4095 if (unlikely(init_method == NULL)) {
4096 if (!HAS_ERROR_OCCURRED(tstate)) {
4097 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
4098 const_str_plain___init__);
4105 if (is_compiled_function) {
4106 result = Nuitka_CallMethodFunctionPosArgs(
4109 result = CALL_FUNCTION_WITH_ARGS5(tstate, init_method, args);
4110 if (init_method_needs_release) {
4111 Py_DECREF(init_method);
4115 if (unlikely(result == NULL)) {
4122 if (unlikely(result != Py_None)) {
4125 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4129 if (pos_args == NULL) {
4130 pos_args = MAKE_TUPLE(tstate, args, 5);
4133 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
4135 Py_XDECREF(pos_args);
4142 Py_XDECREF(pos_args);
4144 CHECK_OBJECT_X(obj);
4149#if PYTHON_VERSION < 0x300
4150 }
else if (PyClass_Check(called)) {
4151 PyObject *obj = PyInstance_NewRaw(called, NULL);
4153 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
4155 if (unlikely(init_method == NULL)) {
4156 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
4163 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
4167 bool is_compiled_function =
false;
4169 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
4171 if (descr_get == NULL) {
4172 Py_INCREF(init_method);
4173 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
4174 is_compiled_function =
true;
4175 }
else if (descr_get != NULL) {
4176 PyObject *descr_method = descr_get(init_method, obj, called);
4178 if (unlikely(descr_method == NULL)) {
4182 init_method = descr_method;
4186 if (is_compiled_function) {
4187 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
4190 result = CALL_FUNCTION_WITH_ARGS5(tstate, init_method, args);
4191 Py_DECREF(init_method);
4193 if (unlikely(result == NULL)) {
4199 if (unlikely(result != Py_None)) {
4200 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4204 CHECK_OBJECT_X(obj);
4208#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
4209 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
4210 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4212 if (likely(func != NULL)) {
4213 PyObject *result = func(called, args, 5, NULL);
4215 CHECK_OBJECT_X(result);
4217 return Nuitka_CheckFunctionResult(tstate, called, result);
4224 PRINT_STRING(
"FALLBACK");
4229 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
4231 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
4233 Py_DECREF(pos_args);
4235 CHECK_OBJECT_X(result);
4239PyObject *CALL_FUNCTION_WITH_POS_ARGS5(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
4240 assert(PyTuple_CheckExact(pos_args));
4241 assert(PyTuple_GET_SIZE(pos_args) == 5);
4242 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
4243 CHECK_OBJECT(called);
4244 CHECK_OBJECTS(args, 5);
4246 if (Nuitka_Function_Check(called)) {
4247 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4254 if (function->m_args_simple && 5 == function->m_args_positional_count) {
4255 for (Py_ssize_t i = 0; i < 5; i++) {
4258 result = function->m_c_code(tstate, function, (PyObject **)args);
4259 }
else if (function->m_args_simple && 5 + function->m_defaults_given == function->m_args_positional_count) {
4260 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4262 memcpy(python_pars, args, 5 *
sizeof(PyObject *));
4263 memcpy(python_pars + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
4264 function->m_defaults_given *
sizeof(PyObject *));
4266 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
4267 Py_INCREF(python_pars[i]);
4270 result = function->m_c_code(tstate, function, python_pars);
4272 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 5);
4275 Py_LeaveRecursiveCall();
4277 CHECK_OBJECT_X(result);
4280 }
else if (Nuitka_Method_Check(called)) {
4283 if (method->m_object == NULL) {
4284 PyObject *self = args[0];
4286 int res = PyObject_IsInstance(self, method->m_class);
4288 if (unlikely(res < 0)) {
4290 }
else if (unlikely(res == 0)) {
4291 PyErr_Format(PyExc_TypeError,
4292 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
4293 "instance instead)",
4294 GET_CALLABLE_NAME((PyObject *)method->m_function),
4295 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
4296 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
4301 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 5);
4303 CHECK_OBJECT_X(result);
4307 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4315 if (function->m_args_simple && 5 + 1 == function->m_args_positional_count) {
4316 PyObject *python_pars[5 + 1];
4318 python_pars[0] = method->m_object;
4319 Py_INCREF(method->m_object);
4321 for (Py_ssize_t i = 0; i < 5; i++) {
4322 python_pars[i + 1] = args[i];
4325 result = function->m_c_code(tstate, function, python_pars);
4326 }
else if (function->m_args_simple &&
4327 5 + 1 + function->m_defaults_given == function->m_args_positional_count) {
4328 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4330 python_pars[0] = method->m_object;
4331 Py_INCREF(method->m_object);
4333 memcpy(python_pars + 1, args, 5 *
sizeof(PyObject *));
4334 memcpy(python_pars + 1 + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
4335 function->m_defaults_given *
sizeof(PyObject *));
4337 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
4338 Py_INCREF(python_pars[i]);
4341 result = function->m_c_code(tstate, function, python_pars);
4343 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 5);
4346 Py_LeaveRecursiveCall();
4348 CHECK_OBJECT_X(result);
4352#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
4353 }
else if (PyCFunction_CheckExact(called)) {
4354#if PYTHON_VERSION >= 0x380
4355#ifdef _NUITKA_FULL_COMPAT
4356 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4361 int flags = PyCFunction_GET_FLAGS(called);
4365 if (!(flags & METH_VARARGS)) {
4366 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4368 assert(func != NULL);
4369 result = func(called, args, 5, NULL);
4371 CHECK_OBJECT_X(result);
4373 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4374 PyObject *self = PyCFunction_GET_SELF(called);
4376 if (flags & METH_KEYWORDS) {
4377 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
4379 result = (*method)(self, pos_args);
4383#ifdef _NUITKA_FULL_COMPAT
4384 Py_LeaveRecursiveCall();
4386 CHECK_OBJECT_X(result);
4388 return Nuitka_CheckFunctionResult(tstate, called, result);
4391 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
4393 if (unlikely(flags & METH_NOARGS)) {
4394 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (5 given)",
4395 ((PyCFunctionObject *)called)->m_ml->ml_name);
4397 }
else if (unlikely(flags & METH_O)) {
4398 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (5 given)",
4399 ((PyCFunctionObject *)called)->m_ml->ml_name);
4401 }
else if (flags & METH_VARARGS) {
4404#ifdef _NUITKA_FULL_COMPAT
4405 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4409 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4410 PyObject *self = PyCFunction_GET_SELF(called);
4414#if PYTHON_VERSION < 0x360
4415 if (flags & METH_KEYWORDS) {
4416 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4418 result = (*method)(self, pos_args);
4422 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
4423 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4424 }
else if (flags == METH_FASTCALL) {
4425#if PYTHON_VERSION < 0x370
4426 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 5, NULL);
4428 result = (*(_PyCFunctionFast)method)(self, &pos_args, 5);
4431 result = (*method)(self, pos_args);
4435#ifdef _NUITKA_FULL_COMPAT
4436 Py_LeaveRecursiveCall();
4439 CHECK_OBJECT_X(result);
4441 return Nuitka_CheckFunctionResult(tstate, called, result);
4445#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
4446 }
else if (PyFunction_Check(called)) {
4447#if PYTHON_VERSION < 0x3b0
4448 PyObject *result = callPythonFunction(called, args, 5);
4450 PyObject *result = _PyFunction_Vectorcall(called, args, 5, NULL);
4452 CHECK_OBJECT_X(result);
4456#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
4457 }
else if (PyType_Check(called)) {
4458 PyTypeObject *type = Py_TYPE(called);
4460 if (type->tp_call == PyType_Type.tp_call) {
4461 PyTypeObject *called_type = (PyTypeObject *)(called);
4463 if (unlikely(called_type->tp_new == NULL)) {
4464 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
4470 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
4471 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
4472 formatCannotInstantiateAbstractClass(tstate, called_type);
4476 obj = called_type->tp_alloc(called_type, 0);
4479 obj = called_type->tp_new(called_type, pos_args, NULL);
4482 if (likely(obj != NULL)) {
4483 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
4488 type = Py_TYPE(obj);
4490 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
4491 if (type->tp_init == default_tp_init_wrapper) {
4493 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
4496 assert(init_method != NULL);
4498 bool is_compiled_function =
false;
4499 bool init_method_needs_release =
false;
4501 if (likely(init_method != NULL)) {
4502 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
4504 if (func == Nuitka_Function_Type.tp_descr_get) {
4505 is_compiled_function =
true;
4506 }
else if (func != NULL) {
4507 init_method = func(init_method, obj, (PyObject *)(type));
4508 init_method_needs_release =
true;
4512 if (unlikely(init_method == NULL)) {
4513 if (!HAS_ERROR_OCCURRED(tstate)) {
4514 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
4515 const_str_plain___init__);
4522 if (is_compiled_function) {
4523 result = Nuitka_CallMethodFunctionPosArgs(
4526 result = CALL_FUNCTION_WITH_POS_ARGS5(tstate, init_method, pos_args);
4527 if (init_method_needs_release) {
4528 Py_DECREF(init_method);
4532 if (unlikely(result == NULL)) {
4539 if (unlikely(result != Py_None)) {
4542 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4547 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
4555 CHECK_OBJECT_X(obj);
4560#if PYTHON_VERSION < 0x300
4561 }
else if (PyClass_Check(called)) {
4562 PyObject *obj = PyInstance_NewRaw(called, NULL);
4564 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
4566 if (unlikely(init_method == NULL)) {
4567 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
4574 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
4578 bool is_compiled_function =
false;
4580 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
4582 if (descr_get == NULL) {
4583 Py_INCREF(init_method);
4584 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
4585 is_compiled_function =
true;
4586 }
else if (descr_get != NULL) {
4587 PyObject *descr_method = descr_get(init_method, obj, called);
4589 if (unlikely(descr_method == NULL)) {
4593 init_method = descr_method;
4597 if (is_compiled_function) {
4598 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
4601 result = CALL_FUNCTION_WITH_POS_ARGS5(tstate, init_method, pos_args);
4602 Py_DECREF(init_method);
4604 if (unlikely(result == NULL)) {
4610 if (unlikely(result != Py_None)) {
4611 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4615 CHECK_OBJECT_X(obj);
4619#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
4620 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
4621 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4623 if (likely(func != NULL)) {
4624 PyObject *result = func(called, args, 5, NULL);
4626 CHECK_OBJECT_X(result);
4628 return Nuitka_CheckFunctionResult(tstate, called, result);
4635 PRINT_STRING(
"FALLBACK");
4640 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
4642 CHECK_OBJECT_X(result);
4646PyObject *CALL_FUNCTION_WITH_ARGS6(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
4647 CHECK_OBJECT(called);
4648 CHECK_OBJECTS(args, 6);
4650 if (Nuitka_Function_Check(called)) {
4651 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4658 if (function->m_args_simple && 6 == function->m_args_positional_count) {
4659 for (Py_ssize_t i = 0; i < 6; i++) {
4662 result = function->m_c_code(tstate, function, (PyObject **)args);
4663 }
else if (function->m_args_simple && 6 + function->m_defaults_given == function->m_args_positional_count) {
4664 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4666 memcpy(python_pars, args, 6 *
sizeof(PyObject *));
4667 memcpy(python_pars + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
4668 function->m_defaults_given *
sizeof(PyObject *));
4670 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
4671 Py_INCREF(python_pars[i]);
4674 result = function->m_c_code(tstate, function, python_pars);
4676 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 6);
4679 Py_LeaveRecursiveCall();
4681 CHECK_OBJECT_X(result);
4684 }
else if (Nuitka_Method_Check(called)) {
4687 if (method->m_object == NULL) {
4688 PyObject *self = args[0];
4690 int res = PyObject_IsInstance(self, method->m_class);
4692 if (unlikely(res < 0)) {
4694 }
else if (unlikely(res == 0)) {
4695 PyErr_Format(PyExc_TypeError,
4696 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
4697 "instance instead)",
4698 GET_CALLABLE_NAME((PyObject *)method->m_function),
4699 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
4700 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
4705 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 6);
4707 CHECK_OBJECT_X(result);
4711 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4719 if (function->m_args_simple && 6 + 1 == function->m_args_positional_count) {
4720 PyObject *python_pars[6 + 1];
4722 python_pars[0] = method->m_object;
4723 Py_INCREF(method->m_object);
4725 for (Py_ssize_t i = 0; i < 6; i++) {
4726 python_pars[i + 1] = args[i];
4729 result = function->m_c_code(tstate, function, python_pars);
4730 }
else if (function->m_args_simple &&
4731 6 + 1 + function->m_defaults_given == function->m_args_positional_count) {
4732 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4734 python_pars[0] = method->m_object;
4735 Py_INCREF(method->m_object);
4737 memcpy(python_pars + 1, args, 6 *
sizeof(PyObject *));
4738 memcpy(python_pars + 1 + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
4739 function->m_defaults_given *
sizeof(PyObject *));
4741 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
4742 Py_INCREF(python_pars[i]);
4745 result = function->m_c_code(tstate, function, python_pars);
4747 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 6);
4750 Py_LeaveRecursiveCall();
4752 CHECK_OBJECT_X(result);
4756#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
4757 }
else if (PyCFunction_CheckExact(called)) {
4758#if PYTHON_VERSION >= 0x380
4759#ifdef _NUITKA_FULL_COMPAT
4760 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4765 int flags = PyCFunction_GET_FLAGS(called);
4769 if (!(flags & METH_VARARGS)) {
4770 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4772 assert(func != NULL);
4773 result = func(called, args, 6, NULL);
4775 CHECK_OBJECT_X(result);
4777 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4778 PyObject *self = PyCFunction_GET_SELF(called);
4780 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4782 if (flags & METH_KEYWORDS) {
4783 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
4785 result = (*method)(self, pos_args);
4788 Py_DECREF(pos_args);
4791#ifdef _NUITKA_FULL_COMPAT
4792 Py_LeaveRecursiveCall();
4794 CHECK_OBJECT_X(result);
4796 return Nuitka_CheckFunctionResult(tstate, called, result);
4799 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
4801 if (unlikely(flags & METH_NOARGS)) {
4802 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (6 given)",
4803 ((PyCFunctionObject *)called)->m_ml->ml_name);
4805 }
else if (unlikely(flags & METH_O)) {
4806 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (6 given)",
4807 ((PyCFunctionObject *)called)->m_ml->ml_name);
4809 }
else if (flags & METH_VARARGS) {
4812#ifdef _NUITKA_FULL_COMPAT
4813 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4817 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4818 PyObject *self = PyCFunction_GET_SELF(called);
4822#if PYTHON_VERSION < 0x360
4823 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4824 if (flags & METH_KEYWORDS) {
4825 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4827 result = (*method)(self, pos_args);
4830 Py_DECREF(pos_args);
4832 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
4833 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4834 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4835 Py_DECREF(pos_args);
4836 }
else if (flags == METH_FASTCALL) {
4837#if PYTHON_VERSION < 0x370
4838 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 6, NULL);
4840 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4841 result = (*(_PyCFunctionFast)method)(self, &pos_args, 6);
4842 Py_DECREF(pos_args);
4845 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4846 result = (*method)(self, pos_args);
4847 Py_DECREF(pos_args);
4851#ifdef _NUITKA_FULL_COMPAT
4852 Py_LeaveRecursiveCall();
4855 CHECK_OBJECT_X(result);
4857 return Nuitka_CheckFunctionResult(tstate, called, result);
4861#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
4862 }
else if (PyFunction_Check(called)) {
4863#if PYTHON_VERSION < 0x3b0
4864 PyObject *result = callPythonFunction(called, args, 6);
4866 PyObject *result = _PyFunction_Vectorcall(called, args, 6, NULL);
4868 CHECK_OBJECT_X(result);
4872#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
4873 }
else if (PyType_Check(called)) {
4874 PyTypeObject *type = Py_TYPE(called);
4876 if (type->tp_call == PyType_Type.tp_call) {
4877 PyTypeObject *called_type = (PyTypeObject *)(called);
4879 if (unlikely(called_type->tp_new == NULL)) {
4880 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
4884 PyObject *pos_args = NULL;
4887 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
4888 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
4889 formatCannotInstantiateAbstractClass(tstate, called_type);
4893 obj = called_type->tp_alloc(called_type, 0);
4896 pos_args = MAKE_TUPLE(tstate, args, 6);
4897 obj = called_type->tp_new(called_type, pos_args, NULL);
4900 if (likely(obj != NULL)) {
4901 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
4902 Py_DECREF(pos_args);
4907 type = Py_TYPE(obj);
4909 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
4910 if (type->tp_init == default_tp_init_wrapper) {
4911 Py_XDECREF(pos_args);
4914 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
4917 assert(init_method != NULL);
4919 bool is_compiled_function =
false;
4920 bool init_method_needs_release =
false;
4922 if (likely(init_method != NULL)) {
4923 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
4925 if (func == Nuitka_Function_Type.tp_descr_get) {
4926 is_compiled_function =
true;
4927 }
else if (func != NULL) {
4928 init_method = func(init_method, obj, (PyObject *)(type));
4929 init_method_needs_release =
true;
4933 if (unlikely(init_method == NULL)) {
4934 if (!HAS_ERROR_OCCURRED(tstate)) {
4935 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
4936 const_str_plain___init__);
4943 if (is_compiled_function) {
4944 result = Nuitka_CallMethodFunctionPosArgs(
4947 result = CALL_FUNCTION_WITH_ARGS6(tstate, init_method, args);
4948 if (init_method_needs_release) {
4949 Py_DECREF(init_method);
4953 if (unlikely(result == NULL)) {
4960 if (unlikely(result != Py_None)) {
4963 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4967 if (pos_args == NULL) {
4968 pos_args = MAKE_TUPLE(tstate, args, 6);
4971 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
4973 Py_XDECREF(pos_args);
4980 Py_XDECREF(pos_args);
4982 CHECK_OBJECT_X(obj);
4987#if PYTHON_VERSION < 0x300
4988 }
else if (PyClass_Check(called)) {
4989 PyObject *obj = PyInstance_NewRaw(called, NULL);
4991 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
4993 if (unlikely(init_method == NULL)) {
4994 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
5001 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
5005 bool is_compiled_function =
false;
5007 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
5009 if (descr_get == NULL) {
5010 Py_INCREF(init_method);
5011 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
5012 is_compiled_function =
true;
5013 }
else if (descr_get != NULL) {
5014 PyObject *descr_method = descr_get(init_method, obj, called);
5016 if (unlikely(descr_method == NULL)) {
5020 init_method = descr_method;
5024 if (is_compiled_function) {
5025 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
5028 result = CALL_FUNCTION_WITH_ARGS6(tstate, init_method, args);
5029 Py_DECREF(init_method);
5031 if (unlikely(result == NULL)) {
5037 if (unlikely(result != Py_None)) {
5038 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5042 CHECK_OBJECT_X(obj);
5046#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
5047 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
5048 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5050 if (likely(func != NULL)) {
5051 PyObject *result = func(called, args, 6, NULL);
5053 CHECK_OBJECT_X(result);
5055 return Nuitka_CheckFunctionResult(tstate, called, result);
5062 PRINT_STRING(
"FALLBACK");
5067 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
5069 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
5071 Py_DECREF(pos_args);
5073 CHECK_OBJECT_X(result);
5077PyObject *CALL_FUNCTION_WITH_POS_ARGS6(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
5078 assert(PyTuple_CheckExact(pos_args));
5079 assert(PyTuple_GET_SIZE(pos_args) == 6);
5080 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
5081 CHECK_OBJECT(called);
5082 CHECK_OBJECTS(args, 6);
5084 if (Nuitka_Function_Check(called)) {
5085 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5092 if (function->m_args_simple && 6 == function->m_args_positional_count) {
5093 for (Py_ssize_t i = 0; i < 6; i++) {
5096 result = function->m_c_code(tstate, function, (PyObject **)args);
5097 }
else if (function->m_args_simple && 6 + function->m_defaults_given == function->m_args_positional_count) {
5098 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5100 memcpy(python_pars, args, 6 *
sizeof(PyObject *));
5101 memcpy(python_pars + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
5102 function->m_defaults_given *
sizeof(PyObject *));
5104 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
5105 Py_INCREF(python_pars[i]);
5108 result = function->m_c_code(tstate, function, python_pars);
5110 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 6);
5113 Py_LeaveRecursiveCall();
5115 CHECK_OBJECT_X(result);
5118 }
else if (Nuitka_Method_Check(called)) {
5121 if (method->m_object == NULL) {
5122 PyObject *self = args[0];
5124 int res = PyObject_IsInstance(self, method->m_class);
5126 if (unlikely(res < 0)) {
5128 }
else if (unlikely(res == 0)) {
5129 PyErr_Format(PyExc_TypeError,
5130 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
5131 "instance instead)",
5132 GET_CALLABLE_NAME((PyObject *)method->m_function),
5133 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
5134 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
5139 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 6);
5141 CHECK_OBJECT_X(result);
5145 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5153 if (function->m_args_simple && 6 + 1 == function->m_args_positional_count) {
5154 PyObject *python_pars[6 + 1];
5156 python_pars[0] = method->m_object;
5157 Py_INCREF(method->m_object);
5159 for (Py_ssize_t i = 0; i < 6; i++) {
5160 python_pars[i + 1] = args[i];
5163 result = function->m_c_code(tstate, function, python_pars);
5164 }
else if (function->m_args_simple &&
5165 6 + 1 + function->m_defaults_given == function->m_args_positional_count) {
5166 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5168 python_pars[0] = method->m_object;
5169 Py_INCREF(method->m_object);
5171 memcpy(python_pars + 1, args, 6 *
sizeof(PyObject *));
5172 memcpy(python_pars + 1 + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
5173 function->m_defaults_given *
sizeof(PyObject *));
5175 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
5176 Py_INCREF(python_pars[i]);
5179 result = function->m_c_code(tstate, function, python_pars);
5181 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 6);
5184 Py_LeaveRecursiveCall();
5186 CHECK_OBJECT_X(result);
5190#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
5191 }
else if (PyCFunction_CheckExact(called)) {
5192#if PYTHON_VERSION >= 0x380
5193#ifdef _NUITKA_FULL_COMPAT
5194 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5199 int flags = PyCFunction_GET_FLAGS(called);
5203 if (!(flags & METH_VARARGS)) {
5204 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5206 assert(func != NULL);
5207 result = func(called, args, 6, NULL);
5209 CHECK_OBJECT_X(result);
5211 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5212 PyObject *self = PyCFunction_GET_SELF(called);
5214 if (flags & METH_KEYWORDS) {
5215 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
5217 result = (*method)(self, pos_args);
5221#ifdef _NUITKA_FULL_COMPAT
5222 Py_LeaveRecursiveCall();
5224 CHECK_OBJECT_X(result);
5226 return Nuitka_CheckFunctionResult(tstate, called, result);
5229 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
5231 if (unlikely(flags & METH_NOARGS)) {
5232 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (6 given)",
5233 ((PyCFunctionObject *)called)->m_ml->ml_name);
5235 }
else if (unlikely(flags & METH_O)) {
5236 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (6 given)",
5237 ((PyCFunctionObject *)called)->m_ml->ml_name);
5239 }
else if (flags & METH_VARARGS) {
5242#ifdef _NUITKA_FULL_COMPAT
5243 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5247 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5248 PyObject *self = PyCFunction_GET_SELF(called);
5252#if PYTHON_VERSION < 0x360
5253 if (flags & METH_KEYWORDS) {
5254 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5256 result = (*method)(self, pos_args);
5260 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
5261 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5262 }
else if (flags == METH_FASTCALL) {
5263#if PYTHON_VERSION < 0x370
5264 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 6, NULL);
5266 result = (*(_PyCFunctionFast)method)(self, &pos_args, 6);
5269 result = (*method)(self, pos_args);
5273#ifdef _NUITKA_FULL_COMPAT
5274 Py_LeaveRecursiveCall();
5277 CHECK_OBJECT_X(result);
5279 return Nuitka_CheckFunctionResult(tstate, called, result);
5283#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
5284 }
else if (PyFunction_Check(called)) {
5285#if PYTHON_VERSION < 0x3b0
5286 PyObject *result = callPythonFunction(called, args, 6);
5288 PyObject *result = _PyFunction_Vectorcall(called, args, 6, NULL);
5290 CHECK_OBJECT_X(result);
5294#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
5295 }
else if (PyType_Check(called)) {
5296 PyTypeObject *type = Py_TYPE(called);
5298 if (type->tp_call == PyType_Type.tp_call) {
5299 PyTypeObject *called_type = (PyTypeObject *)(called);
5301 if (unlikely(called_type->tp_new == NULL)) {
5302 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
5308 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
5309 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
5310 formatCannotInstantiateAbstractClass(tstate, called_type);
5314 obj = called_type->tp_alloc(called_type, 0);
5317 obj = called_type->tp_new(called_type, pos_args, NULL);
5320 if (likely(obj != NULL)) {
5321 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
5326 type = Py_TYPE(obj);
5328 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
5329 if (type->tp_init == default_tp_init_wrapper) {
5331 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
5334 assert(init_method != NULL);
5336 bool is_compiled_function =
false;
5337 bool init_method_needs_release =
false;
5339 if (likely(init_method != NULL)) {
5340 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
5342 if (func == Nuitka_Function_Type.tp_descr_get) {
5343 is_compiled_function =
true;
5344 }
else if (func != NULL) {
5345 init_method = func(init_method, obj, (PyObject *)(type));
5346 init_method_needs_release =
true;
5350 if (unlikely(init_method == NULL)) {
5351 if (!HAS_ERROR_OCCURRED(tstate)) {
5352 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
5353 const_str_plain___init__);
5360 if (is_compiled_function) {
5361 result = Nuitka_CallMethodFunctionPosArgs(
5364 result = CALL_FUNCTION_WITH_POS_ARGS6(tstate, init_method, pos_args);
5365 if (init_method_needs_release) {
5366 Py_DECREF(init_method);
5370 if (unlikely(result == NULL)) {
5377 if (unlikely(result != Py_None)) {
5380 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5385 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
5393 CHECK_OBJECT_X(obj);
5398#if PYTHON_VERSION < 0x300
5399 }
else if (PyClass_Check(called)) {
5400 PyObject *obj = PyInstance_NewRaw(called, NULL);
5402 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
5404 if (unlikely(init_method == NULL)) {
5405 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
5412 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
5416 bool is_compiled_function =
false;
5418 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
5420 if (descr_get == NULL) {
5421 Py_INCREF(init_method);
5422 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
5423 is_compiled_function =
true;
5424 }
else if (descr_get != NULL) {
5425 PyObject *descr_method = descr_get(init_method, obj, called);
5427 if (unlikely(descr_method == NULL)) {
5431 init_method = descr_method;
5435 if (is_compiled_function) {
5436 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
5439 result = CALL_FUNCTION_WITH_POS_ARGS6(tstate, init_method, pos_args);
5440 Py_DECREF(init_method);
5442 if (unlikely(result == NULL)) {
5448 if (unlikely(result != Py_None)) {
5449 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5453 CHECK_OBJECT_X(obj);
5457#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
5458 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
5459 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5461 if (likely(func != NULL)) {
5462 PyObject *result = func(called, args, 6, NULL);
5464 CHECK_OBJECT_X(result);
5466 return Nuitka_CheckFunctionResult(tstate, called, result);
5473 PRINT_STRING(
"FALLBACK");
5478 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
5480 CHECK_OBJECT_X(result);
5484PyObject *CALL_FUNCTION_WITH_ARGS7(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
5485 CHECK_OBJECT(called);
5486 CHECK_OBJECTS(args, 7);
5488 if (Nuitka_Function_Check(called)) {
5489 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5496 if (function->m_args_simple && 7 == function->m_args_positional_count) {
5497 for (Py_ssize_t i = 0; i < 7; i++) {
5500 result = function->m_c_code(tstate, function, (PyObject **)args);
5501 }
else if (function->m_args_simple && 7 + function->m_defaults_given == function->m_args_positional_count) {
5502 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5504 memcpy(python_pars, args, 7 *
sizeof(PyObject *));
5505 memcpy(python_pars + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
5506 function->m_defaults_given *
sizeof(PyObject *));
5508 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
5509 Py_INCREF(python_pars[i]);
5512 result = function->m_c_code(tstate, function, python_pars);
5514 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 7);
5517 Py_LeaveRecursiveCall();
5519 CHECK_OBJECT_X(result);
5522 }
else if (Nuitka_Method_Check(called)) {
5525 if (method->m_object == NULL) {
5526 PyObject *self = args[0];
5528 int res = PyObject_IsInstance(self, method->m_class);
5530 if (unlikely(res < 0)) {
5532 }
else if (unlikely(res == 0)) {
5533 PyErr_Format(PyExc_TypeError,
5534 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
5535 "instance instead)",
5536 GET_CALLABLE_NAME((PyObject *)method->m_function),
5537 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
5538 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
5543 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 7);
5545 CHECK_OBJECT_X(result);
5549 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5557 if (function->m_args_simple && 7 + 1 == function->m_args_positional_count) {
5558 PyObject *python_pars[7 + 1];
5560 python_pars[0] = method->m_object;
5561 Py_INCREF(method->m_object);
5563 for (Py_ssize_t i = 0; i < 7; i++) {
5564 python_pars[i + 1] = args[i];
5567 result = function->m_c_code(tstate, function, python_pars);
5568 }
else if (function->m_args_simple &&
5569 7 + 1 + function->m_defaults_given == function->m_args_positional_count) {
5570 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5572 python_pars[0] = method->m_object;
5573 Py_INCREF(method->m_object);
5575 memcpy(python_pars + 1, args, 7 *
sizeof(PyObject *));
5576 memcpy(python_pars + 1 + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
5577 function->m_defaults_given *
sizeof(PyObject *));
5579 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
5580 Py_INCREF(python_pars[i]);
5583 result = function->m_c_code(tstate, function, python_pars);
5585 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 7);
5588 Py_LeaveRecursiveCall();
5590 CHECK_OBJECT_X(result);
5594#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
5595 }
else if (PyCFunction_CheckExact(called)) {
5596#if PYTHON_VERSION >= 0x380
5597#ifdef _NUITKA_FULL_COMPAT
5598 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5603 int flags = PyCFunction_GET_FLAGS(called);
5607 if (!(flags & METH_VARARGS)) {
5608 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5610 assert(func != NULL);
5611 result = func(called, args, 7, NULL);
5613 CHECK_OBJECT_X(result);
5615 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5616 PyObject *self = PyCFunction_GET_SELF(called);
5618 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5620 if (flags & METH_KEYWORDS) {
5621 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
5623 result = (*method)(self, pos_args);
5626 Py_DECREF(pos_args);
5629#ifdef _NUITKA_FULL_COMPAT
5630 Py_LeaveRecursiveCall();
5632 CHECK_OBJECT_X(result);
5634 return Nuitka_CheckFunctionResult(tstate, called, result);
5637 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
5639 if (unlikely(flags & METH_NOARGS)) {
5640 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (7 given)",
5641 ((PyCFunctionObject *)called)->m_ml->ml_name);
5643 }
else if (unlikely(flags & METH_O)) {
5644 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (7 given)",
5645 ((PyCFunctionObject *)called)->m_ml->ml_name);
5647 }
else if (flags & METH_VARARGS) {
5650#ifdef _NUITKA_FULL_COMPAT
5651 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5655 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5656 PyObject *self = PyCFunction_GET_SELF(called);
5660#if PYTHON_VERSION < 0x360
5661 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5662 if (flags & METH_KEYWORDS) {
5663 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5665 result = (*method)(self, pos_args);
5668 Py_DECREF(pos_args);
5670 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
5671 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5672 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5673 Py_DECREF(pos_args);
5674 }
else if (flags == METH_FASTCALL) {
5675#if PYTHON_VERSION < 0x370
5676 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 7, NULL);
5678 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5679 result = (*(_PyCFunctionFast)method)(self, &pos_args, 7);
5680 Py_DECREF(pos_args);
5683 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5684 result = (*method)(self, pos_args);
5685 Py_DECREF(pos_args);
5689#ifdef _NUITKA_FULL_COMPAT
5690 Py_LeaveRecursiveCall();
5693 CHECK_OBJECT_X(result);
5695 return Nuitka_CheckFunctionResult(tstate, called, result);
5699#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
5700 }
else if (PyFunction_Check(called)) {
5701#if PYTHON_VERSION < 0x3b0
5702 PyObject *result = callPythonFunction(called, args, 7);
5704 PyObject *result = _PyFunction_Vectorcall(called, args, 7, NULL);
5706 CHECK_OBJECT_X(result);
5710#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
5711 }
else if (PyType_Check(called)) {
5712 PyTypeObject *type = Py_TYPE(called);
5714 if (type->tp_call == PyType_Type.tp_call) {
5715 PyTypeObject *called_type = (PyTypeObject *)(called);
5717 if (unlikely(called_type->tp_new == NULL)) {
5718 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
5722 PyObject *pos_args = NULL;
5725 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
5726 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
5727 formatCannotInstantiateAbstractClass(tstate, called_type);
5731 obj = called_type->tp_alloc(called_type, 0);
5734 pos_args = MAKE_TUPLE(tstate, args, 7);
5735 obj = called_type->tp_new(called_type, pos_args, NULL);
5738 if (likely(obj != NULL)) {
5739 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
5740 Py_DECREF(pos_args);
5745 type = Py_TYPE(obj);
5747 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
5748 if (type->tp_init == default_tp_init_wrapper) {
5749 Py_XDECREF(pos_args);
5752 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
5755 assert(init_method != NULL);
5757 bool is_compiled_function =
false;
5758 bool init_method_needs_release =
false;
5760 if (likely(init_method != NULL)) {
5761 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
5763 if (func == Nuitka_Function_Type.tp_descr_get) {
5764 is_compiled_function =
true;
5765 }
else if (func != NULL) {
5766 init_method = func(init_method, obj, (PyObject *)(type));
5767 init_method_needs_release =
true;
5771 if (unlikely(init_method == NULL)) {
5772 if (!HAS_ERROR_OCCURRED(tstate)) {
5773 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
5774 const_str_plain___init__);
5781 if (is_compiled_function) {
5782 result = Nuitka_CallMethodFunctionPosArgs(
5785 result = CALL_FUNCTION_WITH_ARGS7(tstate, init_method, args);
5786 if (init_method_needs_release) {
5787 Py_DECREF(init_method);
5791 if (unlikely(result == NULL)) {
5798 if (unlikely(result != Py_None)) {
5801 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5805 if (pos_args == NULL) {
5806 pos_args = MAKE_TUPLE(tstate, args, 7);
5809 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
5811 Py_XDECREF(pos_args);
5818 Py_XDECREF(pos_args);
5820 CHECK_OBJECT_X(obj);
5825#if PYTHON_VERSION < 0x300
5826 }
else if (PyClass_Check(called)) {
5827 PyObject *obj = PyInstance_NewRaw(called, NULL);
5829 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
5831 if (unlikely(init_method == NULL)) {
5832 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
5839 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
5843 bool is_compiled_function =
false;
5845 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
5847 if (descr_get == NULL) {
5848 Py_INCREF(init_method);
5849 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
5850 is_compiled_function =
true;
5851 }
else if (descr_get != NULL) {
5852 PyObject *descr_method = descr_get(init_method, obj, called);
5854 if (unlikely(descr_method == NULL)) {
5858 init_method = descr_method;
5862 if (is_compiled_function) {
5863 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
5866 result = CALL_FUNCTION_WITH_ARGS7(tstate, init_method, args);
5867 Py_DECREF(init_method);
5869 if (unlikely(result == NULL)) {
5875 if (unlikely(result != Py_None)) {
5876 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5880 CHECK_OBJECT_X(obj);
5884#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
5885 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
5886 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5888 if (likely(func != NULL)) {
5889 PyObject *result = func(called, args, 7, NULL);
5891 CHECK_OBJECT_X(result);
5893 return Nuitka_CheckFunctionResult(tstate, called, result);
5900 PRINT_STRING(
"FALLBACK");
5905 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5907 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
5909 Py_DECREF(pos_args);
5911 CHECK_OBJECT_X(result);
5915PyObject *CALL_FUNCTION_WITH_POS_ARGS7(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
5916 assert(PyTuple_CheckExact(pos_args));
5917 assert(PyTuple_GET_SIZE(pos_args) == 7);
5918 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
5919 CHECK_OBJECT(called);
5920 CHECK_OBJECTS(args, 7);
5922 if (Nuitka_Function_Check(called)) {
5923 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5930 if (function->m_args_simple && 7 == function->m_args_positional_count) {
5931 for (Py_ssize_t i = 0; i < 7; i++) {
5934 result = function->m_c_code(tstate, function, (PyObject **)args);
5935 }
else if (function->m_args_simple && 7 + function->m_defaults_given == function->m_args_positional_count) {
5936 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5938 memcpy(python_pars, args, 7 *
sizeof(PyObject *));
5939 memcpy(python_pars + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
5940 function->m_defaults_given *
sizeof(PyObject *));
5942 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
5943 Py_INCREF(python_pars[i]);
5946 result = function->m_c_code(tstate, function, python_pars);
5948 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 7);
5951 Py_LeaveRecursiveCall();
5953 CHECK_OBJECT_X(result);
5956 }
else if (Nuitka_Method_Check(called)) {
5959 if (method->m_object == NULL) {
5960 PyObject *self = args[0];
5962 int res = PyObject_IsInstance(self, method->m_class);
5964 if (unlikely(res < 0)) {
5966 }
else if (unlikely(res == 0)) {
5967 PyErr_Format(PyExc_TypeError,
5968 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
5969 "instance instead)",
5970 GET_CALLABLE_NAME((PyObject *)method->m_function),
5971 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
5972 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
5977 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 7);
5979 CHECK_OBJECT_X(result);
5983 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5991 if (function->m_args_simple && 7 + 1 == function->m_args_positional_count) {
5992 PyObject *python_pars[7 + 1];
5994 python_pars[0] = method->m_object;
5995 Py_INCREF(method->m_object);
5997 for (Py_ssize_t i = 0; i < 7; i++) {
5998 python_pars[i + 1] = args[i];
6001 result = function->m_c_code(tstate, function, python_pars);
6002 }
else if (function->m_args_simple &&
6003 7 + 1 + function->m_defaults_given == function->m_args_positional_count) {
6004 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6006 python_pars[0] = method->m_object;
6007 Py_INCREF(method->m_object);
6009 memcpy(python_pars + 1, args, 7 *
sizeof(PyObject *));
6010 memcpy(python_pars + 1 + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
6011 function->m_defaults_given *
sizeof(PyObject *));
6013 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
6014 Py_INCREF(python_pars[i]);
6017 result = function->m_c_code(tstate, function, python_pars);
6019 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 7);
6022 Py_LeaveRecursiveCall();
6024 CHECK_OBJECT_X(result);
6028#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
6029 }
else if (PyCFunction_CheckExact(called)) {
6030#if PYTHON_VERSION >= 0x380
6031#ifdef _NUITKA_FULL_COMPAT
6032 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6037 int flags = PyCFunction_GET_FLAGS(called);
6041 if (!(flags & METH_VARARGS)) {
6042 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6044 assert(func != NULL);
6045 result = func(called, args, 7, NULL);
6047 CHECK_OBJECT_X(result);
6049 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6050 PyObject *self = PyCFunction_GET_SELF(called);
6052 if (flags & METH_KEYWORDS) {
6053 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
6055 result = (*method)(self, pos_args);
6059#ifdef _NUITKA_FULL_COMPAT
6060 Py_LeaveRecursiveCall();
6062 CHECK_OBJECT_X(result);
6064 return Nuitka_CheckFunctionResult(tstate, called, result);
6067 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
6069 if (unlikely(flags & METH_NOARGS)) {
6070 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (7 given)",
6071 ((PyCFunctionObject *)called)->m_ml->ml_name);
6073 }
else if (unlikely(flags & METH_O)) {
6074 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (7 given)",
6075 ((PyCFunctionObject *)called)->m_ml->ml_name);
6077 }
else if (flags & METH_VARARGS) {
6080#ifdef _NUITKA_FULL_COMPAT
6081 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6085 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6086 PyObject *self = PyCFunction_GET_SELF(called);
6090#if PYTHON_VERSION < 0x360
6091 if (flags & METH_KEYWORDS) {
6092 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6094 result = (*method)(self, pos_args);
6098 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
6099 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6100 }
else if (flags == METH_FASTCALL) {
6101#if PYTHON_VERSION < 0x370
6102 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 7, NULL);
6104 result = (*(_PyCFunctionFast)method)(self, &pos_args, 7);
6107 result = (*method)(self, pos_args);
6111#ifdef _NUITKA_FULL_COMPAT
6112 Py_LeaveRecursiveCall();
6115 CHECK_OBJECT_X(result);
6117 return Nuitka_CheckFunctionResult(tstate, called, result);
6121#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
6122 }
else if (PyFunction_Check(called)) {
6123#if PYTHON_VERSION < 0x3b0
6124 PyObject *result = callPythonFunction(called, args, 7);
6126 PyObject *result = _PyFunction_Vectorcall(called, args, 7, NULL);
6128 CHECK_OBJECT_X(result);
6132#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
6133 }
else if (PyType_Check(called)) {
6134 PyTypeObject *type = Py_TYPE(called);
6136 if (type->tp_call == PyType_Type.tp_call) {
6137 PyTypeObject *called_type = (PyTypeObject *)(called);
6139 if (unlikely(called_type->tp_new == NULL)) {
6140 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
6146 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
6147 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
6148 formatCannotInstantiateAbstractClass(tstate, called_type);
6152 obj = called_type->tp_alloc(called_type, 0);
6155 obj = called_type->tp_new(called_type, pos_args, NULL);
6158 if (likely(obj != NULL)) {
6159 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
6164 type = Py_TYPE(obj);
6166 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
6167 if (type->tp_init == default_tp_init_wrapper) {
6169 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
6172 assert(init_method != NULL);
6174 bool is_compiled_function =
false;
6175 bool init_method_needs_release =
false;
6177 if (likely(init_method != NULL)) {
6178 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
6180 if (func == Nuitka_Function_Type.tp_descr_get) {
6181 is_compiled_function =
true;
6182 }
else if (func != NULL) {
6183 init_method = func(init_method, obj, (PyObject *)(type));
6184 init_method_needs_release =
true;
6188 if (unlikely(init_method == NULL)) {
6189 if (!HAS_ERROR_OCCURRED(tstate)) {
6190 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
6191 const_str_plain___init__);
6198 if (is_compiled_function) {
6199 result = Nuitka_CallMethodFunctionPosArgs(
6202 result = CALL_FUNCTION_WITH_POS_ARGS7(tstate, init_method, pos_args);
6203 if (init_method_needs_release) {
6204 Py_DECREF(init_method);
6208 if (unlikely(result == NULL)) {
6215 if (unlikely(result != Py_None)) {
6218 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
6223 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
6231 CHECK_OBJECT_X(obj);
6236#if PYTHON_VERSION < 0x300
6237 }
else if (PyClass_Check(called)) {
6238 PyObject *obj = PyInstance_NewRaw(called, NULL);
6240 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
6242 if (unlikely(init_method == NULL)) {
6243 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
6250 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
6254 bool is_compiled_function =
false;
6256 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
6258 if (descr_get == NULL) {
6259 Py_INCREF(init_method);
6260 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
6261 is_compiled_function =
true;
6262 }
else if (descr_get != NULL) {
6263 PyObject *descr_method = descr_get(init_method, obj, called);
6265 if (unlikely(descr_method == NULL)) {
6269 init_method = descr_method;
6273 if (is_compiled_function) {
6274 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
6277 result = CALL_FUNCTION_WITH_POS_ARGS7(tstate, init_method, pos_args);
6278 Py_DECREF(init_method);
6280 if (unlikely(result == NULL)) {
6286 if (unlikely(result != Py_None)) {
6287 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
6291 CHECK_OBJECT_X(obj);
6295#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
6296 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
6297 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6299 if (likely(func != NULL)) {
6300 PyObject *result = func(called, args, 7, NULL);
6302 CHECK_OBJECT_X(result);
6304 return Nuitka_CheckFunctionResult(tstate, called, result);
6311 PRINT_STRING(
"FALLBACK");
6316 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
6318 CHECK_OBJECT_X(result);
6322PyObject *CALL_FUNCTION_WITH_ARGS8(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
6323 CHECK_OBJECT(called);
6324 CHECK_OBJECTS(args, 8);
6326 if (Nuitka_Function_Check(called)) {
6327 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6334 if (function->m_args_simple && 8 == function->m_args_positional_count) {
6335 for (Py_ssize_t i = 0; i < 8; i++) {
6338 result = function->m_c_code(tstate, function, (PyObject **)args);
6339 }
else if (function->m_args_simple && 8 + function->m_defaults_given == function->m_args_positional_count) {
6340 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6342 memcpy(python_pars, args, 8 *
sizeof(PyObject *));
6343 memcpy(python_pars + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6344 function->m_defaults_given *
sizeof(PyObject *));
6346 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
6347 Py_INCREF(python_pars[i]);
6350 result = function->m_c_code(tstate, function, python_pars);
6352 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 8);
6355 Py_LeaveRecursiveCall();
6357 CHECK_OBJECT_X(result);
6360 }
else if (Nuitka_Method_Check(called)) {
6363 if (method->m_object == NULL) {
6364 PyObject *self = args[0];
6366 int res = PyObject_IsInstance(self, method->m_class);
6368 if (unlikely(res < 0)) {
6370 }
else if (unlikely(res == 0)) {
6371 PyErr_Format(PyExc_TypeError,
6372 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
6373 "instance instead)",
6374 GET_CALLABLE_NAME((PyObject *)method->m_function),
6375 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
6376 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
6381 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 8);
6383 CHECK_OBJECT_X(result);
6387 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6395 if (function->m_args_simple && 8 + 1 == function->m_args_positional_count) {
6396 PyObject *python_pars[8 + 1];
6398 python_pars[0] = method->m_object;
6399 Py_INCREF(method->m_object);
6401 for (Py_ssize_t i = 0; i < 8; i++) {
6402 python_pars[i + 1] = args[i];
6405 result = function->m_c_code(tstate, function, python_pars);
6406 }
else if (function->m_args_simple &&
6407 8 + 1 + function->m_defaults_given == function->m_args_positional_count) {
6408 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6410 python_pars[0] = method->m_object;
6411 Py_INCREF(method->m_object);
6413 memcpy(python_pars + 1, args, 8 *
sizeof(PyObject *));
6414 memcpy(python_pars + 1 + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6415 function->m_defaults_given *
sizeof(PyObject *));
6417 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
6418 Py_INCREF(python_pars[i]);
6421 result = function->m_c_code(tstate, function, python_pars);
6423 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 8);
6426 Py_LeaveRecursiveCall();
6428 CHECK_OBJECT_X(result);
6432#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
6433 }
else if (PyCFunction_CheckExact(called)) {
6434#if PYTHON_VERSION >= 0x380
6435#ifdef _NUITKA_FULL_COMPAT
6436 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6441 int flags = PyCFunction_GET_FLAGS(called);
6445 if (!(flags & METH_VARARGS)) {
6446 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6448 assert(func != NULL);
6449 result = func(called, args, 8, NULL);
6451 CHECK_OBJECT_X(result);
6453 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6454 PyObject *self = PyCFunction_GET_SELF(called);
6456 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6458 if (flags & METH_KEYWORDS) {
6459 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
6461 result = (*method)(self, pos_args);
6464 Py_DECREF(pos_args);
6467#ifdef _NUITKA_FULL_COMPAT
6468 Py_LeaveRecursiveCall();
6470 CHECK_OBJECT_X(result);
6472 return Nuitka_CheckFunctionResult(tstate, called, result);
6475 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
6477 if (unlikely(flags & METH_NOARGS)) {
6478 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (8 given)",
6479 ((PyCFunctionObject *)called)->m_ml->ml_name);
6481 }
else if (unlikely(flags & METH_O)) {
6482 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (8 given)",
6483 ((PyCFunctionObject *)called)->m_ml->ml_name);
6485 }
else if (flags & METH_VARARGS) {
6488#ifdef _NUITKA_FULL_COMPAT
6489 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6493 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6494 PyObject *self = PyCFunction_GET_SELF(called);
6498#if PYTHON_VERSION < 0x360
6499 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6500 if (flags & METH_KEYWORDS) {
6501 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6503 result = (*method)(self, pos_args);
6506 Py_DECREF(pos_args);
6508 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
6509 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6510 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6511 Py_DECREF(pos_args);
6512 }
else if (flags == METH_FASTCALL) {
6513#if PYTHON_VERSION < 0x370
6514 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 8, NULL);
6516 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6517 result = (*(_PyCFunctionFast)method)(self, &pos_args, 8);
6518 Py_DECREF(pos_args);
6521 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6522 result = (*method)(self, pos_args);
6523 Py_DECREF(pos_args);
6527#ifdef _NUITKA_FULL_COMPAT
6528 Py_LeaveRecursiveCall();
6531 CHECK_OBJECT_X(result);
6533 return Nuitka_CheckFunctionResult(tstate, called, result);
6537#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
6538 }
else if (PyFunction_Check(called)) {
6539#if PYTHON_VERSION < 0x3b0
6540 PyObject *result = callPythonFunction(called, args, 8);
6542 PyObject *result = _PyFunction_Vectorcall(called, args, 8, NULL);
6544 CHECK_OBJECT_X(result);
6548#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
6549 }
else if (PyType_Check(called)) {
6550 PyTypeObject *type = Py_TYPE(called);
6552 if (type->tp_call == PyType_Type.tp_call) {
6553 PyTypeObject *called_type = (PyTypeObject *)(called);
6555 if (unlikely(called_type->tp_new == NULL)) {
6556 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
6560 PyObject *pos_args = NULL;
6563 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
6564 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
6565 formatCannotInstantiateAbstractClass(tstate, called_type);
6569 obj = called_type->tp_alloc(called_type, 0);
6572 pos_args = MAKE_TUPLE(tstate, args, 8);
6573 obj = called_type->tp_new(called_type, pos_args, NULL);
6576 if (likely(obj != NULL)) {
6577 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
6578 Py_DECREF(pos_args);
6583 type = Py_TYPE(obj);
6585 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
6586 if (type->tp_init == default_tp_init_wrapper) {
6587 Py_XDECREF(pos_args);
6590 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
6593 assert(init_method != NULL);
6595 bool is_compiled_function =
false;
6596 bool init_method_needs_release =
false;
6598 if (likely(init_method != NULL)) {
6599 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
6601 if (func == Nuitka_Function_Type.tp_descr_get) {
6602 is_compiled_function =
true;
6603 }
else if (func != NULL) {
6604 init_method = func(init_method, obj, (PyObject *)(type));
6605 init_method_needs_release =
true;
6609 if (unlikely(init_method == NULL)) {
6610 if (!HAS_ERROR_OCCURRED(tstate)) {
6611 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
6612 const_str_plain___init__);
6619 if (is_compiled_function) {
6620 result = Nuitka_CallMethodFunctionPosArgs(
6623 result = CALL_FUNCTION_WITH_ARGS8(tstate, init_method, args);
6624 if (init_method_needs_release) {
6625 Py_DECREF(init_method);
6629 if (unlikely(result == NULL)) {
6636 if (unlikely(result != Py_None)) {
6639 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
6643 if (pos_args == NULL) {
6644 pos_args = MAKE_TUPLE(tstate, args, 8);
6647 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
6649 Py_XDECREF(pos_args);
6656 Py_XDECREF(pos_args);
6658 CHECK_OBJECT_X(obj);
6663#if PYTHON_VERSION < 0x300
6664 }
else if (PyClass_Check(called)) {
6665 PyObject *obj = PyInstance_NewRaw(called, NULL);
6667 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
6669 if (unlikely(init_method == NULL)) {
6670 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
6677 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
6681 bool is_compiled_function =
false;
6683 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
6685 if (descr_get == NULL) {
6686 Py_INCREF(init_method);
6687 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
6688 is_compiled_function =
true;
6689 }
else if (descr_get != NULL) {
6690 PyObject *descr_method = descr_get(init_method, obj, called);
6692 if (unlikely(descr_method == NULL)) {
6696 init_method = descr_method;
6700 if (is_compiled_function) {
6701 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
6704 result = CALL_FUNCTION_WITH_ARGS8(tstate, init_method, args);
6705 Py_DECREF(init_method);
6707 if (unlikely(result == NULL)) {
6713 if (unlikely(result != Py_None)) {
6714 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
6718 CHECK_OBJECT_X(obj);
6722#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
6723 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
6724 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6726 if (likely(func != NULL)) {
6727 PyObject *result = func(called, args, 8, NULL);
6729 CHECK_OBJECT_X(result);
6731 return Nuitka_CheckFunctionResult(tstate, called, result);
6738 PRINT_STRING(
"FALLBACK");
6743 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6745 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
6747 Py_DECREF(pos_args);
6749 CHECK_OBJECT_X(result);
6753PyObject *CALL_FUNCTION_WITH_POS_ARGS8(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
6754 assert(PyTuple_CheckExact(pos_args));
6755 assert(PyTuple_GET_SIZE(pos_args) == 8);
6756 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
6757 CHECK_OBJECT(called);
6758 CHECK_OBJECTS(args, 8);
6760 if (Nuitka_Function_Check(called)) {
6761 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6768 if (function->m_args_simple && 8 == function->m_args_positional_count) {
6769 for (Py_ssize_t i = 0; i < 8; i++) {
6772 result = function->m_c_code(tstate, function, (PyObject **)args);
6773 }
else if (function->m_args_simple && 8 + function->m_defaults_given == function->m_args_positional_count) {
6774 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6776 memcpy(python_pars, args, 8 *
sizeof(PyObject *));
6777 memcpy(python_pars + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6778 function->m_defaults_given *
sizeof(PyObject *));
6780 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
6781 Py_INCREF(python_pars[i]);
6784 result = function->m_c_code(tstate, function, python_pars);
6786 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 8);
6789 Py_LeaveRecursiveCall();
6791 CHECK_OBJECT_X(result);
6794 }
else if (Nuitka_Method_Check(called)) {
6797 if (method->m_object == NULL) {
6798 PyObject *self = args[0];
6800 int res = PyObject_IsInstance(self, method->m_class);
6802 if (unlikely(res < 0)) {
6804 }
else if (unlikely(res == 0)) {
6805 PyErr_Format(PyExc_TypeError,
6806 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
6807 "instance instead)",
6808 GET_CALLABLE_NAME((PyObject *)method->m_function),
6809 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
6810 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
6815 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 8);
6817 CHECK_OBJECT_X(result);
6821 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6829 if (function->m_args_simple && 8 + 1 == function->m_args_positional_count) {
6830 PyObject *python_pars[8 + 1];
6832 python_pars[0] = method->m_object;
6833 Py_INCREF(method->m_object);
6835 for (Py_ssize_t i = 0; i < 8; i++) {
6836 python_pars[i + 1] = args[i];
6839 result = function->m_c_code(tstate, function, python_pars);
6840 }
else if (function->m_args_simple &&
6841 8 + 1 + function->m_defaults_given == function->m_args_positional_count) {
6842 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6844 python_pars[0] = method->m_object;
6845 Py_INCREF(method->m_object);
6847 memcpy(python_pars + 1, args, 8 *
sizeof(PyObject *));
6848 memcpy(python_pars + 1 + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6849 function->m_defaults_given *
sizeof(PyObject *));
6851 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
6852 Py_INCREF(python_pars[i]);
6855 result = function->m_c_code(tstate, function, python_pars);
6857 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 8);
6860 Py_LeaveRecursiveCall();
6862 CHECK_OBJECT_X(result);
6866#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
6867 }
else if (PyCFunction_CheckExact(called)) {
6868#if PYTHON_VERSION >= 0x380
6869#ifdef _NUITKA_FULL_COMPAT
6870 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6875 int flags = PyCFunction_GET_FLAGS(called);
6879 if (!(flags & METH_VARARGS)) {
6880 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6882 assert(func != NULL);
6883 result = func(called, args, 8, NULL);
6885 CHECK_OBJECT_X(result);
6887 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6888 PyObject *self = PyCFunction_GET_SELF(called);
6890 if (flags & METH_KEYWORDS) {
6891 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
6893 result = (*method)(self, pos_args);
6897#ifdef _NUITKA_FULL_COMPAT
6898 Py_LeaveRecursiveCall();
6900 CHECK_OBJECT_X(result);
6902 return Nuitka_CheckFunctionResult(tstate, called, result);
6905 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
6907 if (unlikely(flags & METH_NOARGS)) {
6908 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (8 given)",
6909 ((PyCFunctionObject *)called)->m_ml->ml_name);
6911 }
else if (unlikely(flags & METH_O)) {
6912 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (8 given)",
6913 ((PyCFunctionObject *)called)->m_ml->ml_name);
6915 }
else if (flags & METH_VARARGS) {
6918#ifdef _NUITKA_FULL_COMPAT
6919 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6923 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6924 PyObject *self = PyCFunction_GET_SELF(called);
6928#if PYTHON_VERSION < 0x360
6929 if (flags & METH_KEYWORDS) {
6930 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6932 result = (*method)(self, pos_args);
6936 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
6937 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6938 }
else if (flags == METH_FASTCALL) {
6939#if PYTHON_VERSION < 0x370
6940 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 8, NULL);
6942 result = (*(_PyCFunctionFast)method)(self, &pos_args, 8);
6945 result = (*method)(self, pos_args);
6949#ifdef _NUITKA_FULL_COMPAT
6950 Py_LeaveRecursiveCall();
6953 CHECK_OBJECT_X(result);
6955 return Nuitka_CheckFunctionResult(tstate, called, result);
6959#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
6960 }
else if (PyFunction_Check(called)) {
6961#if PYTHON_VERSION < 0x3b0
6962 PyObject *result = callPythonFunction(called, args, 8);
6964 PyObject *result = _PyFunction_Vectorcall(called, args, 8, NULL);
6966 CHECK_OBJECT_X(result);
6970#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
6971 }
else if (PyType_Check(called)) {
6972 PyTypeObject *type = Py_TYPE(called);
6974 if (type->tp_call == PyType_Type.tp_call) {
6975 PyTypeObject *called_type = (PyTypeObject *)(called);
6977 if (unlikely(called_type->tp_new == NULL)) {
6978 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
6984 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
6985 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
6986 formatCannotInstantiateAbstractClass(tstate, called_type);
6990 obj = called_type->tp_alloc(called_type, 0);
6993 obj = called_type->tp_new(called_type, pos_args, NULL);
6996 if (likely(obj != NULL)) {
6997 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
7002 type = Py_TYPE(obj);
7004 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
7005 if (type->tp_init == default_tp_init_wrapper) {
7007 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
7010 assert(init_method != NULL);
7012 bool is_compiled_function =
false;
7013 bool init_method_needs_release =
false;
7015 if (likely(init_method != NULL)) {
7016 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
7018 if (func == Nuitka_Function_Type.tp_descr_get) {
7019 is_compiled_function =
true;
7020 }
else if (func != NULL) {
7021 init_method = func(init_method, obj, (PyObject *)(type));
7022 init_method_needs_release =
true;
7026 if (unlikely(init_method == NULL)) {
7027 if (!HAS_ERROR_OCCURRED(tstate)) {
7028 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
7029 const_str_plain___init__);
7036 if (is_compiled_function) {
7037 result = Nuitka_CallMethodFunctionPosArgs(
7040 result = CALL_FUNCTION_WITH_POS_ARGS8(tstate, init_method, pos_args);
7041 if (init_method_needs_release) {
7042 Py_DECREF(init_method);
7046 if (unlikely(result == NULL)) {
7053 if (unlikely(result != Py_None)) {
7056 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7061 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
7069 CHECK_OBJECT_X(obj);
7074#if PYTHON_VERSION < 0x300
7075 }
else if (PyClass_Check(called)) {
7076 PyObject *obj = PyInstance_NewRaw(called, NULL);
7078 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
7080 if (unlikely(init_method == NULL)) {
7081 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
7088 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
7092 bool is_compiled_function =
false;
7094 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
7096 if (descr_get == NULL) {
7097 Py_INCREF(init_method);
7098 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
7099 is_compiled_function =
true;
7100 }
else if (descr_get != NULL) {
7101 PyObject *descr_method = descr_get(init_method, obj, called);
7103 if (unlikely(descr_method == NULL)) {
7107 init_method = descr_method;
7111 if (is_compiled_function) {
7112 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
7115 result = CALL_FUNCTION_WITH_POS_ARGS8(tstate, init_method, pos_args);
7116 Py_DECREF(init_method);
7118 if (unlikely(result == NULL)) {
7124 if (unlikely(result != Py_None)) {
7125 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7129 CHECK_OBJECT_X(obj);
7133#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
7134 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
7135 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7137 if (likely(func != NULL)) {
7138 PyObject *result = func(called, args, 8, NULL);
7140 CHECK_OBJECT_X(result);
7142 return Nuitka_CheckFunctionResult(tstate, called, result);
7149 PRINT_STRING(
"FALLBACK");
7154 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
7156 CHECK_OBJECT_X(result);
7160PyObject *CALL_FUNCTION_WITH_ARGS9(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
7161 CHECK_OBJECT(called);
7162 CHECK_OBJECTS(args, 9);
7164 if (Nuitka_Function_Check(called)) {
7165 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7172 if (function->m_args_simple && 9 == function->m_args_positional_count) {
7173 for (Py_ssize_t i = 0; i < 9; i++) {
7176 result = function->m_c_code(tstate, function, (PyObject **)args);
7177 }
else if (function->m_args_simple && 9 + function->m_defaults_given == function->m_args_positional_count) {
7178 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7180 memcpy(python_pars, args, 9 *
sizeof(PyObject *));
7181 memcpy(python_pars + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7182 function->m_defaults_given *
sizeof(PyObject *));
7184 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
7185 Py_INCREF(python_pars[i]);
7188 result = function->m_c_code(tstate, function, python_pars);
7190 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 9);
7193 Py_LeaveRecursiveCall();
7195 CHECK_OBJECT_X(result);
7198 }
else if (Nuitka_Method_Check(called)) {
7201 if (method->m_object == NULL) {
7202 PyObject *self = args[0];
7204 int res = PyObject_IsInstance(self, method->m_class);
7206 if (unlikely(res < 0)) {
7208 }
else if (unlikely(res == 0)) {
7209 PyErr_Format(PyExc_TypeError,
7210 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
7211 "instance instead)",
7212 GET_CALLABLE_NAME((PyObject *)method->m_function),
7213 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
7214 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
7219 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 9);
7221 CHECK_OBJECT_X(result);
7225 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7233 if (function->m_args_simple && 9 + 1 == function->m_args_positional_count) {
7234 PyObject *python_pars[9 + 1];
7236 python_pars[0] = method->m_object;
7237 Py_INCREF(method->m_object);
7239 for (Py_ssize_t i = 0; i < 9; i++) {
7240 python_pars[i + 1] = args[i];
7243 result = function->m_c_code(tstate, function, python_pars);
7244 }
else if (function->m_args_simple &&
7245 9 + 1 + function->m_defaults_given == function->m_args_positional_count) {
7246 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7248 python_pars[0] = method->m_object;
7249 Py_INCREF(method->m_object);
7251 memcpy(python_pars + 1, args, 9 *
sizeof(PyObject *));
7252 memcpy(python_pars + 1 + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7253 function->m_defaults_given *
sizeof(PyObject *));
7255 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
7256 Py_INCREF(python_pars[i]);
7259 result = function->m_c_code(tstate, function, python_pars);
7261 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 9);
7264 Py_LeaveRecursiveCall();
7266 CHECK_OBJECT_X(result);
7270#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
7271 }
else if (PyCFunction_CheckExact(called)) {
7272#if PYTHON_VERSION >= 0x380
7273#ifdef _NUITKA_FULL_COMPAT
7274 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7279 int flags = PyCFunction_GET_FLAGS(called);
7283 if (!(flags & METH_VARARGS)) {
7284 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7286 assert(func != NULL);
7287 result = func(called, args, 9, NULL);
7289 CHECK_OBJECT_X(result);
7291 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7292 PyObject *self = PyCFunction_GET_SELF(called);
7294 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7296 if (flags & METH_KEYWORDS) {
7297 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
7299 result = (*method)(self, pos_args);
7302 Py_DECREF(pos_args);
7305#ifdef _NUITKA_FULL_COMPAT
7306 Py_LeaveRecursiveCall();
7308 CHECK_OBJECT_X(result);
7310 return Nuitka_CheckFunctionResult(tstate, called, result);
7313 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
7315 if (unlikely(flags & METH_NOARGS)) {
7316 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (9 given)",
7317 ((PyCFunctionObject *)called)->m_ml->ml_name);
7319 }
else if (unlikely(flags & METH_O)) {
7320 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (9 given)",
7321 ((PyCFunctionObject *)called)->m_ml->ml_name);
7323 }
else if (flags & METH_VARARGS) {
7326#ifdef _NUITKA_FULL_COMPAT
7327 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7331 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7332 PyObject *self = PyCFunction_GET_SELF(called);
7336#if PYTHON_VERSION < 0x360
7337 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7338 if (flags & METH_KEYWORDS) {
7339 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7341 result = (*method)(self, pos_args);
7344 Py_DECREF(pos_args);
7346 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
7347 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7348 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7349 Py_DECREF(pos_args);
7350 }
else if (flags == METH_FASTCALL) {
7351#if PYTHON_VERSION < 0x370
7352 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 9, NULL);
7354 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7355 result = (*(_PyCFunctionFast)method)(self, &pos_args, 9);
7356 Py_DECREF(pos_args);
7359 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7360 result = (*method)(self, pos_args);
7361 Py_DECREF(pos_args);
7365#ifdef _NUITKA_FULL_COMPAT
7366 Py_LeaveRecursiveCall();
7369 CHECK_OBJECT_X(result);
7371 return Nuitka_CheckFunctionResult(tstate, called, result);
7375#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
7376 }
else if (PyFunction_Check(called)) {
7377#if PYTHON_VERSION < 0x3b0
7378 PyObject *result = callPythonFunction(called, args, 9);
7380 PyObject *result = _PyFunction_Vectorcall(called, args, 9, NULL);
7382 CHECK_OBJECT_X(result);
7386#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
7387 }
else if (PyType_Check(called)) {
7388 PyTypeObject *type = Py_TYPE(called);
7390 if (type->tp_call == PyType_Type.tp_call) {
7391 PyTypeObject *called_type = (PyTypeObject *)(called);
7393 if (unlikely(called_type->tp_new == NULL)) {
7394 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
7398 PyObject *pos_args = NULL;
7401 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
7402 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
7403 formatCannotInstantiateAbstractClass(tstate, called_type);
7407 obj = called_type->tp_alloc(called_type, 0);
7410 pos_args = MAKE_TUPLE(tstate, args, 9);
7411 obj = called_type->tp_new(called_type, pos_args, NULL);
7414 if (likely(obj != NULL)) {
7415 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
7416 Py_DECREF(pos_args);
7421 type = Py_TYPE(obj);
7423 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
7424 if (type->tp_init == default_tp_init_wrapper) {
7425 Py_XDECREF(pos_args);
7428 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
7431 assert(init_method != NULL);
7433 bool is_compiled_function =
false;
7434 bool init_method_needs_release =
false;
7436 if (likely(init_method != NULL)) {
7437 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
7439 if (func == Nuitka_Function_Type.tp_descr_get) {
7440 is_compiled_function =
true;
7441 }
else if (func != NULL) {
7442 init_method = func(init_method, obj, (PyObject *)(type));
7443 init_method_needs_release =
true;
7447 if (unlikely(init_method == NULL)) {
7448 if (!HAS_ERROR_OCCURRED(tstate)) {
7449 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
7450 const_str_plain___init__);
7457 if (is_compiled_function) {
7458 result = Nuitka_CallMethodFunctionPosArgs(
7461 result = CALL_FUNCTION_WITH_ARGS9(tstate, init_method, args);
7462 if (init_method_needs_release) {
7463 Py_DECREF(init_method);
7467 if (unlikely(result == NULL)) {
7474 if (unlikely(result != Py_None)) {
7477 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7481 if (pos_args == NULL) {
7482 pos_args = MAKE_TUPLE(tstate, args, 9);
7485 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
7487 Py_XDECREF(pos_args);
7494 Py_XDECREF(pos_args);
7496 CHECK_OBJECT_X(obj);
7501#if PYTHON_VERSION < 0x300
7502 }
else if (PyClass_Check(called)) {
7503 PyObject *obj = PyInstance_NewRaw(called, NULL);
7505 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
7507 if (unlikely(init_method == NULL)) {
7508 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
7515 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
7519 bool is_compiled_function =
false;
7521 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
7523 if (descr_get == NULL) {
7524 Py_INCREF(init_method);
7525 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
7526 is_compiled_function =
true;
7527 }
else if (descr_get != NULL) {
7528 PyObject *descr_method = descr_get(init_method, obj, called);
7530 if (unlikely(descr_method == NULL)) {
7534 init_method = descr_method;
7538 if (is_compiled_function) {
7539 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
7542 result = CALL_FUNCTION_WITH_ARGS9(tstate, init_method, args);
7543 Py_DECREF(init_method);
7545 if (unlikely(result == NULL)) {
7551 if (unlikely(result != Py_None)) {
7552 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7556 CHECK_OBJECT_X(obj);
7560#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
7561 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
7562 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7564 if (likely(func != NULL)) {
7565 PyObject *result = func(called, args, 9, NULL);
7567 CHECK_OBJECT_X(result);
7569 return Nuitka_CheckFunctionResult(tstate, called, result);
7576 PRINT_STRING(
"FALLBACK");
7581 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7583 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
7585 Py_DECREF(pos_args);
7587 CHECK_OBJECT_X(result);
7591PyObject *CALL_FUNCTION_WITH_POS_ARGS9(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
7592 assert(PyTuple_CheckExact(pos_args));
7593 assert(PyTuple_GET_SIZE(pos_args) == 9);
7594 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
7595 CHECK_OBJECT(called);
7596 CHECK_OBJECTS(args, 9);
7598 if (Nuitka_Function_Check(called)) {
7599 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7606 if (function->m_args_simple && 9 == function->m_args_positional_count) {
7607 for (Py_ssize_t i = 0; i < 9; i++) {
7610 result = function->m_c_code(tstate, function, (PyObject **)args);
7611 }
else if (function->m_args_simple && 9 + function->m_defaults_given == function->m_args_positional_count) {
7612 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7614 memcpy(python_pars, args, 9 *
sizeof(PyObject *));
7615 memcpy(python_pars + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7616 function->m_defaults_given *
sizeof(PyObject *));
7618 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
7619 Py_INCREF(python_pars[i]);
7622 result = function->m_c_code(tstate, function, python_pars);
7624 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 9);
7627 Py_LeaveRecursiveCall();
7629 CHECK_OBJECT_X(result);
7632 }
else if (Nuitka_Method_Check(called)) {
7635 if (method->m_object == NULL) {
7636 PyObject *self = args[0];
7638 int res = PyObject_IsInstance(self, method->m_class);
7640 if (unlikely(res < 0)) {
7642 }
else if (unlikely(res == 0)) {
7643 PyErr_Format(PyExc_TypeError,
7644 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
7645 "instance instead)",
7646 GET_CALLABLE_NAME((PyObject *)method->m_function),
7647 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
7648 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
7653 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 9);
7655 CHECK_OBJECT_X(result);
7659 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7667 if (function->m_args_simple && 9 + 1 == function->m_args_positional_count) {
7668 PyObject *python_pars[9 + 1];
7670 python_pars[0] = method->m_object;
7671 Py_INCREF(method->m_object);
7673 for (Py_ssize_t i = 0; i < 9; i++) {
7674 python_pars[i + 1] = args[i];
7677 result = function->m_c_code(tstate, function, python_pars);
7678 }
else if (function->m_args_simple &&
7679 9 + 1 + function->m_defaults_given == function->m_args_positional_count) {
7680 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7682 python_pars[0] = method->m_object;
7683 Py_INCREF(method->m_object);
7685 memcpy(python_pars + 1, args, 9 *
sizeof(PyObject *));
7686 memcpy(python_pars + 1 + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7687 function->m_defaults_given *
sizeof(PyObject *));
7689 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
7690 Py_INCREF(python_pars[i]);
7693 result = function->m_c_code(tstate, function, python_pars);
7695 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 9);
7698 Py_LeaveRecursiveCall();
7700 CHECK_OBJECT_X(result);
7704#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
7705 }
else if (PyCFunction_CheckExact(called)) {
7706#if PYTHON_VERSION >= 0x380
7707#ifdef _NUITKA_FULL_COMPAT
7708 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7713 int flags = PyCFunction_GET_FLAGS(called);
7717 if (!(flags & METH_VARARGS)) {
7718 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7720 assert(func != NULL);
7721 result = func(called, args, 9, NULL);
7723 CHECK_OBJECT_X(result);
7725 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7726 PyObject *self = PyCFunction_GET_SELF(called);
7728 if (flags & METH_KEYWORDS) {
7729 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
7731 result = (*method)(self, pos_args);
7735#ifdef _NUITKA_FULL_COMPAT
7736 Py_LeaveRecursiveCall();
7738 CHECK_OBJECT_X(result);
7740 return Nuitka_CheckFunctionResult(tstate, called, result);
7743 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
7745 if (unlikely(flags & METH_NOARGS)) {
7746 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (9 given)",
7747 ((PyCFunctionObject *)called)->m_ml->ml_name);
7749 }
else if (unlikely(flags & METH_O)) {
7750 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (9 given)",
7751 ((PyCFunctionObject *)called)->m_ml->ml_name);
7753 }
else if (flags & METH_VARARGS) {
7756#ifdef _NUITKA_FULL_COMPAT
7757 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7761 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7762 PyObject *self = PyCFunction_GET_SELF(called);
7766#if PYTHON_VERSION < 0x360
7767 if (flags & METH_KEYWORDS) {
7768 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7770 result = (*method)(self, pos_args);
7774 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
7775 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7776 }
else if (flags == METH_FASTCALL) {
7777#if PYTHON_VERSION < 0x370
7778 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 9, NULL);
7780 result = (*(_PyCFunctionFast)method)(self, &pos_args, 9);
7783 result = (*method)(self, pos_args);
7787#ifdef _NUITKA_FULL_COMPAT
7788 Py_LeaveRecursiveCall();
7791 CHECK_OBJECT_X(result);
7793 return Nuitka_CheckFunctionResult(tstate, called, result);
7797#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
7798 }
else if (PyFunction_Check(called)) {
7799#if PYTHON_VERSION < 0x3b0
7800 PyObject *result = callPythonFunction(called, args, 9);
7802 PyObject *result = _PyFunction_Vectorcall(called, args, 9, NULL);
7804 CHECK_OBJECT_X(result);
7808#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
7809 }
else if (PyType_Check(called)) {
7810 PyTypeObject *type = Py_TYPE(called);
7812 if (type->tp_call == PyType_Type.tp_call) {
7813 PyTypeObject *called_type = (PyTypeObject *)(called);
7815 if (unlikely(called_type->tp_new == NULL)) {
7816 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
7822 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
7823 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
7824 formatCannotInstantiateAbstractClass(tstate, called_type);
7828 obj = called_type->tp_alloc(called_type, 0);
7831 obj = called_type->tp_new(called_type, pos_args, NULL);
7834 if (likely(obj != NULL)) {
7835 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
7840 type = Py_TYPE(obj);
7842 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
7843 if (type->tp_init == default_tp_init_wrapper) {
7845 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
7848 assert(init_method != NULL);
7850 bool is_compiled_function =
false;
7851 bool init_method_needs_release =
false;
7853 if (likely(init_method != NULL)) {
7854 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
7856 if (func == Nuitka_Function_Type.tp_descr_get) {
7857 is_compiled_function =
true;
7858 }
else if (func != NULL) {
7859 init_method = func(init_method, obj, (PyObject *)(type));
7860 init_method_needs_release =
true;
7864 if (unlikely(init_method == NULL)) {
7865 if (!HAS_ERROR_OCCURRED(tstate)) {
7866 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
7867 const_str_plain___init__);
7874 if (is_compiled_function) {
7875 result = Nuitka_CallMethodFunctionPosArgs(
7878 result = CALL_FUNCTION_WITH_POS_ARGS9(tstate, init_method, pos_args);
7879 if (init_method_needs_release) {
7880 Py_DECREF(init_method);
7884 if (unlikely(result == NULL)) {
7891 if (unlikely(result != Py_None)) {
7894 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7899 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
7907 CHECK_OBJECT_X(obj);
7912#if PYTHON_VERSION < 0x300
7913 }
else if (PyClass_Check(called)) {
7914 PyObject *obj = PyInstance_NewRaw(called, NULL);
7916 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
7918 if (unlikely(init_method == NULL)) {
7919 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
7926 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
7930 bool is_compiled_function =
false;
7932 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
7934 if (descr_get == NULL) {
7935 Py_INCREF(init_method);
7936 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
7937 is_compiled_function =
true;
7938 }
else if (descr_get != NULL) {
7939 PyObject *descr_method = descr_get(init_method, obj, called);
7941 if (unlikely(descr_method == NULL)) {
7945 init_method = descr_method;
7949 if (is_compiled_function) {
7950 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
7953 result = CALL_FUNCTION_WITH_POS_ARGS9(tstate, init_method, pos_args);
7954 Py_DECREF(init_method);
7956 if (unlikely(result == NULL)) {
7962 if (unlikely(result != Py_None)) {
7963 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7967 CHECK_OBJECT_X(obj);
7971#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
7972 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
7973 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7975 if (likely(func != NULL)) {
7976 PyObject *result = func(called, args, 9, NULL);
7978 CHECK_OBJECT_X(result);
7980 return Nuitka_CheckFunctionResult(tstate, called, result);
7987 PRINT_STRING(
"FALLBACK");
7992 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
7994 CHECK_OBJECT_X(result);
7998PyObject *CALL_FUNCTION_WITH_ARGS10(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
7999 CHECK_OBJECT(called);
8000 CHECK_OBJECTS(args, 10);
8002 if (Nuitka_Function_Check(called)) {
8003 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8010 if (function->m_args_simple && 10 == function->m_args_positional_count) {
8011 for (Py_ssize_t i = 0; i < 10; i++) {
8014 result = function->m_c_code(tstate, function, (PyObject **)args);
8015 }
else if (function->m_args_simple && 10 + function->m_defaults_given == function->m_args_positional_count) {
8016 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8018 memcpy(python_pars, args, 10 *
sizeof(PyObject *));
8019 memcpy(python_pars + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8020 function->m_defaults_given *
sizeof(PyObject *));
8022 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
8023 Py_INCREF(python_pars[i]);
8026 result = function->m_c_code(tstate, function, python_pars);
8028 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 10);
8031 Py_LeaveRecursiveCall();
8033 CHECK_OBJECT_X(result);
8036 }
else if (Nuitka_Method_Check(called)) {
8039 if (method->m_object == NULL) {
8040 PyObject *self = args[0];
8042 int res = PyObject_IsInstance(self, method->m_class);
8044 if (unlikely(res < 0)) {
8046 }
else if (unlikely(res == 0)) {
8047 PyErr_Format(PyExc_TypeError,
8048 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
8049 "instance instead)",
8050 GET_CALLABLE_NAME((PyObject *)method->m_function),
8051 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
8052 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
8057 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 10);
8059 CHECK_OBJECT_X(result);
8063 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8071 if (function->m_args_simple && 10 + 1 == function->m_args_positional_count) {
8072 PyObject *python_pars[10 + 1];
8074 python_pars[0] = method->m_object;
8075 Py_INCREF(method->m_object);
8077 for (Py_ssize_t i = 0; i < 10; i++) {
8078 python_pars[i + 1] = args[i];
8081 result = function->m_c_code(tstate, function, python_pars);
8082 }
else if (function->m_args_simple &&
8083 10 + 1 + function->m_defaults_given == function->m_args_positional_count) {
8084 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8086 python_pars[0] = method->m_object;
8087 Py_INCREF(method->m_object);
8089 memcpy(python_pars + 1, args, 10 *
sizeof(PyObject *));
8090 memcpy(python_pars + 1 + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8091 function->m_defaults_given *
sizeof(PyObject *));
8093 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
8094 Py_INCREF(python_pars[i]);
8097 result = function->m_c_code(tstate, function, python_pars);
8099 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 10);
8102 Py_LeaveRecursiveCall();
8104 CHECK_OBJECT_X(result);
8108#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
8109 }
else if (PyCFunction_CheckExact(called)) {
8110#if PYTHON_VERSION >= 0x380
8111#ifdef _NUITKA_FULL_COMPAT
8112 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8117 int flags = PyCFunction_GET_FLAGS(called);
8121 if (!(flags & METH_VARARGS)) {
8122 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8124 assert(func != NULL);
8125 result = func(called, args, 10, NULL);
8127 CHECK_OBJECT_X(result);
8129 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8130 PyObject *self = PyCFunction_GET_SELF(called);
8132 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8134 if (flags & METH_KEYWORDS) {
8135 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
8137 result = (*method)(self, pos_args);
8140 Py_DECREF(pos_args);
8143#ifdef _NUITKA_FULL_COMPAT
8144 Py_LeaveRecursiveCall();
8146 CHECK_OBJECT_X(result);
8148 return Nuitka_CheckFunctionResult(tstate, called, result);
8151 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
8153 if (unlikely(flags & METH_NOARGS)) {
8154 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (10 given)",
8155 ((PyCFunctionObject *)called)->m_ml->ml_name);
8157 }
else if (unlikely(flags & METH_O)) {
8158 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (10 given)",
8159 ((PyCFunctionObject *)called)->m_ml->ml_name);
8161 }
else if (flags & METH_VARARGS) {
8164#ifdef _NUITKA_FULL_COMPAT
8165 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8169 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8170 PyObject *self = PyCFunction_GET_SELF(called);
8174#if PYTHON_VERSION < 0x360
8175 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8176 if (flags & METH_KEYWORDS) {
8177 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8179 result = (*method)(self, pos_args);
8182 Py_DECREF(pos_args);
8184 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
8185 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8186 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8187 Py_DECREF(pos_args);
8188 }
else if (flags == METH_FASTCALL) {
8189#if PYTHON_VERSION < 0x370
8190 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 10, NULL);
8192 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8193 result = (*(_PyCFunctionFast)method)(self, &pos_args, 10);
8194 Py_DECREF(pos_args);
8197 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8198 result = (*method)(self, pos_args);
8199 Py_DECREF(pos_args);
8203#ifdef _NUITKA_FULL_COMPAT
8204 Py_LeaveRecursiveCall();
8207 CHECK_OBJECT_X(result);
8209 return Nuitka_CheckFunctionResult(tstate, called, result);
8213#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
8214 }
else if (PyFunction_Check(called)) {
8215#if PYTHON_VERSION < 0x3b0
8216 PyObject *result = callPythonFunction(called, args, 10);
8218 PyObject *result = _PyFunction_Vectorcall(called, args, 10, NULL);
8220 CHECK_OBJECT_X(result);
8224#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
8225 }
else if (PyType_Check(called)) {
8226 PyTypeObject *type = Py_TYPE(called);
8228 if (type->tp_call == PyType_Type.tp_call) {
8229 PyTypeObject *called_type = (PyTypeObject *)(called);
8231 if (unlikely(called_type->tp_new == NULL)) {
8232 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
8236 PyObject *pos_args = NULL;
8239 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
8240 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
8241 formatCannotInstantiateAbstractClass(tstate, called_type);
8245 obj = called_type->tp_alloc(called_type, 0);
8248 pos_args = MAKE_TUPLE(tstate, args, 10);
8249 obj = called_type->tp_new(called_type, pos_args, NULL);
8252 if (likely(obj != NULL)) {
8253 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
8254 Py_DECREF(pos_args);
8259 type = Py_TYPE(obj);
8261 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
8262 if (type->tp_init == default_tp_init_wrapper) {
8263 Py_XDECREF(pos_args);
8266 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
8269 assert(init_method != NULL);
8271 bool is_compiled_function =
false;
8272 bool init_method_needs_release =
false;
8274 if (likely(init_method != NULL)) {
8275 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
8277 if (func == Nuitka_Function_Type.tp_descr_get) {
8278 is_compiled_function =
true;
8279 }
else if (func != NULL) {
8280 init_method = func(init_method, obj, (PyObject *)(type));
8281 init_method_needs_release =
true;
8285 if (unlikely(init_method == NULL)) {
8286 if (!HAS_ERROR_OCCURRED(tstate)) {
8287 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
8288 const_str_plain___init__);
8295 if (is_compiled_function) {
8296 result = Nuitka_CallMethodFunctionPosArgs(
8299 result = CALL_FUNCTION_WITH_ARGS10(tstate, init_method, args);
8300 if (init_method_needs_release) {
8301 Py_DECREF(init_method);
8305 if (unlikely(result == NULL)) {
8312 if (unlikely(result != Py_None)) {
8315 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
8319 if (pos_args == NULL) {
8320 pos_args = MAKE_TUPLE(tstate, args, 10);
8323 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
8325 Py_XDECREF(pos_args);
8332 Py_XDECREF(pos_args);
8334 CHECK_OBJECT_X(obj);
8339#if PYTHON_VERSION < 0x300
8340 }
else if (PyClass_Check(called)) {
8341 PyObject *obj = PyInstance_NewRaw(called, NULL);
8343 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
8345 if (unlikely(init_method == NULL)) {
8346 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
8353 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
8357 bool is_compiled_function =
false;
8359 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
8361 if (descr_get == NULL) {
8362 Py_INCREF(init_method);
8363 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
8364 is_compiled_function =
true;
8365 }
else if (descr_get != NULL) {
8366 PyObject *descr_method = descr_get(init_method, obj, called);
8368 if (unlikely(descr_method == NULL)) {
8372 init_method = descr_method;
8376 if (is_compiled_function) {
8377 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
8380 result = CALL_FUNCTION_WITH_ARGS10(tstate, init_method, args);
8381 Py_DECREF(init_method);
8383 if (unlikely(result == NULL)) {
8389 if (unlikely(result != Py_None)) {
8390 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
8394 CHECK_OBJECT_X(obj);
8398#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8399 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8400 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8402 if (likely(func != NULL)) {
8403 PyObject *result = func(called, args, 10, NULL);
8405 CHECK_OBJECT_X(result);
8407 return Nuitka_CheckFunctionResult(tstate, called, result);
8414 PRINT_STRING(
"FALLBACK");
8419 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8421 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
8423 Py_DECREF(pos_args);
8425 CHECK_OBJECT_X(result);
8429PyObject *CALL_FUNCTION_WITH_POS_ARGS10(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
8430 assert(PyTuple_CheckExact(pos_args));
8431 assert(PyTuple_GET_SIZE(pos_args) == 10);
8432 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
8433 CHECK_OBJECT(called);
8434 CHECK_OBJECTS(args, 10);
8436 if (Nuitka_Function_Check(called)) {
8437 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8444 if (function->m_args_simple && 10 == function->m_args_positional_count) {
8445 for (Py_ssize_t i = 0; i < 10; i++) {
8448 result = function->m_c_code(tstate, function, (PyObject **)args);
8449 }
else if (function->m_args_simple && 10 + function->m_defaults_given == function->m_args_positional_count) {
8450 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8452 memcpy(python_pars, args, 10 *
sizeof(PyObject *));
8453 memcpy(python_pars + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8454 function->m_defaults_given *
sizeof(PyObject *));
8456 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
8457 Py_INCREF(python_pars[i]);
8460 result = function->m_c_code(tstate, function, python_pars);
8462 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 10);
8465 Py_LeaveRecursiveCall();
8467 CHECK_OBJECT_X(result);
8470 }
else if (Nuitka_Method_Check(called)) {
8473 if (method->m_object == NULL) {
8474 PyObject *self = args[0];
8476 int res = PyObject_IsInstance(self, method->m_class);
8478 if (unlikely(res < 0)) {
8480 }
else if (unlikely(res == 0)) {
8481 PyErr_Format(PyExc_TypeError,
8482 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
8483 "instance instead)",
8484 GET_CALLABLE_NAME((PyObject *)method->m_function),
8485 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
8486 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
8491 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 10);
8493 CHECK_OBJECT_X(result);
8497 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8505 if (function->m_args_simple && 10 + 1 == function->m_args_positional_count) {
8506 PyObject *python_pars[10 + 1];
8508 python_pars[0] = method->m_object;
8509 Py_INCREF(method->m_object);
8511 for (Py_ssize_t i = 0; i < 10; i++) {
8512 python_pars[i + 1] = args[i];
8515 result = function->m_c_code(tstate, function, python_pars);
8516 }
else if (function->m_args_simple &&
8517 10 + 1 + function->m_defaults_given == function->m_args_positional_count) {
8518 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8520 python_pars[0] = method->m_object;
8521 Py_INCREF(method->m_object);
8523 memcpy(python_pars + 1, args, 10 *
sizeof(PyObject *));
8524 memcpy(python_pars + 1 + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8525 function->m_defaults_given *
sizeof(PyObject *));
8527 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
8528 Py_INCREF(python_pars[i]);
8531 result = function->m_c_code(tstate, function, python_pars);
8533 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 10);
8536 Py_LeaveRecursiveCall();
8538 CHECK_OBJECT_X(result);
8542#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
8543 }
else if (PyCFunction_CheckExact(called)) {
8544#if PYTHON_VERSION >= 0x380
8545#ifdef _NUITKA_FULL_COMPAT
8546 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8551 int flags = PyCFunction_GET_FLAGS(called);
8555 if (!(flags & METH_VARARGS)) {
8556 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8558 assert(func != NULL);
8559 result = func(called, args, 10, NULL);
8561 CHECK_OBJECT_X(result);
8563 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8564 PyObject *self = PyCFunction_GET_SELF(called);
8566 if (flags & METH_KEYWORDS) {
8567 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
8569 result = (*method)(self, pos_args);
8573#ifdef _NUITKA_FULL_COMPAT
8574 Py_LeaveRecursiveCall();
8576 CHECK_OBJECT_X(result);
8578 return Nuitka_CheckFunctionResult(tstate, called, result);
8581 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
8583 if (unlikely(flags & METH_NOARGS)) {
8584 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (10 given)",
8585 ((PyCFunctionObject *)called)->m_ml->ml_name);
8587 }
else if (unlikely(flags & METH_O)) {
8588 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (10 given)",
8589 ((PyCFunctionObject *)called)->m_ml->ml_name);
8591 }
else if (flags & METH_VARARGS) {
8594#ifdef _NUITKA_FULL_COMPAT
8595 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8599 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8600 PyObject *self = PyCFunction_GET_SELF(called);
8604#if PYTHON_VERSION < 0x360
8605 if (flags & METH_KEYWORDS) {
8606 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8608 result = (*method)(self, pos_args);
8612 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
8613 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8614 }
else if (flags == METH_FASTCALL) {
8615#if PYTHON_VERSION < 0x370
8616 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 10, NULL);
8618 result = (*(_PyCFunctionFast)method)(self, &pos_args, 10);
8621 result = (*method)(self, pos_args);
8625#ifdef _NUITKA_FULL_COMPAT
8626 Py_LeaveRecursiveCall();
8629 CHECK_OBJECT_X(result);
8631 return Nuitka_CheckFunctionResult(tstate, called, result);
8635#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
8636 }
else if (PyFunction_Check(called)) {
8637#if PYTHON_VERSION < 0x3b0
8638 PyObject *result = callPythonFunction(called, args, 10);
8640 PyObject *result = _PyFunction_Vectorcall(called, args, 10, NULL);
8642 CHECK_OBJECT_X(result);
8646#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
8647 }
else if (PyType_Check(called)) {
8648 PyTypeObject *type = Py_TYPE(called);
8650 if (type->tp_call == PyType_Type.tp_call) {
8651 PyTypeObject *called_type = (PyTypeObject *)(called);
8653 if (unlikely(called_type->tp_new == NULL)) {
8654 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
8660 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
8661 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
8662 formatCannotInstantiateAbstractClass(tstate, called_type);
8666 obj = called_type->tp_alloc(called_type, 0);
8669 obj = called_type->tp_new(called_type, pos_args, NULL);
8672 if (likely(obj != NULL)) {
8673 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
8678 type = Py_TYPE(obj);
8680 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
8681 if (type->tp_init == default_tp_init_wrapper) {
8683 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
8686 assert(init_method != NULL);
8688 bool is_compiled_function =
false;
8689 bool init_method_needs_release =
false;
8691 if (likely(init_method != NULL)) {
8692 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
8694 if (func == Nuitka_Function_Type.tp_descr_get) {
8695 is_compiled_function =
true;
8696 }
else if (func != NULL) {
8697 init_method = func(init_method, obj, (PyObject *)(type));
8698 init_method_needs_release =
true;
8702 if (unlikely(init_method == NULL)) {
8703 if (!HAS_ERROR_OCCURRED(tstate)) {
8704 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
8705 const_str_plain___init__);
8712 if (is_compiled_function) {
8713 result = Nuitka_CallMethodFunctionPosArgs(
8716 result = CALL_FUNCTION_WITH_POS_ARGS10(tstate, init_method, pos_args);
8717 if (init_method_needs_release) {
8718 Py_DECREF(init_method);
8722 if (unlikely(result == NULL)) {
8729 if (unlikely(result != Py_None)) {
8732 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
8737 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
8745 CHECK_OBJECT_X(obj);
8750#if PYTHON_VERSION < 0x300
8751 }
else if (PyClass_Check(called)) {
8752 PyObject *obj = PyInstance_NewRaw(called, NULL);
8754 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
8756 if (unlikely(init_method == NULL)) {
8757 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
8764 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
8768 bool is_compiled_function =
false;
8770 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
8772 if (descr_get == NULL) {
8773 Py_INCREF(init_method);
8774 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
8775 is_compiled_function =
true;
8776 }
else if (descr_get != NULL) {
8777 PyObject *descr_method = descr_get(init_method, obj, called);
8779 if (unlikely(descr_method == NULL)) {
8783 init_method = descr_method;
8787 if (is_compiled_function) {
8788 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
8791 result = CALL_FUNCTION_WITH_POS_ARGS10(tstate, init_method, pos_args);
8792 Py_DECREF(init_method);
8794 if (unlikely(result == NULL)) {
8800 if (unlikely(result != Py_None)) {
8801 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
8805 CHECK_OBJECT_X(obj);
8809#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8810 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8811 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8813 if (likely(func != NULL)) {
8814 PyObject *result = func(called, args, 10, NULL);
8816 CHECK_OBJECT_X(result);
8818 return Nuitka_CheckFunctionResult(tstate, called, result);
8825 PRINT_STRING(
"FALLBACK");
8830 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
8832 CHECK_OBJECT_X(result);
8836PyObject *CALL_FUNCTION_WITH_NO_ARGS_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *kw_values,
8837 PyObject *kw_names) {
8839 CHECK_OBJECT(kw_names);
8840 assert(PyTuple_CheckExact(kw_names));
8841 CHECK_OBJECT(called);
8843 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
8845 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
8847 if (Nuitka_Function_Check(called)) {
8848 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8854 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, NULL, 0, kw_values, kw_names);
8856 Py_LeaveRecursiveCall();
8858 CHECK_OBJECT_X(result);
8861#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8862 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8863 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8865 if (likely(func != NULL)) {
8866 PyObject *result = func(called, kw_values, 0, kw_names);
8868 CHECK_OBJECT_X(result);
8870 return Nuitka_CheckFunctionResult(tstate, called, result);
8876 PRINT_STRING(
"FALLBACK");
8881 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
8883 if (unlikely(call_slot == NULL)) {
8884 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
8889 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8893 PyObject *pos_args = const_tuple_empty;
8895 PyObject *named_args = _PyDict_NewPresized(nkwargs);
8897 for (Py_ssize_t i = 0; i < nkwargs; i++) {
8898 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
8900 PyObject *value = kw_values[i];
8903 CHECK_OBJECT(value);
8905 DICT_SET_ITEM(named_args, key, value);
8908 PyObject *result = (*call_slot)(called, pos_args, named_args);
8910 Py_DECREF(named_args);
8912 Py_LeaveRecursiveCall();
8914 CHECK_OBJECT_X(result);
8916 return Nuitka_CheckFunctionResult(tstate, called, result);
8918PyObject *CALL_FUNCTION_WITH_ARGS1_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
8919 PyObject *kw_names) {
8920 CHECK_OBJECTS(args, 1);
8921 CHECK_OBJECT(kw_names);
8922 assert(PyTuple_CheckExact(kw_names));
8923 CHECK_OBJECT(called);
8925 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
8927 CHECK_OBJECTS(&args[1], nkwargs);
8929 if (Nuitka_Function_Check(called)) {
8930 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8937 Nuitka_CallFunctionVectorcall(tstate, function, args, 1, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
8939 Py_LeaveRecursiveCall();
8941 CHECK_OBJECT_X(result);
8944#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8945 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8946 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8948 if (likely(func != NULL)) {
8949 PyObject *result = func(called, args, 1, kw_names);
8951 CHECK_OBJECT_X(result);
8953 return Nuitka_CheckFunctionResult(tstate, called, result);
8959 PRINT_STRING(
"FALLBACK");
8964 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
8966 if (unlikely(call_slot == NULL)) {
8967 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
8972 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8976 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
8978 PyObject *named_args = _PyDict_NewPresized(nkwargs);
8980 for (Py_ssize_t i = 0; i < nkwargs; i++) {
8981 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
8983 PyObject *value = args[1 + i];
8986 CHECK_OBJECT(value);
8988 DICT_SET_ITEM(named_args, key, value);
8991 PyObject *result = (*call_slot)(called, pos_args, named_args);
8993 Py_DECREF(pos_args);
8994 Py_DECREF(named_args);
8996 Py_LeaveRecursiveCall();
8998 CHECK_OBJECT_X(result);
9000 return Nuitka_CheckFunctionResult(tstate, called, result);
9002PyObject *CALL_FUNCTION_WITH_ARGS1_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9003 PyObject *
const *kw_values, PyObject *kw_names) {
9004 CHECK_OBJECTS(args, 1);
9005 CHECK_OBJECT(kw_names);
9006 assert(PyTuple_CheckExact(kw_names));
9007 CHECK_OBJECT(called);
9009 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9011 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9013 if (Nuitka_Function_Check(called)) {
9014 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9020 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 1, kw_values, kw_names);
9022 Py_LeaveRecursiveCall();
9024 CHECK_OBJECT_X(result);
9027#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9028 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9029 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9031 if (likely(func != NULL)) {
9032 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 1 + nkwargs);
9034 memcpy(vectorcall_args, args, 1 *
sizeof(PyObject *));
9035 memcpy(&vectorcall_args[1], kw_values, nkwargs *
sizeof(PyObject *));
9037 PyObject *result = func(called, vectorcall_args, 1, kw_names);
9039 CHECK_OBJECT_X(result);
9041 return Nuitka_CheckFunctionResult(tstate, called, result);
9047 PRINT_STRING(
"FALLBACK");
9052 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9054 if (unlikely(call_slot == NULL)) {
9055 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9060 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9064 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
9066 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9068 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9069 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9071 PyObject *value = kw_values[i];
9074 CHECK_OBJECT(value);
9076 DICT_SET_ITEM(named_args, key, value);
9079 PyObject *result = (*call_slot)(called, pos_args, named_args);
9081 Py_DECREF(pos_args);
9082 Py_DECREF(named_args);
9084 Py_LeaveRecursiveCall();
9086 CHECK_OBJECT_X(result);
9088 return Nuitka_CheckFunctionResult(tstate, called, result);
9090PyObject *CALL_FUNCTION_WITH_POS_ARGS1_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9091 PyObject *
const *kw_values, PyObject *kw_names) {
9092 assert(PyTuple_CheckExact(pos_args));
9093 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
9094 CHECK_OBJECTS(args, 1);
9095 CHECK_OBJECT(kw_names);
9096 assert(PyTuple_CheckExact(kw_names));
9097 CHECK_OBJECT(called);
9099 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9101 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9103 if (Nuitka_Function_Check(called)) {
9104 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9110 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 1, kw_values, kw_names);
9112 Py_LeaveRecursiveCall();
9114 CHECK_OBJECT_X(result);
9117#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9118 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9119 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9121 if (likely(func != NULL)) {
9122 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 1 + nkwargs);
9124 memcpy(vectorcall_args, args, 1 *
sizeof(PyObject *));
9125 memcpy(&vectorcall_args[1], kw_values, nkwargs *
sizeof(PyObject *));
9127 PyObject *result = func(called, vectorcall_args, 1, kw_names);
9129 CHECK_OBJECT_X(result);
9131 return Nuitka_CheckFunctionResult(tstate, called, result);
9137 PRINT_STRING(
"FALLBACK");
9142 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9144 if (unlikely(call_slot == NULL)) {
9145 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9150 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9154 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9156 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9157 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9159 PyObject *value = kw_values[i];
9162 CHECK_OBJECT(value);
9164 DICT_SET_ITEM(named_args, key, value);
9167 PyObject *result = (*call_slot)(called, pos_args, named_args);
9169 Py_DECREF(named_args);
9171 Py_LeaveRecursiveCall();
9173 CHECK_OBJECT_X(result);
9175 return Nuitka_CheckFunctionResult(tstate, called, result);
9177PyObject *CALL_FUNCTION_WITH_ARGS2_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9178 PyObject *kw_names) {
9179 CHECK_OBJECTS(args, 2);
9180 CHECK_OBJECT(kw_names);
9181 assert(PyTuple_CheckExact(kw_names));
9182 CHECK_OBJECT(called);
9184 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9186 CHECK_OBJECTS(&args[2], nkwargs);
9188 if (Nuitka_Function_Check(called)) {
9189 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9196 Nuitka_CallFunctionVectorcall(tstate, function, args, 2, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
9198 Py_LeaveRecursiveCall();
9200 CHECK_OBJECT_X(result);
9203#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9204 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9205 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9207 if (likely(func != NULL)) {
9208 PyObject *result = func(called, args, 2, kw_names);
9210 CHECK_OBJECT_X(result);
9212 return Nuitka_CheckFunctionResult(tstate, called, result);
9218 PRINT_STRING(
"FALLBACK");
9223 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9225 if (unlikely(call_slot == NULL)) {
9226 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9231 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9235 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
9237 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9239 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9240 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9242 PyObject *value = args[2 + i];
9245 CHECK_OBJECT(value);
9247 DICT_SET_ITEM(named_args, key, value);
9250 PyObject *result = (*call_slot)(called, pos_args, named_args);
9252 Py_DECREF(pos_args);
9253 Py_DECREF(named_args);
9255 Py_LeaveRecursiveCall();
9257 CHECK_OBJECT_X(result);
9259 return Nuitka_CheckFunctionResult(tstate, called, result);
9261PyObject *CALL_FUNCTION_WITH_ARGS2_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9262 PyObject *
const *kw_values, PyObject *kw_names) {
9263 CHECK_OBJECTS(args, 2);
9264 CHECK_OBJECT(kw_names);
9265 assert(PyTuple_CheckExact(kw_names));
9266 CHECK_OBJECT(called);
9268 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9270 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9272 if (Nuitka_Function_Check(called)) {
9273 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9279 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 2, kw_values, kw_names);
9281 Py_LeaveRecursiveCall();
9283 CHECK_OBJECT_X(result);
9286#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9287 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9288 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9290 if (likely(func != NULL)) {
9291 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 2 + nkwargs);
9293 memcpy(vectorcall_args, args, 2 *
sizeof(PyObject *));
9294 memcpy(&vectorcall_args[2], kw_values, nkwargs *
sizeof(PyObject *));
9296 PyObject *result = func(called, vectorcall_args, 2, kw_names);
9298 CHECK_OBJECT_X(result);
9300 return Nuitka_CheckFunctionResult(tstate, called, result);
9306 PRINT_STRING(
"FALLBACK");
9311 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9313 if (unlikely(call_slot == NULL)) {
9314 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9319 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9323 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
9325 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9327 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9328 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9330 PyObject *value = kw_values[i];
9333 CHECK_OBJECT(value);
9335 DICT_SET_ITEM(named_args, key, value);
9338 PyObject *result = (*call_slot)(called, pos_args, named_args);
9340 Py_DECREF(pos_args);
9341 Py_DECREF(named_args);
9343 Py_LeaveRecursiveCall();
9345 CHECK_OBJECT_X(result);
9347 return Nuitka_CheckFunctionResult(tstate, called, result);
9349PyObject *CALL_FUNCTION_WITH_POS_ARGS2_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9350 PyObject *
const *kw_values, PyObject *kw_names) {
9351 assert(PyTuple_CheckExact(pos_args));
9352 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
9353 CHECK_OBJECTS(args, 2);
9354 CHECK_OBJECT(kw_names);
9355 assert(PyTuple_CheckExact(kw_names));
9356 CHECK_OBJECT(called);
9358 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9360 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9362 if (Nuitka_Function_Check(called)) {
9363 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9369 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 2, kw_values, kw_names);
9371 Py_LeaveRecursiveCall();
9373 CHECK_OBJECT_X(result);
9376#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9377 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9378 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9380 if (likely(func != NULL)) {
9381 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 2 + nkwargs);
9383 memcpy(vectorcall_args, args, 2 *
sizeof(PyObject *));
9384 memcpy(&vectorcall_args[2], kw_values, nkwargs *
sizeof(PyObject *));
9386 PyObject *result = func(called, vectorcall_args, 2, kw_names);
9388 CHECK_OBJECT_X(result);
9390 return Nuitka_CheckFunctionResult(tstate, called, result);
9396 PRINT_STRING(
"FALLBACK");
9401 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9403 if (unlikely(call_slot == NULL)) {
9404 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9409 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9413 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9415 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9416 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9418 PyObject *value = kw_values[i];
9421 CHECK_OBJECT(value);
9423 DICT_SET_ITEM(named_args, key, value);
9426 PyObject *result = (*call_slot)(called, pos_args, named_args);
9428 Py_DECREF(named_args);
9430 Py_LeaveRecursiveCall();
9432 CHECK_OBJECT_X(result);
9434 return Nuitka_CheckFunctionResult(tstate, called, result);
9436PyObject *CALL_FUNCTION_WITH_ARGS3_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9437 PyObject *kw_names) {
9438 CHECK_OBJECTS(args, 3);
9439 CHECK_OBJECT(kw_names);
9440 assert(PyTuple_CheckExact(kw_names));
9441 CHECK_OBJECT(called);
9443 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9445 CHECK_OBJECTS(&args[3], nkwargs);
9447 if (Nuitka_Function_Check(called)) {
9448 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9455 Nuitka_CallFunctionVectorcall(tstate, function, args, 3, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
9457 Py_LeaveRecursiveCall();
9459 CHECK_OBJECT_X(result);
9462#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9463 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9464 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9466 if (likely(func != NULL)) {
9467 PyObject *result = func(called, args, 3, kw_names);
9469 CHECK_OBJECT_X(result);
9471 return Nuitka_CheckFunctionResult(tstate, called, result);
9477 PRINT_STRING(
"FALLBACK");
9482 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9484 if (unlikely(call_slot == NULL)) {
9485 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9490 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9494 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
9496 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9498 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9499 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9501 PyObject *value = args[3 + i];
9504 CHECK_OBJECT(value);
9506 DICT_SET_ITEM(named_args, key, value);
9509 PyObject *result = (*call_slot)(called, pos_args, named_args);
9511 Py_DECREF(pos_args);
9512 Py_DECREF(named_args);
9514 Py_LeaveRecursiveCall();
9516 CHECK_OBJECT_X(result);
9518 return Nuitka_CheckFunctionResult(tstate, called, result);
9520PyObject *CALL_FUNCTION_WITH_ARGS3_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9521 PyObject *
const *kw_values, PyObject *kw_names) {
9522 CHECK_OBJECTS(args, 3);
9523 CHECK_OBJECT(kw_names);
9524 assert(PyTuple_CheckExact(kw_names));
9525 CHECK_OBJECT(called);
9527 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9529 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9531 if (Nuitka_Function_Check(called)) {
9532 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9538 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 3, kw_values, kw_names);
9540 Py_LeaveRecursiveCall();
9542 CHECK_OBJECT_X(result);
9545#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9546 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9547 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9549 if (likely(func != NULL)) {
9550 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 3 + nkwargs);
9552 memcpy(vectorcall_args, args, 3 *
sizeof(PyObject *));
9553 memcpy(&vectorcall_args[3], kw_values, nkwargs *
sizeof(PyObject *));
9555 PyObject *result = func(called, vectorcall_args, 3, kw_names);
9557 CHECK_OBJECT_X(result);
9559 return Nuitka_CheckFunctionResult(tstate, called, result);
9565 PRINT_STRING(
"FALLBACK");
9570 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9572 if (unlikely(call_slot == NULL)) {
9573 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9578 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9582 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
9584 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9586 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9587 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9589 PyObject *value = kw_values[i];
9592 CHECK_OBJECT(value);
9594 DICT_SET_ITEM(named_args, key, value);
9597 PyObject *result = (*call_slot)(called, pos_args, named_args);
9599 Py_DECREF(pos_args);
9600 Py_DECREF(named_args);
9602 Py_LeaveRecursiveCall();
9604 CHECK_OBJECT_X(result);
9606 return Nuitka_CheckFunctionResult(tstate, called, result);
9608PyObject *CALL_FUNCTION_WITH_POS_ARGS3_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9609 PyObject *
const *kw_values, PyObject *kw_names) {
9610 assert(PyTuple_CheckExact(pos_args));
9611 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
9612 CHECK_OBJECTS(args, 3);
9613 CHECK_OBJECT(kw_names);
9614 assert(PyTuple_CheckExact(kw_names));
9615 CHECK_OBJECT(called);
9617 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9619 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9621 if (Nuitka_Function_Check(called)) {
9622 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9628 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 3, kw_values, kw_names);
9630 Py_LeaveRecursiveCall();
9632 CHECK_OBJECT_X(result);
9635#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9636 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9637 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9639 if (likely(func != NULL)) {
9640 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 3 + nkwargs);
9642 memcpy(vectorcall_args, args, 3 *
sizeof(PyObject *));
9643 memcpy(&vectorcall_args[3], kw_values, nkwargs *
sizeof(PyObject *));
9645 PyObject *result = func(called, vectorcall_args, 3, kw_names);
9647 CHECK_OBJECT_X(result);
9649 return Nuitka_CheckFunctionResult(tstate, called, result);
9655 PRINT_STRING(
"FALLBACK");
9660 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9662 if (unlikely(call_slot == NULL)) {
9663 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9668 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9672 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9674 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9675 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9677 PyObject *value = kw_values[i];
9680 CHECK_OBJECT(value);
9682 DICT_SET_ITEM(named_args, key, value);
9685 PyObject *result = (*call_slot)(called, pos_args, named_args);
9687 Py_DECREF(named_args);
9689 Py_LeaveRecursiveCall();
9691 CHECK_OBJECT_X(result);
9693 return Nuitka_CheckFunctionResult(tstate, called, result);
9695PyObject *CALL_FUNCTION_WITH_ARGS4_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9696 PyObject *kw_names) {
9697 CHECK_OBJECTS(args, 4);
9698 CHECK_OBJECT(kw_names);
9699 assert(PyTuple_CheckExact(kw_names));
9700 CHECK_OBJECT(called);
9702 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9704 CHECK_OBJECTS(&args[4], nkwargs);
9706 if (Nuitka_Function_Check(called)) {
9707 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9714 Nuitka_CallFunctionVectorcall(tstate, function, args, 4, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
9716 Py_LeaveRecursiveCall();
9718 CHECK_OBJECT_X(result);
9721#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9722 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9723 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9725 if (likely(func != NULL)) {
9726 PyObject *result = func(called, args, 4, kw_names);
9728 CHECK_OBJECT_X(result);
9730 return Nuitka_CheckFunctionResult(tstate, called, result);
9736 PRINT_STRING(
"FALLBACK");
9741 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9743 if (unlikely(call_slot == NULL)) {
9744 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9749 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9753 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
9755 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9757 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9758 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9760 PyObject *value = args[4 + i];
9763 CHECK_OBJECT(value);
9765 DICT_SET_ITEM(named_args, key, value);
9768 PyObject *result = (*call_slot)(called, pos_args, named_args);
9770 Py_DECREF(pos_args);
9771 Py_DECREF(named_args);
9773 Py_LeaveRecursiveCall();
9775 CHECK_OBJECT_X(result);
9777 return Nuitka_CheckFunctionResult(tstate, called, result);
9779PyObject *CALL_FUNCTION_WITH_ARGS4_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9780 PyObject *
const *kw_values, PyObject *kw_names) {
9781 CHECK_OBJECTS(args, 4);
9782 CHECK_OBJECT(kw_names);
9783 assert(PyTuple_CheckExact(kw_names));
9784 CHECK_OBJECT(called);
9786 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9788 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9790 if (Nuitka_Function_Check(called)) {
9791 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9797 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 4, kw_values, kw_names);
9799 Py_LeaveRecursiveCall();
9801 CHECK_OBJECT_X(result);
9804#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9805 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9806 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9808 if (likely(func != NULL)) {
9809 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 4 + nkwargs);
9811 memcpy(vectorcall_args, args, 4 *
sizeof(PyObject *));
9812 memcpy(&vectorcall_args[4], kw_values, nkwargs *
sizeof(PyObject *));
9814 PyObject *result = func(called, vectorcall_args, 4, kw_names);
9816 CHECK_OBJECT_X(result);
9818 return Nuitka_CheckFunctionResult(tstate, called, result);
9824 PRINT_STRING(
"FALLBACK");
9829 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9831 if (unlikely(call_slot == NULL)) {
9832 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9837 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9841 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
9843 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9845 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9846 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9848 PyObject *value = kw_values[i];
9851 CHECK_OBJECT(value);
9853 DICT_SET_ITEM(named_args, key, value);
9856 PyObject *result = (*call_slot)(called, pos_args, named_args);
9858 Py_DECREF(pos_args);
9859 Py_DECREF(named_args);
9861 Py_LeaveRecursiveCall();
9863 CHECK_OBJECT_X(result);
9865 return Nuitka_CheckFunctionResult(tstate, called, result);
9867PyObject *CALL_FUNCTION_WITH_POS_ARGS4_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9868 PyObject *
const *kw_values, PyObject *kw_names) {
9869 assert(PyTuple_CheckExact(pos_args));
9870 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
9871 CHECK_OBJECTS(args, 4);
9872 CHECK_OBJECT(kw_names);
9873 assert(PyTuple_CheckExact(kw_names));
9874 CHECK_OBJECT(called);
9876 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9878 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9880 if (Nuitka_Function_Check(called)) {
9881 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9887 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 4, kw_values, kw_names);
9889 Py_LeaveRecursiveCall();
9891 CHECK_OBJECT_X(result);
9894#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9895 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9896 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9898 if (likely(func != NULL)) {
9899 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 4 + nkwargs);
9901 memcpy(vectorcall_args, args, 4 *
sizeof(PyObject *));
9902 memcpy(&vectorcall_args[4], kw_values, nkwargs *
sizeof(PyObject *));
9904 PyObject *result = func(called, vectorcall_args, 4, kw_names);
9906 CHECK_OBJECT_X(result);
9908 return Nuitka_CheckFunctionResult(tstate, called, result);
9914 PRINT_STRING(
"FALLBACK");
9919 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9921 if (unlikely(call_slot == NULL)) {
9922 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9927 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9931 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9933 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9934 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9936 PyObject *value = kw_values[i];
9939 CHECK_OBJECT(value);
9941 DICT_SET_ITEM(named_args, key, value);
9944 PyObject *result = (*call_slot)(called, pos_args, named_args);
9946 Py_DECREF(named_args);
9948 Py_LeaveRecursiveCall();
9950 CHECK_OBJECT_X(result);
9952 return Nuitka_CheckFunctionResult(tstate, called, result);
9954PyObject *CALL_FUNCTION_WITH_ARGS5_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9955 PyObject *kw_names) {
9956 CHECK_OBJECTS(args, 5);
9957 CHECK_OBJECT(kw_names);
9958 assert(PyTuple_CheckExact(kw_names));
9959 CHECK_OBJECT(called);
9961 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9963 CHECK_OBJECTS(&args[5], nkwargs);
9965 if (Nuitka_Function_Check(called)) {
9966 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9973 Nuitka_CallFunctionVectorcall(tstate, function, args, 5, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
9975 Py_LeaveRecursiveCall();
9977 CHECK_OBJECT_X(result);
9980#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9981 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9982 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9984 if (likely(func != NULL)) {
9985 PyObject *result = func(called, args, 5, kw_names);
9987 CHECK_OBJECT_X(result);
9989 return Nuitka_CheckFunctionResult(tstate, called, result);
9995 PRINT_STRING(
"FALLBACK");
10000 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10002 if (unlikely(call_slot == NULL)) {
10003 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10008 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10012 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
10014 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10016 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10017 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10019 PyObject *value = args[5 + i];
10022 CHECK_OBJECT(value);
10024 DICT_SET_ITEM(named_args, key, value);
10027 PyObject *result = (*call_slot)(called, pos_args, named_args);
10029 Py_DECREF(pos_args);
10030 Py_DECREF(named_args);
10032 Py_LeaveRecursiveCall();
10034 CHECK_OBJECT_X(result);
10036 return Nuitka_CheckFunctionResult(tstate, called, result);
10038PyObject *CALL_FUNCTION_WITH_ARGS5_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10039 PyObject *
const *kw_values, PyObject *kw_names) {
10040 CHECK_OBJECTS(args, 5);
10041 CHECK_OBJECT(kw_names);
10042 assert(PyTuple_CheckExact(kw_names));
10043 CHECK_OBJECT(called);
10045 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10047 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10049 if (Nuitka_Function_Check(called)) {
10050 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10056 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 5, kw_values, kw_names);
10058 Py_LeaveRecursiveCall();
10060 CHECK_OBJECT_X(result);
10063#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10064 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10065 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10067 if (likely(func != NULL)) {
10068 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 5 + nkwargs);
10070 memcpy(vectorcall_args, args, 5 *
sizeof(PyObject *));
10071 memcpy(&vectorcall_args[5], kw_values, nkwargs *
sizeof(PyObject *));
10073 PyObject *result = func(called, vectorcall_args, 5, kw_names);
10075 CHECK_OBJECT_X(result);
10077 return Nuitka_CheckFunctionResult(tstate, called, result);
10083 PRINT_STRING(
"FALLBACK");
10084 PRINT_ITEM(called);
10088 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10090 if (unlikely(call_slot == NULL)) {
10091 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10096 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10100 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
10102 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10104 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10105 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10107 PyObject *value = kw_values[i];
10110 CHECK_OBJECT(value);
10112 DICT_SET_ITEM(named_args, key, value);
10115 PyObject *result = (*call_slot)(called, pos_args, named_args);
10117 Py_DECREF(pos_args);
10118 Py_DECREF(named_args);
10120 Py_LeaveRecursiveCall();
10122 CHECK_OBJECT_X(result);
10124 return Nuitka_CheckFunctionResult(tstate, called, result);
10126PyObject *CALL_FUNCTION_WITH_POS_ARGS5_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10127 PyObject *
const *kw_values, PyObject *kw_names) {
10128 assert(PyTuple_CheckExact(pos_args));
10129 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
10130 CHECK_OBJECTS(args, 5);
10131 CHECK_OBJECT(kw_names);
10132 assert(PyTuple_CheckExact(kw_names));
10133 CHECK_OBJECT(called);
10135 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10137 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10139 if (Nuitka_Function_Check(called)) {
10140 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10146 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 5, kw_values, kw_names);
10148 Py_LeaveRecursiveCall();
10150 CHECK_OBJECT_X(result);
10153#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10154 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10155 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10157 if (likely(func != NULL)) {
10158 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 5 + nkwargs);
10160 memcpy(vectorcall_args, args, 5 *
sizeof(PyObject *));
10161 memcpy(&vectorcall_args[5], kw_values, nkwargs *
sizeof(PyObject *));
10163 PyObject *result = func(called, vectorcall_args, 5, kw_names);
10165 CHECK_OBJECT_X(result);
10167 return Nuitka_CheckFunctionResult(tstate, called, result);
10173 PRINT_STRING(
"FALLBACK");
10174 PRINT_ITEM(called);
10178 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10180 if (unlikely(call_slot == NULL)) {
10181 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10186 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10190 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10192 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10193 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10195 PyObject *value = kw_values[i];
10198 CHECK_OBJECT(value);
10200 DICT_SET_ITEM(named_args, key, value);
10203 PyObject *result = (*call_slot)(called, pos_args, named_args);
10205 Py_DECREF(named_args);
10207 Py_LeaveRecursiveCall();
10209 CHECK_OBJECT_X(result);
10211 return Nuitka_CheckFunctionResult(tstate, called, result);
10213PyObject *CALL_FUNCTION_WITH_ARGS6_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10214 PyObject *kw_names) {
10215 CHECK_OBJECTS(args, 6);
10216 CHECK_OBJECT(kw_names);
10217 assert(PyTuple_CheckExact(kw_names));
10218 CHECK_OBJECT(called);
10220 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10222 CHECK_OBJECTS(&args[6], nkwargs);
10224 if (Nuitka_Function_Check(called)) {
10225 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10232 Nuitka_CallFunctionVectorcall(tstate, function, args, 6, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
10234 Py_LeaveRecursiveCall();
10236 CHECK_OBJECT_X(result);
10239#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10240 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10241 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10243 if (likely(func != NULL)) {
10244 PyObject *result = func(called, args, 6, kw_names);
10246 CHECK_OBJECT_X(result);
10248 return Nuitka_CheckFunctionResult(tstate, called, result);
10254 PRINT_STRING(
"FALLBACK");
10255 PRINT_ITEM(called);
10259 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10261 if (unlikely(call_slot == NULL)) {
10262 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10267 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10271 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
10273 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10275 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10276 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10278 PyObject *value = args[6 + i];
10281 CHECK_OBJECT(value);
10283 DICT_SET_ITEM(named_args, key, value);
10286 PyObject *result = (*call_slot)(called, pos_args, named_args);
10288 Py_DECREF(pos_args);
10289 Py_DECREF(named_args);
10291 Py_LeaveRecursiveCall();
10293 CHECK_OBJECT_X(result);
10295 return Nuitka_CheckFunctionResult(tstate, called, result);
10297PyObject *CALL_FUNCTION_WITH_ARGS6_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10298 PyObject *
const *kw_values, PyObject *kw_names) {
10299 CHECK_OBJECTS(args, 6);
10300 CHECK_OBJECT(kw_names);
10301 assert(PyTuple_CheckExact(kw_names));
10302 CHECK_OBJECT(called);
10304 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10306 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10308 if (Nuitka_Function_Check(called)) {
10309 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10315 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 6, kw_values, kw_names);
10317 Py_LeaveRecursiveCall();
10319 CHECK_OBJECT_X(result);
10322#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10323 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10324 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10326 if (likely(func != NULL)) {
10327 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 6 + nkwargs);
10329 memcpy(vectorcall_args, args, 6 *
sizeof(PyObject *));
10330 memcpy(&vectorcall_args[6], kw_values, nkwargs *
sizeof(PyObject *));
10332 PyObject *result = func(called, vectorcall_args, 6, kw_names);
10334 CHECK_OBJECT_X(result);
10336 return Nuitka_CheckFunctionResult(tstate, called, result);
10342 PRINT_STRING(
"FALLBACK");
10343 PRINT_ITEM(called);
10347 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10349 if (unlikely(call_slot == NULL)) {
10350 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10355 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10359 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
10361 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10363 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10364 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10366 PyObject *value = kw_values[i];
10369 CHECK_OBJECT(value);
10371 DICT_SET_ITEM(named_args, key, value);
10374 PyObject *result = (*call_slot)(called, pos_args, named_args);
10376 Py_DECREF(pos_args);
10377 Py_DECREF(named_args);
10379 Py_LeaveRecursiveCall();
10381 CHECK_OBJECT_X(result);
10383 return Nuitka_CheckFunctionResult(tstate, called, result);
10385PyObject *CALL_FUNCTION_WITH_POS_ARGS6_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10386 PyObject *
const *kw_values, PyObject *kw_names) {
10387 assert(PyTuple_CheckExact(pos_args));
10388 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
10389 CHECK_OBJECTS(args, 6);
10390 CHECK_OBJECT(kw_names);
10391 assert(PyTuple_CheckExact(kw_names));
10392 CHECK_OBJECT(called);
10394 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10396 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10398 if (Nuitka_Function_Check(called)) {
10399 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10405 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 6, kw_values, kw_names);
10407 Py_LeaveRecursiveCall();
10409 CHECK_OBJECT_X(result);
10412#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10413 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10414 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10416 if (likely(func != NULL)) {
10417 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 6 + nkwargs);
10419 memcpy(vectorcall_args, args, 6 *
sizeof(PyObject *));
10420 memcpy(&vectorcall_args[6], kw_values, nkwargs *
sizeof(PyObject *));
10422 PyObject *result = func(called, vectorcall_args, 6, kw_names);
10424 CHECK_OBJECT_X(result);
10426 return Nuitka_CheckFunctionResult(tstate, called, result);
10432 PRINT_STRING(
"FALLBACK");
10433 PRINT_ITEM(called);
10437 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10439 if (unlikely(call_slot == NULL)) {
10440 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10445 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10449 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10451 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10452 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10454 PyObject *value = kw_values[i];
10457 CHECK_OBJECT(value);
10459 DICT_SET_ITEM(named_args, key, value);
10462 PyObject *result = (*call_slot)(called, pos_args, named_args);
10464 Py_DECREF(named_args);
10466 Py_LeaveRecursiveCall();
10468 CHECK_OBJECT_X(result);
10470 return Nuitka_CheckFunctionResult(tstate, called, result);
10472PyObject *CALL_FUNCTION_WITH_ARGS7_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10473 PyObject *kw_names) {
10474 CHECK_OBJECTS(args, 7);
10475 CHECK_OBJECT(kw_names);
10476 assert(PyTuple_CheckExact(kw_names));
10477 CHECK_OBJECT(called);
10479 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10481 CHECK_OBJECTS(&args[7], nkwargs);
10483 if (Nuitka_Function_Check(called)) {
10484 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10491 Nuitka_CallFunctionVectorcall(tstate, function, args, 7, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
10493 Py_LeaveRecursiveCall();
10495 CHECK_OBJECT_X(result);
10498#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10499 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10500 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10502 if (likely(func != NULL)) {
10503 PyObject *result = func(called, args, 7, kw_names);
10505 CHECK_OBJECT_X(result);
10507 return Nuitka_CheckFunctionResult(tstate, called, result);
10513 PRINT_STRING(
"FALLBACK");
10514 PRINT_ITEM(called);
10518 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10520 if (unlikely(call_slot == NULL)) {
10521 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10526 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10530 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
10532 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10534 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10535 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10537 PyObject *value = args[7 + i];
10540 CHECK_OBJECT(value);
10542 DICT_SET_ITEM(named_args, key, value);
10545 PyObject *result = (*call_slot)(called, pos_args, named_args);
10547 Py_DECREF(pos_args);
10548 Py_DECREF(named_args);
10550 Py_LeaveRecursiveCall();
10552 CHECK_OBJECT_X(result);
10554 return Nuitka_CheckFunctionResult(tstate, called, result);
10556PyObject *CALL_FUNCTION_WITH_ARGS7_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10557 PyObject *
const *kw_values, PyObject *kw_names) {
10558 CHECK_OBJECTS(args, 7);
10559 CHECK_OBJECT(kw_names);
10560 assert(PyTuple_CheckExact(kw_names));
10561 CHECK_OBJECT(called);
10563 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10565 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10567 if (Nuitka_Function_Check(called)) {
10568 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10574 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 7, kw_values, kw_names);
10576 Py_LeaveRecursiveCall();
10578 CHECK_OBJECT_X(result);
10581#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10582 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10583 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10585 if (likely(func != NULL)) {
10586 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 7 + nkwargs);
10588 memcpy(vectorcall_args, args, 7 *
sizeof(PyObject *));
10589 memcpy(&vectorcall_args[7], kw_values, nkwargs *
sizeof(PyObject *));
10591 PyObject *result = func(called, vectorcall_args, 7, kw_names);
10593 CHECK_OBJECT_X(result);
10595 return Nuitka_CheckFunctionResult(tstate, called, result);
10601 PRINT_STRING(
"FALLBACK");
10602 PRINT_ITEM(called);
10606 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10608 if (unlikely(call_slot == NULL)) {
10609 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10614 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10618 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
10620 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10622 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10623 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10625 PyObject *value = kw_values[i];
10628 CHECK_OBJECT(value);
10630 DICT_SET_ITEM(named_args, key, value);
10633 PyObject *result = (*call_slot)(called, pos_args, named_args);
10635 Py_DECREF(pos_args);
10636 Py_DECREF(named_args);
10638 Py_LeaveRecursiveCall();
10640 CHECK_OBJECT_X(result);
10642 return Nuitka_CheckFunctionResult(tstate, called, result);
10644PyObject *CALL_FUNCTION_WITH_POS_ARGS7_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10645 PyObject *
const *kw_values, PyObject *kw_names) {
10646 assert(PyTuple_CheckExact(pos_args));
10647 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
10648 CHECK_OBJECTS(args, 7);
10649 CHECK_OBJECT(kw_names);
10650 assert(PyTuple_CheckExact(kw_names));
10651 CHECK_OBJECT(called);
10653 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10655 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10657 if (Nuitka_Function_Check(called)) {
10658 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10664 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 7, kw_values, kw_names);
10666 Py_LeaveRecursiveCall();
10668 CHECK_OBJECT_X(result);
10671#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10672 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10673 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10675 if (likely(func != NULL)) {
10676 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 7 + nkwargs);
10678 memcpy(vectorcall_args, args, 7 *
sizeof(PyObject *));
10679 memcpy(&vectorcall_args[7], kw_values, nkwargs *
sizeof(PyObject *));
10681 PyObject *result = func(called, vectorcall_args, 7, kw_names);
10683 CHECK_OBJECT_X(result);
10685 return Nuitka_CheckFunctionResult(tstate, called, result);
10691 PRINT_STRING(
"FALLBACK");
10692 PRINT_ITEM(called);
10696 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10698 if (unlikely(call_slot == NULL)) {
10699 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10704 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10708 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10710 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10711 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10713 PyObject *value = kw_values[i];
10716 CHECK_OBJECT(value);
10718 DICT_SET_ITEM(named_args, key, value);
10721 PyObject *result = (*call_slot)(called, pos_args, named_args);
10723 Py_DECREF(named_args);
10725 Py_LeaveRecursiveCall();
10727 CHECK_OBJECT_X(result);
10729 return Nuitka_CheckFunctionResult(tstate, called, result);
10731PyObject *CALL_FUNCTION_WITH_ARGS8_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10732 PyObject *kw_names) {
10733 CHECK_OBJECTS(args, 8);
10734 CHECK_OBJECT(kw_names);
10735 assert(PyTuple_CheckExact(kw_names));
10736 CHECK_OBJECT(called);
10738 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10740 CHECK_OBJECTS(&args[8], nkwargs);
10742 if (Nuitka_Function_Check(called)) {
10743 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10750 Nuitka_CallFunctionVectorcall(tstate, function, args, 8, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
10752 Py_LeaveRecursiveCall();
10754 CHECK_OBJECT_X(result);
10757#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10758 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10759 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10761 if (likely(func != NULL)) {
10762 PyObject *result = func(called, args, 8, kw_names);
10764 CHECK_OBJECT_X(result);
10766 return Nuitka_CheckFunctionResult(tstate, called, result);
10772 PRINT_STRING(
"FALLBACK");
10773 PRINT_ITEM(called);
10777 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10779 if (unlikely(call_slot == NULL)) {
10780 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10785 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10789 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
10791 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10793 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10794 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10796 PyObject *value = args[8 + i];
10799 CHECK_OBJECT(value);
10801 DICT_SET_ITEM(named_args, key, value);
10804 PyObject *result = (*call_slot)(called, pos_args, named_args);
10806 Py_DECREF(pos_args);
10807 Py_DECREF(named_args);
10809 Py_LeaveRecursiveCall();
10811 CHECK_OBJECT_X(result);
10813 return Nuitka_CheckFunctionResult(tstate, called, result);
10815PyObject *CALL_FUNCTION_WITH_ARGS8_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10816 PyObject *
const *kw_values, PyObject *kw_names) {
10817 CHECK_OBJECTS(args, 8);
10818 CHECK_OBJECT(kw_names);
10819 assert(PyTuple_CheckExact(kw_names));
10820 CHECK_OBJECT(called);
10822 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10824 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10826 if (Nuitka_Function_Check(called)) {
10827 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10833 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 8, kw_values, kw_names);
10835 Py_LeaveRecursiveCall();
10837 CHECK_OBJECT_X(result);
10840#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10841 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10842 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10844 if (likely(func != NULL)) {
10845 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 8 + nkwargs);
10847 memcpy(vectorcall_args, args, 8 *
sizeof(PyObject *));
10848 memcpy(&vectorcall_args[8], kw_values, nkwargs *
sizeof(PyObject *));
10850 PyObject *result = func(called, vectorcall_args, 8, kw_names);
10852 CHECK_OBJECT_X(result);
10854 return Nuitka_CheckFunctionResult(tstate, called, result);
10860 PRINT_STRING(
"FALLBACK");
10861 PRINT_ITEM(called);
10865 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10867 if (unlikely(call_slot == NULL)) {
10868 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10873 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10877 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
10879 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10881 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10882 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10884 PyObject *value = kw_values[i];
10887 CHECK_OBJECT(value);
10889 DICT_SET_ITEM(named_args, key, value);
10892 PyObject *result = (*call_slot)(called, pos_args, named_args);
10894 Py_DECREF(pos_args);
10895 Py_DECREF(named_args);
10897 Py_LeaveRecursiveCall();
10899 CHECK_OBJECT_X(result);
10901 return Nuitka_CheckFunctionResult(tstate, called, result);
10903PyObject *CALL_FUNCTION_WITH_POS_ARGS8_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10904 PyObject *
const *kw_values, PyObject *kw_names) {
10905 assert(PyTuple_CheckExact(pos_args));
10906 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
10907 CHECK_OBJECTS(args, 8);
10908 CHECK_OBJECT(kw_names);
10909 assert(PyTuple_CheckExact(kw_names));
10910 CHECK_OBJECT(called);
10912 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10914 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10916 if (Nuitka_Function_Check(called)) {
10917 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10923 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 8, kw_values, kw_names);
10925 Py_LeaveRecursiveCall();
10927 CHECK_OBJECT_X(result);
10930#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10931 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10932 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10934 if (likely(func != NULL)) {
10935 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 8 + nkwargs);
10937 memcpy(vectorcall_args, args, 8 *
sizeof(PyObject *));
10938 memcpy(&vectorcall_args[8], kw_values, nkwargs *
sizeof(PyObject *));
10940 PyObject *result = func(called, vectorcall_args, 8, kw_names);
10942 CHECK_OBJECT_X(result);
10944 return Nuitka_CheckFunctionResult(tstate, called, result);
10950 PRINT_STRING(
"FALLBACK");
10951 PRINT_ITEM(called);
10955 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10957 if (unlikely(call_slot == NULL)) {
10958 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10963 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10967 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10969 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10970 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10972 PyObject *value = kw_values[i];
10975 CHECK_OBJECT(value);
10977 DICT_SET_ITEM(named_args, key, value);
10980 PyObject *result = (*call_slot)(called, pos_args, named_args);
10982 Py_DECREF(named_args);
10984 Py_LeaveRecursiveCall();
10986 CHECK_OBJECT_X(result);
10988 return Nuitka_CheckFunctionResult(tstate, called, result);
10990PyObject *CALL_FUNCTION_WITH_ARGS9_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10991 PyObject *kw_names) {
10992 CHECK_OBJECTS(args, 9);
10993 CHECK_OBJECT(kw_names);
10994 assert(PyTuple_CheckExact(kw_names));
10995 CHECK_OBJECT(called);
10997 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10999 CHECK_OBJECTS(&args[9], nkwargs);
11001 if (Nuitka_Function_Check(called)) {
11002 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11009 Nuitka_CallFunctionVectorcall(tstate, function, args, 9, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
11011 Py_LeaveRecursiveCall();
11013 CHECK_OBJECT_X(result);
11016#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11017 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11018 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11020 if (likely(func != NULL)) {
11021 PyObject *result = func(called, args, 9, kw_names);
11023 CHECK_OBJECT_X(result);
11025 return Nuitka_CheckFunctionResult(tstate, called, result);
11031 PRINT_STRING(
"FALLBACK");
11032 PRINT_ITEM(called);
11036 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11038 if (unlikely(call_slot == NULL)) {
11039 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11044 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11048 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
11050 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11052 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11053 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11055 PyObject *value = args[9 + i];
11058 CHECK_OBJECT(value);
11060 DICT_SET_ITEM(named_args, key, value);
11063 PyObject *result = (*call_slot)(called, pos_args, named_args);
11065 Py_DECREF(pos_args);
11066 Py_DECREF(named_args);
11068 Py_LeaveRecursiveCall();
11070 CHECK_OBJECT_X(result);
11072 return Nuitka_CheckFunctionResult(tstate, called, result);
11074PyObject *CALL_FUNCTION_WITH_ARGS9_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
11075 PyObject *
const *kw_values, PyObject *kw_names) {
11076 CHECK_OBJECTS(args, 9);
11077 CHECK_OBJECT(kw_names);
11078 assert(PyTuple_CheckExact(kw_names));
11079 CHECK_OBJECT(called);
11081 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11083 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11085 if (Nuitka_Function_Check(called)) {
11086 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11092 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 9, kw_values, kw_names);
11094 Py_LeaveRecursiveCall();
11096 CHECK_OBJECT_X(result);
11099#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11100 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11101 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11103 if (likely(func != NULL)) {
11104 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 9 + nkwargs);
11106 memcpy(vectorcall_args, args, 9 *
sizeof(PyObject *));
11107 memcpy(&vectorcall_args[9], kw_values, nkwargs *
sizeof(PyObject *));
11109 PyObject *result = func(called, vectorcall_args, 9, kw_names);
11111 CHECK_OBJECT_X(result);
11113 return Nuitka_CheckFunctionResult(tstate, called, result);
11119 PRINT_STRING(
"FALLBACK");
11120 PRINT_ITEM(called);
11124 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11126 if (unlikely(call_slot == NULL)) {
11127 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11132 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11136 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
11138 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11140 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11141 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11143 PyObject *value = kw_values[i];
11146 CHECK_OBJECT(value);
11148 DICT_SET_ITEM(named_args, key, value);
11151 PyObject *result = (*call_slot)(called, pos_args, named_args);
11153 Py_DECREF(pos_args);
11154 Py_DECREF(named_args);
11156 Py_LeaveRecursiveCall();
11158 CHECK_OBJECT_X(result);
11160 return Nuitka_CheckFunctionResult(tstate, called, result);
11162PyObject *CALL_FUNCTION_WITH_POS_ARGS9_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
11163 PyObject *
const *kw_values, PyObject *kw_names) {
11164 assert(PyTuple_CheckExact(pos_args));
11165 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
11166 CHECK_OBJECTS(args, 9);
11167 CHECK_OBJECT(kw_names);
11168 assert(PyTuple_CheckExact(kw_names));
11169 CHECK_OBJECT(called);
11171 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11173 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11175 if (Nuitka_Function_Check(called)) {
11176 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11182 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 9, kw_values, kw_names);
11184 Py_LeaveRecursiveCall();
11186 CHECK_OBJECT_X(result);
11189#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11190 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11191 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11193 if (likely(func != NULL)) {
11194 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 9 + nkwargs);
11196 memcpy(vectorcall_args, args, 9 *
sizeof(PyObject *));
11197 memcpy(&vectorcall_args[9], kw_values, nkwargs *
sizeof(PyObject *));
11199 PyObject *result = func(called, vectorcall_args, 9, kw_names);
11201 CHECK_OBJECT_X(result);
11203 return Nuitka_CheckFunctionResult(tstate, called, result);
11209 PRINT_STRING(
"FALLBACK");
11210 PRINT_ITEM(called);
11214 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11216 if (unlikely(call_slot == NULL)) {
11217 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11222 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11226 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11228 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11229 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11231 PyObject *value = kw_values[i];
11234 CHECK_OBJECT(value);
11236 DICT_SET_ITEM(named_args, key, value);
11239 PyObject *result = (*call_slot)(called, pos_args, named_args);
11241 Py_DECREF(named_args);
11243 Py_LeaveRecursiveCall();
11245 CHECK_OBJECT_X(result);
11247 return Nuitka_CheckFunctionResult(tstate, called, result);
11249PyObject *CALL_FUNCTION_WITH_ARGS10_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
11250 PyObject *kw_names) {
11251 CHECK_OBJECTS(args, 10);
11252 CHECK_OBJECT(kw_names);
11253 assert(PyTuple_CheckExact(kw_names));
11254 CHECK_OBJECT(called);
11256 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11258 CHECK_OBJECTS(&args[10], nkwargs);
11260 if (Nuitka_Function_Check(called)) {
11261 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11268 Nuitka_CallFunctionVectorcall(tstate, function, args, 10, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
11270 Py_LeaveRecursiveCall();
11272 CHECK_OBJECT_X(result);
11275#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11276 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11277 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11279 if (likely(func != NULL)) {
11280 PyObject *result = func(called, args, 10, kw_names);
11282 CHECK_OBJECT_X(result);
11284 return Nuitka_CheckFunctionResult(tstate, called, result);
11290 PRINT_STRING(
"FALLBACK");
11291 PRINT_ITEM(called);
11295 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11297 if (unlikely(call_slot == NULL)) {
11298 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11303 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11307 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
11309 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11311 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11312 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11314 PyObject *value = args[10 + i];
11317 CHECK_OBJECT(value);
11319 DICT_SET_ITEM(named_args, key, value);
11322 PyObject *result = (*call_slot)(called, pos_args, named_args);
11324 Py_DECREF(pos_args);
11325 Py_DECREF(named_args);
11327 Py_LeaveRecursiveCall();
11329 CHECK_OBJECT_X(result);
11331 return Nuitka_CheckFunctionResult(tstate, called, result);
11333PyObject *CALL_FUNCTION_WITH_ARGS10_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
11334 PyObject *
const *kw_values, PyObject *kw_names) {
11335 CHECK_OBJECTS(args, 10);
11336 CHECK_OBJECT(kw_names);
11337 assert(PyTuple_CheckExact(kw_names));
11338 CHECK_OBJECT(called);
11340 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11342 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11344 if (Nuitka_Function_Check(called)) {
11345 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11351 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 10, kw_values, kw_names);
11353 Py_LeaveRecursiveCall();
11355 CHECK_OBJECT_X(result);
11358#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11359 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11360 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11362 if (likely(func != NULL)) {
11363 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 10 + nkwargs);
11365 memcpy(vectorcall_args, args, 10 *
sizeof(PyObject *));
11366 memcpy(&vectorcall_args[10], kw_values, nkwargs *
sizeof(PyObject *));
11368 PyObject *result = func(called, vectorcall_args, 10, kw_names);
11370 CHECK_OBJECT_X(result);
11372 return Nuitka_CheckFunctionResult(tstate, called, result);
11378 PRINT_STRING(
"FALLBACK");
11379 PRINT_ITEM(called);
11383 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11385 if (unlikely(call_slot == NULL)) {
11386 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11391 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11395 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
11397 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11399 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11400 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11402 PyObject *value = kw_values[i];
11405 CHECK_OBJECT(value);
11407 DICT_SET_ITEM(named_args, key, value);
11410 PyObject *result = (*call_slot)(called, pos_args, named_args);
11412 Py_DECREF(pos_args);
11413 Py_DECREF(named_args);
11415 Py_LeaveRecursiveCall();
11417 CHECK_OBJECT_X(result);
11419 return Nuitka_CheckFunctionResult(tstate, called, result);
11421PyObject *CALL_FUNCTION_WITH_POS_ARGS10_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
11422 PyObject *
const *kw_values, PyObject *kw_names) {
11423 assert(PyTuple_CheckExact(pos_args));
11424 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
11425 CHECK_OBJECTS(args, 10);
11426 CHECK_OBJECT(kw_names);
11427 assert(PyTuple_CheckExact(kw_names));
11428 CHECK_OBJECT(called);
11430 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11432 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11434 if (Nuitka_Function_Check(called)) {
11435 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11441 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 10, kw_values, kw_names);
11443 Py_LeaveRecursiveCall();
11445 CHECK_OBJECT_X(result);
11448#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11449 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11450 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11452 if (likely(func != NULL)) {
11453 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 10 + nkwargs);
11455 memcpy(vectorcall_args, args, 10 *
sizeof(PyObject *));
11456 memcpy(&vectorcall_args[10], kw_values, nkwargs *
sizeof(PyObject *));
11458 PyObject *result = func(called, vectorcall_args, 10, kw_names);
11460 CHECK_OBJECT_X(result);
11462 return Nuitka_CheckFunctionResult(tstate, called, result);
11468 PRINT_STRING(
"FALLBACK");
11469 PRINT_ITEM(called);
11473 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11475 if (unlikely(call_slot == NULL)) {
11476 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11481 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11485 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11487 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11488 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11490 PyObject *value = kw_values[i];
11493 CHECK_OBJECT(value);
11495 DICT_SET_ITEM(named_args, key, value);
11498 PyObject *result = (*call_slot)(called, pos_args, named_args);
11500 Py_DECREF(named_args);
11502 Py_LeaveRecursiveCall();
11504 CHECK_OBJECT_X(result);
11506 return Nuitka_CheckFunctionResult(tstate, called, result);
11508PyObject *CALL_METHODDESCR_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *called, PyObject *arg) {
11509 PyObject *
const *args = &arg;
11510 CHECK_OBJECT(called);
11511 CHECK_OBJECTS(args, 1);
11513#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11514 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11515 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11516 assert(func != NULL);
11517 PyObject *result = func(called, args, 1, NULL);
11519#ifndef __NUITKA_NO_ASSERT__
11520 return Nuitka_CheckFunctionResult(tstate, called, result);
11525 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11526 PyMethodDef *method_def = called_descr->d_method;
11529 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11531 if (likely(flags & METH_NOARGS)) {
11532 PyCFunction method = method_def->ml_meth;
11533 PyObject *self = args[0];
11535 PyObject *result = (*method)(self, NULL);
11537#ifndef __NUITKA_NO_ASSERT__
11538 return Nuitka_CheckFunctionResult(tstate, called, result);
11542 }
else if ((flags & METH_O)) {
11543 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (1 given)",
11544 method_def->ml_name);
11546 }
else if (flags & METH_VARARGS) {
11547 PyCFunction method = method_def->ml_meth;
11548 PyObject *self = args[0];
11552#if PYTHON_VERSION < 0x360
11553 if (flags & METH_KEYWORDS) {
11554 result = (*(PyCFunctionWithKeywords)method)(self, const_tuple_empty, NULL);
11556 result = (*method)(self, const_tuple_empty);
11559 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11560 result = (*(PyCFunctionWithKeywords)method)(self, const_tuple_empty, NULL);
11561 }
else if (flags == METH_FASTCALL) {
11562#if PYTHON_VERSION < 0x370
11563 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 0, NULL);
11565 result = (*(_PyCFunctionFast)method)(self, &const_tuple_empty, 1);
11568 result = (*method)(self, const_tuple_empty);
11571#ifndef __NUITKA_NO_ASSERT__
11572 return Nuitka_CheckFunctionResult(tstate, called, result);
11580 PRINT_STRING(
"FALLBACK");
11581 PRINT_ITEM(called);
11585 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
11587 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11589 Py_DECREF(pos_args);
11594PyObject *CALL_METHODDESCR_WITH_ARGS2(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
11595 CHECK_OBJECT(called);
11596 CHECK_OBJECTS(args, 2);
11598#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11599 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11600 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11601 assert(func != NULL);
11602 PyObject *result = func(called, args, 2, NULL);
11604#ifndef __NUITKA_NO_ASSERT__
11605 return Nuitka_CheckFunctionResult(tstate, called, result);
11610 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11611 PyMethodDef *method_def = called_descr->d_method;
11614 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11616 if (unlikely(flags & METH_NOARGS)) {
11617 PyCFunction method = method_def->ml_meth;
11618 PyObject *self = args[0];
11620 PyObject *result = (*method)(self, NULL);
11622#ifndef __NUITKA_NO_ASSERT__
11623 return Nuitka_CheckFunctionResult(tstate, called, result);
11627 }
else if (unlikely(flags & METH_O)) {
11628 PyCFunction method = method_def->ml_meth;
11629 PyObject *self = args[0];
11631 PyObject *result = (*method)(self, args[1]);
11633#ifndef __NUITKA_NO_ASSERT__
11634 return Nuitka_CheckFunctionResult(tstate, called, result);
11638 }
else if (flags & METH_VARARGS) {
11639 PyCFunction method = method_def->ml_meth;
11640 PyObject *self = args[0];
11644#if PYTHON_VERSION < 0x360
11645 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11647 if (flags & METH_KEYWORDS) {
11648 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11650 result = (*method)(self, pos_args);
11653 Py_DECREF(pos_args);
11655 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11656 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11657 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11658 Py_DECREF(pos_args);
11659 }
else if (flags == METH_FASTCALL) {
11660#if PYTHON_VERSION < 0x370
11661 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 1, NULL);
11663 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11664 result = (*(_PyCFunctionFast)method)(self, &pos_args, 2);
11665 Py_DECREF(pos_args);
11668 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11669 result = (*method)(self, pos_args);
11670 Py_DECREF(pos_args);
11673#ifndef __NUITKA_NO_ASSERT__
11674 return Nuitka_CheckFunctionResult(tstate, called, result);
11682 PRINT_STRING(
"FALLBACK");
11683 PRINT_ITEM(called);
11687 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
11689 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11691 Py_DECREF(pos_args);
11696PyObject *CALL_METHODDESCR_WITH_ARGS3(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
11697 CHECK_OBJECT(called);
11698 CHECK_OBJECTS(args, 3);
11700#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11701 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11702 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11703 assert(func != NULL);
11704 PyObject *result = func(called, args, 3, NULL);
11706#ifndef __NUITKA_NO_ASSERT__
11707 return Nuitka_CheckFunctionResult(tstate, called, result);
11712 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11713 PyMethodDef *method_def = called_descr->d_method;
11716 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11718 if (unlikely(flags & METH_NOARGS)) {
11719 PyCFunction method = method_def->ml_meth;
11720 PyObject *self = args[0];
11722 PyObject *result = (*method)(self, NULL);
11724#ifndef __NUITKA_NO_ASSERT__
11725 return Nuitka_CheckFunctionResult(tstate, called, result);
11729 }
else if (unlikely(flags & METH_O)) {
11730 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (3 given)",
11731 method_def->ml_name);
11733 }
else if (flags & METH_VARARGS) {
11734 PyCFunction method = method_def->ml_meth;
11735 PyObject *self = args[0];
11739#if PYTHON_VERSION < 0x360
11740 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11742 if (flags & METH_KEYWORDS) {
11743 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11745 result = (*method)(self, pos_args);
11748 Py_DECREF(pos_args);
11750 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11751 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11752 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11753 Py_DECREF(pos_args);
11754 }
else if (flags == METH_FASTCALL) {
11755#if PYTHON_VERSION < 0x370
11756 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 2, NULL);
11758 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11759 result = (*(_PyCFunctionFast)method)(self, &pos_args, 3);
11760 Py_DECREF(pos_args);
11763 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11764 result = (*method)(self, pos_args);
11765 Py_DECREF(pos_args);
11768#ifndef __NUITKA_NO_ASSERT__
11769 return Nuitka_CheckFunctionResult(tstate, called, result);
11777 PRINT_STRING(
"FALLBACK");
11778 PRINT_ITEM(called);
11782 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
11784 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11786 Py_DECREF(pos_args);
11791PyObject *CALL_METHODDESCR_WITH_ARGS4(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
11792 CHECK_OBJECT(called);
11793 CHECK_OBJECTS(args, 4);
11795#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11796 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11797 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11798 assert(func != NULL);
11799 PyObject *result = func(called, args, 4, NULL);
11801#ifndef __NUITKA_NO_ASSERT__
11802 return Nuitka_CheckFunctionResult(tstate, called, result);
11807 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11808 PyMethodDef *method_def = called_descr->d_method;
11811 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11813 if (unlikely(flags & METH_NOARGS)) {
11814 PyCFunction method = method_def->ml_meth;
11815 PyObject *self = args[0];
11817 PyObject *result = (*method)(self, NULL);
11819#ifndef __NUITKA_NO_ASSERT__
11820 return Nuitka_CheckFunctionResult(tstate, called, result);
11824 }
else if (unlikely(flags & METH_O)) {
11825 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (4 given)",
11826 method_def->ml_name);
11828 }
else if (flags & METH_VARARGS) {
11829 PyCFunction method = method_def->ml_meth;
11830 PyObject *self = args[0];
11834#if PYTHON_VERSION < 0x360
11835 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11837 if (flags & METH_KEYWORDS) {
11838 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11840 result = (*method)(self, pos_args);
11843 Py_DECREF(pos_args);
11845 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11846 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11847 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11848 Py_DECREF(pos_args);
11849 }
else if (flags == METH_FASTCALL) {
11850#if PYTHON_VERSION < 0x370
11851 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 3, NULL);
11853 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11854 result = (*(_PyCFunctionFast)method)(self, &pos_args, 4);
11855 Py_DECREF(pos_args);
11858 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11859 result = (*method)(self, pos_args);
11860 Py_DECREF(pos_args);
11863#ifndef __NUITKA_NO_ASSERT__
11864 return Nuitka_CheckFunctionResult(tstate, called, result);
11872 PRINT_STRING(
"FALLBACK");
11873 PRINT_ITEM(called);
11877 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
11879 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11881 Py_DECREF(pos_args);
11886PyObject *CALL_METHOD_NO_ARGS(PyThreadState *tstate, PyObject *source, PyObject *attr_name) {
11887 CHECK_OBJECT(source);
11888 CHECK_OBJECT(attr_name);
11890 PyTypeObject *type = Py_TYPE(source);
11892 if (hasTypeGenericGetAttr(type)) {
11894 if (unlikely(type->tp_dict == NULL)) {
11895 if (unlikely(PyType_Ready(type) < 0)) {
11900 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
11901 descrgetfunc func = NULL;
11903 if (descr != NULL) {
11906 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
11907 func = Py_TYPE(descr)->tp_descr_get;
11909 if (func != NULL && Nuitka_Descr_IsData(descr)) {
11910 PyObject *called_object = func(descr, source, (PyObject *)type);
11913 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
11914 Py_DECREF(called_object);
11920 Py_ssize_t dictoffset = type->tp_dictoffset;
11921 PyObject *dict = NULL;
11923 if (dictoffset != 0) {
11925 if (dictoffset < 0) {
11929 tsize = ((PyVarObject *)source)->ob_size;
11933 size = _PyObject_VAR_SIZE(type, tsize);
11935 dictoffset += (long)size;
11938 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
11942 if (dict != NULL) {
11943 CHECK_OBJECT(dict);
11947 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
11949 if (called_object != NULL) {
11953 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
11954 Py_DECREF(called_object);
11961 if (func != NULL) {
11962 if (func == Nuitka_Function_Type.tp_descr_get) {
11969 PyObject *called_object = func(descr, source, (PyObject *)type);
11970 CHECK_OBJECT(called_object);
11974 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
11975 Py_DECREF(called_object);
11980 if (descr != NULL) {
11981 CHECK_OBJECT(descr);
11983 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, descr);
11988#if PYTHON_VERSION < 0x300
11989 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
11990 PyString_AS_STRING(attr_name));
11992 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
11996#if PYTHON_VERSION < 0x300
11997 else if (type == &PyInstance_Type) {
11998 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12002 assert(attr_name != const_str_plain___dict__);
12003 assert(attr_name != const_str_plain___class__);
12006 PyObject *called_object =
12007 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12011 if (called_object != NULL) {
12012 return CALL_FUNCTION_NO_ARGS(tstate, called_object);
12016 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12020 if (called_object != NULL) {
12021 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12023 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12024 return Nuitka_CallMethodFunctionNoArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12026 }
else if (descr_get != NULL) {
12027 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12029 if (unlikely(method == NULL)) {
12033 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, method);
12037 return CALL_FUNCTION_NO_ARGS(tstate, called_object);
12040 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12041 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12042 PyString_AS_STRING(source_instance->in_class->cl_name),
12043 PyString_AS_STRING(attr_name));
12050 PyObject *args2[] = {source, attr_name};
12052 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12054 if (unlikely(called_object == NULL)) {
12058 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
12059 Py_DECREF(called_object);
12064 else if (type->tp_getattro != NULL) {
12065 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12067 if (unlikely(descr == NULL)) {
12071 descrgetfunc func = NULL;
12072 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12073 func = Py_TYPE(descr)->tp_descr_get;
12075 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12076 PyObject *called_object = func(descr, source, (PyObject *)type);
12079 if (unlikely(called_object == NULL)) {
12083 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
12084 Py_DECREF(called_object);
12089 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, descr);
12092 }
else if (type->tp_getattr != NULL) {
12093 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12095 if (unlikely(called_object == NULL)) {
12099 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
12100 Py_DECREF(called_object);
12103 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12104 Nuitka_String_AsString_Unchecked(attr_name));
12109PyObject *CALL_METHOD_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *arg) {
12110 PyObject *
const *args = &arg;
12111 CHECK_OBJECT(source);
12112 CHECK_OBJECT(attr_name);
12114 CHECK_OBJECTS(args, 1);
12116 PyTypeObject *type = Py_TYPE(source);
12118 if (hasTypeGenericGetAttr(type)) {
12120 if (unlikely(type->tp_dict == NULL)) {
12121 if (unlikely(PyType_Ready(type) < 0)) {
12126 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12127 descrgetfunc func = NULL;
12129 if (descr != NULL) {
12132 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12133 func = Py_TYPE(descr)->tp_descr_get;
12135 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12136 PyObject *called_object = func(descr, source, (PyObject *)type);
12139 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12140 Py_DECREF(called_object);
12146 Py_ssize_t dictoffset = type->tp_dictoffset;
12147 PyObject *dict = NULL;
12149 if (dictoffset != 0) {
12151 if (dictoffset < 0) {
12155 tsize = ((PyVarObject *)source)->ob_size;
12159 size = _PyObject_VAR_SIZE(type, tsize);
12161 dictoffset += (long)size;
12164 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
12168 if (dict != NULL) {
12169 CHECK_OBJECT(dict);
12173 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12175 if (called_object != NULL) {
12179 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12180 Py_DECREF(called_object);
12187 if (func != NULL) {
12188 if (func == Nuitka_Function_Type.tp_descr_get) {
12189 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
12195 PyObject *called_object = func(descr, source, (PyObject *)type);
12196 CHECK_OBJECT(called_object);
12200 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12201 Py_DECREF(called_object);
12206 if (descr != NULL) {
12207 CHECK_OBJECT(descr);
12209 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, descr, args[0]);
12214#if PYTHON_VERSION < 0x300
12215 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12216 PyString_AS_STRING(attr_name));
12218 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
12222#if PYTHON_VERSION < 0x300
12223 else if (type == &PyInstance_Type) {
12224 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12228 assert(attr_name != const_str_plain___dict__);
12229 assert(attr_name != const_str_plain___class__);
12232 PyObject *called_object =
12233 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12237 if (called_object != NULL) {
12238 return CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12242 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12246 if (called_object != NULL) {
12247 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12249 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12250 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12252 }
else if (descr_get != NULL) {
12253 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12255 if (unlikely(method == NULL)) {
12259 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, method, args[0]);
12263 return CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12266 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12267 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12268 PyString_AS_STRING(source_instance->in_class->cl_name),
12269 PyString_AS_STRING(attr_name));
12276 PyObject *args2[] = {source, attr_name};
12278 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12280 if (unlikely(called_object == NULL)) {
12284 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12285 Py_DECREF(called_object);
12290 else if (type->tp_getattro != NULL) {
12291 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12293 if (unlikely(descr == NULL)) {
12297 descrgetfunc func = NULL;
12298 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12299 func = Py_TYPE(descr)->tp_descr_get;
12301 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12302 PyObject *called_object = func(descr, source, (PyObject *)type);
12305 if (unlikely(called_object == NULL)) {
12309 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12310 Py_DECREF(called_object);
12315 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, descr, args[0]);
12318 }
else if (type->tp_getattr != NULL) {
12319 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12321 if (unlikely(called_object == NULL)) {
12325 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12326 Py_DECREF(called_object);
12329 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12330 Nuitka_String_AsString_Unchecked(attr_name));
12335PyObject *CALL_METHOD_WITH_ARGS2(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
12336 CHECK_OBJECT(source);
12337 CHECK_OBJECT(attr_name);
12339 CHECK_OBJECTS(args, 2);
12341 PyTypeObject *type = Py_TYPE(source);
12343 if (hasTypeGenericGetAttr(type)) {
12345 if (unlikely(type->tp_dict == NULL)) {
12346 if (unlikely(PyType_Ready(type) < 0)) {
12351 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12352 descrgetfunc func = NULL;
12354 if (descr != NULL) {
12357 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12358 func = Py_TYPE(descr)->tp_descr_get;
12360 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12361 PyObject *called_object = func(descr, source, (PyObject *)type);
12364 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12365 Py_DECREF(called_object);
12371 Py_ssize_t dictoffset = type->tp_dictoffset;
12372 PyObject *dict = NULL;
12374 if (dictoffset != 0) {
12376 if (dictoffset < 0) {
12380 tsize = ((PyVarObject *)source)->ob_size;
12384 size = _PyObject_VAR_SIZE(type, tsize);
12386 dictoffset += (long)size;
12389 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
12393 if (dict != NULL) {
12394 CHECK_OBJECT(dict);
12398 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12400 if (called_object != NULL) {
12404 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12405 Py_DECREF(called_object);
12412 if (func != NULL) {
12413 if (func == Nuitka_Function_Type.tp_descr_get) {
12414 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
12420 PyObject *called_object = func(descr, source, (PyObject *)type);
12421 CHECK_OBJECT(called_object);
12425 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12426 Py_DECREF(called_object);
12431 if (descr != NULL) {
12432 CHECK_OBJECT(descr);
12434 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, descr, args);
12439#if PYTHON_VERSION < 0x300
12440 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12441 PyString_AS_STRING(attr_name));
12443 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
12447#if PYTHON_VERSION < 0x300
12448 else if (type == &PyInstance_Type) {
12449 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12453 assert(attr_name != const_str_plain___dict__);
12454 assert(attr_name != const_str_plain___class__);
12457 PyObject *called_object =
12458 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12462 if (called_object != NULL) {
12463 return CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12467 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12471 if (called_object != NULL) {
12472 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12474 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12475 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12477 }
else if (descr_get != NULL) {
12478 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12480 if (unlikely(method == NULL)) {
12484 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, method, args);
12488 return CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12491 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12492 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12493 PyString_AS_STRING(source_instance->in_class->cl_name),
12494 PyString_AS_STRING(attr_name));
12501 PyObject *args2[] = {source, attr_name};
12503 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12505 if (unlikely(called_object == NULL)) {
12509 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12510 Py_DECREF(called_object);
12515 else if (type->tp_getattro != NULL) {
12516 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12518 if (unlikely(descr == NULL)) {
12522 descrgetfunc func = NULL;
12523 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12524 func = Py_TYPE(descr)->tp_descr_get;
12526 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12527 PyObject *called_object = func(descr, source, (PyObject *)type);
12530 if (unlikely(called_object == NULL)) {
12534 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12535 Py_DECREF(called_object);
12540 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, descr, args);
12543 }
else if (type->tp_getattr != NULL) {
12544 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12546 if (unlikely(called_object == NULL)) {
12550 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12551 Py_DECREF(called_object);
12554 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12555 Nuitka_String_AsString_Unchecked(attr_name));
12560PyObject *CALL_METHOD_WITH_ARGS3(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
12561 CHECK_OBJECT(source);
12562 CHECK_OBJECT(attr_name);
12564 CHECK_OBJECTS(args, 3);
12566 PyTypeObject *type = Py_TYPE(source);
12568 if (hasTypeGenericGetAttr(type)) {
12570 if (unlikely(type->tp_dict == NULL)) {
12571 if (unlikely(PyType_Ready(type) < 0)) {
12576 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12577 descrgetfunc func = NULL;
12579 if (descr != NULL) {
12582 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12583 func = Py_TYPE(descr)->tp_descr_get;
12585 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12586 PyObject *called_object = func(descr, source, (PyObject *)type);
12589 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12590 Py_DECREF(called_object);
12596 Py_ssize_t dictoffset = type->tp_dictoffset;
12597 PyObject *dict = NULL;
12599 if (dictoffset != 0) {
12601 if (dictoffset < 0) {
12605 tsize = ((PyVarObject *)source)->ob_size;
12609 size = _PyObject_VAR_SIZE(type, tsize);
12611 dictoffset += (long)size;
12614 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
12618 if (dict != NULL) {
12619 CHECK_OBJECT(dict);
12623 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12625 if (called_object != NULL) {
12629 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12630 Py_DECREF(called_object);
12637 if (func != NULL) {
12638 if (func == Nuitka_Function_Type.tp_descr_get) {
12639 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
12645 PyObject *called_object = func(descr, source, (PyObject *)type);
12646 CHECK_OBJECT(called_object);
12650 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12651 Py_DECREF(called_object);
12656 if (descr != NULL) {
12657 CHECK_OBJECT(descr);
12659 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, descr, args);
12664#if PYTHON_VERSION < 0x300
12665 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12666 PyString_AS_STRING(attr_name));
12668 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
12672#if PYTHON_VERSION < 0x300
12673 else if (type == &PyInstance_Type) {
12674 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12678 assert(attr_name != const_str_plain___dict__);
12679 assert(attr_name != const_str_plain___class__);
12682 PyObject *called_object =
12683 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12687 if (called_object != NULL) {
12688 return CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12692 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12696 if (called_object != NULL) {
12697 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12699 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12700 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12702 }
else if (descr_get != NULL) {
12703 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12705 if (unlikely(method == NULL)) {
12709 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, method, args);
12713 return CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12716 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12717 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12718 PyString_AS_STRING(source_instance->in_class->cl_name),
12719 PyString_AS_STRING(attr_name));
12726 PyObject *args2[] = {source, attr_name};
12728 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12730 if (unlikely(called_object == NULL)) {
12734 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12735 Py_DECREF(called_object);
12740 else if (type->tp_getattro != NULL) {
12741 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12743 if (unlikely(descr == NULL)) {
12747 descrgetfunc func = NULL;
12748 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12749 func = Py_TYPE(descr)->tp_descr_get;
12751 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12752 PyObject *called_object = func(descr, source, (PyObject *)type);
12755 if (unlikely(called_object == NULL)) {
12759 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12760 Py_DECREF(called_object);
12765 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, descr, args);
12768 }
else if (type->tp_getattr != NULL) {
12769 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12771 if (unlikely(called_object == NULL)) {
12775 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12776 Py_DECREF(called_object);
12779 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12780 Nuitka_String_AsString_Unchecked(attr_name));
12785PyObject *CALL_METHOD_WITH_ARGS4(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
12786 CHECK_OBJECT(source);
12787 CHECK_OBJECT(attr_name);
12789 CHECK_OBJECTS(args, 4);
12791 PyTypeObject *type = Py_TYPE(source);
12793 if (hasTypeGenericGetAttr(type)) {
12795 if (unlikely(type->tp_dict == NULL)) {
12796 if (unlikely(PyType_Ready(type) < 0)) {
12801 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12802 descrgetfunc func = NULL;
12804 if (descr != NULL) {
12807 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12808 func = Py_TYPE(descr)->tp_descr_get;
12810 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12811 PyObject *called_object = func(descr, source, (PyObject *)type);
12814 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12815 Py_DECREF(called_object);
12821 Py_ssize_t dictoffset = type->tp_dictoffset;
12822 PyObject *dict = NULL;
12824 if (dictoffset != 0) {
12826 if (dictoffset < 0) {
12830 tsize = ((PyVarObject *)source)->ob_size;
12834 size = _PyObject_VAR_SIZE(type, tsize);
12836 dictoffset += (long)size;
12839 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
12843 if (dict != NULL) {
12844 CHECK_OBJECT(dict);
12848 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12850 if (called_object != NULL) {
12854 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12855 Py_DECREF(called_object);
12862 if (func != NULL) {
12863 if (func == Nuitka_Function_Type.tp_descr_get) {
12864 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
12870 PyObject *called_object = func(descr, source, (PyObject *)type);
12871 CHECK_OBJECT(called_object);
12875 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12876 Py_DECREF(called_object);
12881 if (descr != NULL) {
12882 CHECK_OBJECT(descr);
12884 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, descr, args);
12889#if PYTHON_VERSION < 0x300
12890 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12891 PyString_AS_STRING(attr_name));
12893 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
12897#if PYTHON_VERSION < 0x300
12898 else if (type == &PyInstance_Type) {
12899 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12903 assert(attr_name != const_str_plain___dict__);
12904 assert(attr_name != const_str_plain___class__);
12907 PyObject *called_object =
12908 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12912 if (called_object != NULL) {
12913 return CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12917 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12921 if (called_object != NULL) {
12922 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12924 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12925 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12927 }
else if (descr_get != NULL) {
12928 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12930 if (unlikely(method == NULL)) {
12934 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, method, args);
12938 return CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12941 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12942 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12943 PyString_AS_STRING(source_instance->in_class->cl_name),
12944 PyString_AS_STRING(attr_name));
12951 PyObject *args2[] = {source, attr_name};
12953 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12955 if (unlikely(called_object == NULL)) {
12959 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12960 Py_DECREF(called_object);
12965 else if (type->tp_getattro != NULL) {
12966 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12968 if (unlikely(descr == NULL)) {
12972 descrgetfunc func = NULL;
12973 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12974 func = Py_TYPE(descr)->tp_descr_get;
12976 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12977 PyObject *called_object = func(descr, source, (PyObject *)type);
12980 if (unlikely(called_object == NULL)) {
12984 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12985 Py_DECREF(called_object);
12990 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, descr, args);
12993 }
else if (type->tp_getattr != NULL) {
12994 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12996 if (unlikely(called_object == NULL)) {
13000 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
13001 Py_DECREF(called_object);
13004 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13005 Nuitka_String_AsString_Unchecked(attr_name));
13010PyObject *CALL_METHOD_WITH_ARGS5(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13011 CHECK_OBJECT(source);
13012 CHECK_OBJECT(attr_name);
13014 CHECK_OBJECTS(args, 5);
13016 PyTypeObject *type = Py_TYPE(source);
13018 if (hasTypeGenericGetAttr(type)) {
13020 if (unlikely(type->tp_dict == NULL)) {
13021 if (unlikely(PyType_Ready(type) < 0)) {
13026 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13027 descrgetfunc func = NULL;
13029 if (descr != NULL) {
13032 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13033 func = Py_TYPE(descr)->tp_descr_get;
13035 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13036 PyObject *called_object = func(descr, source, (PyObject *)type);
13039 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13040 Py_DECREF(called_object);
13046 Py_ssize_t dictoffset = type->tp_dictoffset;
13047 PyObject *dict = NULL;
13049 if (dictoffset != 0) {
13051 if (dictoffset < 0) {
13055 tsize = ((PyVarObject *)source)->ob_size;
13059 size = _PyObject_VAR_SIZE(type, tsize);
13061 dictoffset += (long)size;
13064 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13068 if (dict != NULL) {
13069 CHECK_OBJECT(dict);
13073 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13075 if (called_object != NULL) {
13079 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13080 Py_DECREF(called_object);
13087 if (func != NULL) {
13088 if (func == Nuitka_Function_Type.tp_descr_get) {
13089 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13095 PyObject *called_object = func(descr, source, (PyObject *)type);
13096 CHECK_OBJECT(called_object);
13100 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13101 Py_DECREF(called_object);
13106 if (descr != NULL) {
13107 CHECK_OBJECT(descr);
13109 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, descr, args);
13114#if PYTHON_VERSION < 0x300
13115 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13116 PyString_AS_STRING(attr_name));
13118 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
13122#if PYTHON_VERSION < 0x300
13123 else if (type == &PyInstance_Type) {
13124 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13128 assert(attr_name != const_str_plain___dict__);
13129 assert(attr_name != const_str_plain___class__);
13132 PyObject *called_object =
13133 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13137 if (called_object != NULL) {
13138 return CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13142 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13146 if (called_object != NULL) {
13147 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13149 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13150 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
13152 }
else if (descr_get != NULL) {
13153 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13155 if (unlikely(method == NULL)) {
13159 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, method, args);
13163 return CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13166 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13167 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
13168 PyString_AS_STRING(source_instance->in_class->cl_name),
13169 PyString_AS_STRING(attr_name));
13176 PyObject *args2[] = {source, attr_name};
13178 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13180 if (unlikely(called_object == NULL)) {
13184 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13185 Py_DECREF(called_object);
13190 else if (type->tp_getattro != NULL) {
13191 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13193 if (unlikely(descr == NULL)) {
13197 descrgetfunc func = NULL;
13198 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13199 func = Py_TYPE(descr)->tp_descr_get;
13201 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13202 PyObject *called_object = func(descr, source, (PyObject *)type);
13205 if (unlikely(called_object == NULL)) {
13209 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13210 Py_DECREF(called_object);
13215 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, descr, args);
13218 }
else if (type->tp_getattr != NULL) {
13219 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
13221 if (unlikely(called_object == NULL)) {
13225 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13226 Py_DECREF(called_object);
13229 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13230 Nuitka_String_AsString_Unchecked(attr_name));
13235PyObject *CALL_METHOD_WITH_ARGS6(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13236 CHECK_OBJECT(source);
13237 CHECK_OBJECT(attr_name);
13239 CHECK_OBJECTS(args, 6);
13241 PyTypeObject *type = Py_TYPE(source);
13243 if (hasTypeGenericGetAttr(type)) {
13245 if (unlikely(type->tp_dict == NULL)) {
13246 if (unlikely(PyType_Ready(type) < 0)) {
13251 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13252 descrgetfunc func = NULL;
13254 if (descr != NULL) {
13257 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13258 func = Py_TYPE(descr)->tp_descr_get;
13260 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13261 PyObject *called_object = func(descr, source, (PyObject *)type);
13264 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13265 Py_DECREF(called_object);
13271 Py_ssize_t dictoffset = type->tp_dictoffset;
13272 PyObject *dict = NULL;
13274 if (dictoffset != 0) {
13276 if (dictoffset < 0) {
13280 tsize = ((PyVarObject *)source)->ob_size;
13284 size = _PyObject_VAR_SIZE(type, tsize);
13286 dictoffset += (long)size;
13289 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13293 if (dict != NULL) {
13294 CHECK_OBJECT(dict);
13298 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13300 if (called_object != NULL) {
13304 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13305 Py_DECREF(called_object);
13312 if (func != NULL) {
13313 if (func == Nuitka_Function_Type.tp_descr_get) {
13314 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13320 PyObject *called_object = func(descr, source, (PyObject *)type);
13321 CHECK_OBJECT(called_object);
13325 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13326 Py_DECREF(called_object);
13331 if (descr != NULL) {
13332 CHECK_OBJECT(descr);
13334 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, descr, args);
13339#if PYTHON_VERSION < 0x300
13340 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13341 PyString_AS_STRING(attr_name));
13343 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
13347#if PYTHON_VERSION < 0x300
13348 else if (type == &PyInstance_Type) {
13349 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13353 assert(attr_name != const_str_plain___dict__);
13354 assert(attr_name != const_str_plain___class__);
13357 PyObject *called_object =
13358 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13362 if (called_object != NULL) {
13363 return CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13367 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13371 if (called_object != NULL) {
13372 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13374 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13375 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
13377 }
else if (descr_get != NULL) {
13378 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13380 if (unlikely(method == NULL)) {
13384 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, method, args);
13388 return CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13391 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13392 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
13393 PyString_AS_STRING(source_instance->in_class->cl_name),
13394 PyString_AS_STRING(attr_name));
13401 PyObject *args2[] = {source, attr_name};
13403 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13405 if (unlikely(called_object == NULL)) {
13409 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13410 Py_DECREF(called_object);
13415 else if (type->tp_getattro != NULL) {
13416 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13418 if (unlikely(descr == NULL)) {
13422 descrgetfunc func = NULL;
13423 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13424 func = Py_TYPE(descr)->tp_descr_get;
13426 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13427 PyObject *called_object = func(descr, source, (PyObject *)type);
13430 if (unlikely(called_object == NULL)) {
13434 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13435 Py_DECREF(called_object);
13440 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, descr, args);
13443 }
else if (type->tp_getattr != NULL) {
13444 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
13446 if (unlikely(called_object == NULL)) {
13450 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13451 Py_DECREF(called_object);
13454 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13455 Nuitka_String_AsString_Unchecked(attr_name));
13460PyObject *CALL_METHOD_WITH_ARGS7(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13461 CHECK_OBJECT(source);
13462 CHECK_OBJECT(attr_name);
13464 CHECK_OBJECTS(args, 7);
13466 PyTypeObject *type = Py_TYPE(source);
13468 if (hasTypeGenericGetAttr(type)) {
13470 if (unlikely(type->tp_dict == NULL)) {
13471 if (unlikely(PyType_Ready(type) < 0)) {
13476 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13477 descrgetfunc func = NULL;
13479 if (descr != NULL) {
13482 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13483 func = Py_TYPE(descr)->tp_descr_get;
13485 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13486 PyObject *called_object = func(descr, source, (PyObject *)type);
13489 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13490 Py_DECREF(called_object);
13496 Py_ssize_t dictoffset = type->tp_dictoffset;
13497 PyObject *dict = NULL;
13499 if (dictoffset != 0) {
13501 if (dictoffset < 0) {
13505 tsize = ((PyVarObject *)source)->ob_size;
13509 size = _PyObject_VAR_SIZE(type, tsize);
13511 dictoffset += (long)size;
13514 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13518 if (dict != NULL) {
13519 CHECK_OBJECT(dict);
13523 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13525 if (called_object != NULL) {
13529 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13530 Py_DECREF(called_object);
13537 if (func != NULL) {
13538 if (func == Nuitka_Function_Type.tp_descr_get) {
13539 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13545 PyObject *called_object = func(descr, source, (PyObject *)type);
13546 CHECK_OBJECT(called_object);
13550 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13551 Py_DECREF(called_object);
13556 if (descr != NULL) {
13557 CHECK_OBJECT(descr);
13559 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, descr, args);
13564#if PYTHON_VERSION < 0x300
13565 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13566 PyString_AS_STRING(attr_name));
13568 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
13572#if PYTHON_VERSION < 0x300
13573 else if (type == &PyInstance_Type) {
13574 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13578 assert(attr_name != const_str_plain___dict__);
13579 assert(attr_name != const_str_plain___class__);
13582 PyObject *called_object =
13583 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13587 if (called_object != NULL) {
13588 return CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13592 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13596 if (called_object != NULL) {
13597 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13599 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13600 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
13602 }
else if (descr_get != NULL) {
13603 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13605 if (unlikely(method == NULL)) {
13609 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, method, args);
13613 return CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13616 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13617 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
13618 PyString_AS_STRING(source_instance->in_class->cl_name),
13619 PyString_AS_STRING(attr_name));
13626 PyObject *args2[] = {source, attr_name};
13628 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13630 if (unlikely(called_object == NULL)) {
13634 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13635 Py_DECREF(called_object);
13640 else if (type->tp_getattro != NULL) {
13641 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13643 if (unlikely(descr == NULL)) {
13647 descrgetfunc func = NULL;
13648 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13649 func = Py_TYPE(descr)->tp_descr_get;
13651 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13652 PyObject *called_object = func(descr, source, (PyObject *)type);
13655 if (unlikely(called_object == NULL)) {
13659 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13660 Py_DECREF(called_object);
13665 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, descr, args);
13668 }
else if (type->tp_getattr != NULL) {
13669 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
13671 if (unlikely(called_object == NULL)) {
13675 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13676 Py_DECREF(called_object);
13679 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13680 Nuitka_String_AsString_Unchecked(attr_name));
13685PyObject *CALL_METHOD_WITH_ARGS8(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13686 CHECK_OBJECT(source);
13687 CHECK_OBJECT(attr_name);
13689 CHECK_OBJECTS(args, 8);
13691 PyTypeObject *type = Py_TYPE(source);
13693 if (hasTypeGenericGetAttr(type)) {
13695 if (unlikely(type->tp_dict == NULL)) {
13696 if (unlikely(PyType_Ready(type) < 0)) {
13701 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13702 descrgetfunc func = NULL;
13704 if (descr != NULL) {
13707 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13708 func = Py_TYPE(descr)->tp_descr_get;
13710 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13711 PyObject *called_object = func(descr, source, (PyObject *)type);
13714 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13715 Py_DECREF(called_object);
13721 Py_ssize_t dictoffset = type->tp_dictoffset;
13722 PyObject *dict = NULL;
13724 if (dictoffset != 0) {
13726 if (dictoffset < 0) {
13730 tsize = ((PyVarObject *)source)->ob_size;
13734 size = _PyObject_VAR_SIZE(type, tsize);
13736 dictoffset += (long)size;
13739 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13743 if (dict != NULL) {
13744 CHECK_OBJECT(dict);
13748 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13750 if (called_object != NULL) {
13754 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13755 Py_DECREF(called_object);
13762 if (func != NULL) {
13763 if (func == Nuitka_Function_Type.tp_descr_get) {
13764 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13770 PyObject *called_object = func(descr, source, (PyObject *)type);
13771 CHECK_OBJECT(called_object);
13775 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13776 Py_DECREF(called_object);
13781 if (descr != NULL) {
13782 CHECK_OBJECT(descr);
13784 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, descr, args);
13789#if PYTHON_VERSION < 0x300
13790 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13791 PyString_AS_STRING(attr_name));
13793 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
13797#if PYTHON_VERSION < 0x300
13798 else if (type == &PyInstance_Type) {
13799 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13803 assert(attr_name != const_str_plain___dict__);
13804 assert(attr_name != const_str_plain___class__);
13807 PyObject *called_object =
13808 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13812 if (called_object != NULL) {
13813 return CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13817 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13821 if (called_object != NULL) {
13822 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13824 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13825 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
13827 }
else if (descr_get != NULL) {
13828 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13830 if (unlikely(method == NULL)) {
13834 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, method, args);
13838 return CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13841 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13842 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
13843 PyString_AS_STRING(source_instance->in_class->cl_name),
13844 PyString_AS_STRING(attr_name));
13851 PyObject *args2[] = {source, attr_name};
13853 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13855 if (unlikely(called_object == NULL)) {
13859 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13860 Py_DECREF(called_object);
13865 else if (type->tp_getattro != NULL) {
13866 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13868 if (unlikely(descr == NULL)) {
13872 descrgetfunc func = NULL;
13873 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13874 func = Py_TYPE(descr)->tp_descr_get;
13876 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13877 PyObject *called_object = func(descr, source, (PyObject *)type);
13880 if (unlikely(called_object == NULL)) {
13884 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13885 Py_DECREF(called_object);
13890 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, descr, args);
13893 }
else if (type->tp_getattr != NULL) {
13894 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
13896 if (unlikely(called_object == NULL)) {
13900 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13901 Py_DECREF(called_object);
13904 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13905 Nuitka_String_AsString_Unchecked(attr_name));
13910PyObject *CALL_METHOD_WITH_ARGS9(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13911 CHECK_OBJECT(source);
13912 CHECK_OBJECT(attr_name);
13914 CHECK_OBJECTS(args, 9);
13916 PyTypeObject *type = Py_TYPE(source);
13918 if (hasTypeGenericGetAttr(type)) {
13920 if (unlikely(type->tp_dict == NULL)) {
13921 if (unlikely(PyType_Ready(type) < 0)) {
13926 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13927 descrgetfunc func = NULL;
13929 if (descr != NULL) {
13932 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13933 func = Py_TYPE(descr)->tp_descr_get;
13935 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13936 PyObject *called_object = func(descr, source, (PyObject *)type);
13939 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
13940 Py_DECREF(called_object);
13946 Py_ssize_t dictoffset = type->tp_dictoffset;
13947 PyObject *dict = NULL;
13949 if (dictoffset != 0) {
13951 if (dictoffset < 0) {
13955 tsize = ((PyVarObject *)source)->ob_size;
13959 size = _PyObject_VAR_SIZE(type, tsize);
13961 dictoffset += (long)size;
13964 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13968 if (dict != NULL) {
13969 CHECK_OBJECT(dict);
13973 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13975 if (called_object != NULL) {
13979 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
13980 Py_DECREF(called_object);
13987 if (func != NULL) {
13988 if (func == Nuitka_Function_Type.tp_descr_get) {
13989 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13995 PyObject *called_object = func(descr, source, (PyObject *)type);
13996 CHECK_OBJECT(called_object);
14000 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14001 Py_DECREF(called_object);
14006 if (descr != NULL) {
14007 CHECK_OBJECT(descr);
14009 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, descr, args);
14014#if PYTHON_VERSION < 0x300
14015 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
14016 PyString_AS_STRING(attr_name));
14018 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
14022#if PYTHON_VERSION < 0x300
14023 else if (type == &PyInstance_Type) {
14024 PyInstanceObject *source_instance = (PyInstanceObject *)source;
14028 assert(attr_name != const_str_plain___dict__);
14029 assert(attr_name != const_str_plain___class__);
14032 PyObject *called_object =
14033 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
14037 if (called_object != NULL) {
14038 return CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14042 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
14046 if (called_object != NULL) {
14047 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
14049 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
14050 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
14052 }
else if (descr_get != NULL) {
14053 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
14055 if (unlikely(method == NULL)) {
14059 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, method, args);
14063 return CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14066 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
14067 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
14068 PyString_AS_STRING(source_instance->in_class->cl_name),
14069 PyString_AS_STRING(attr_name));
14076 PyObject *args2[] = {source, attr_name};
14078 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
14080 if (unlikely(called_object == NULL)) {
14084 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14085 Py_DECREF(called_object);
14090 else if (type->tp_getattro != NULL) {
14091 PyObject *descr = (*type->tp_getattro)(source, attr_name);
14093 if (unlikely(descr == NULL)) {
14097 descrgetfunc func = NULL;
14098 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
14099 func = Py_TYPE(descr)->tp_descr_get;
14101 if (func != NULL && Nuitka_Descr_IsData(descr)) {
14102 PyObject *called_object = func(descr, source, (PyObject *)type);
14105 if (unlikely(called_object == NULL)) {
14109 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14110 Py_DECREF(called_object);
14115 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, descr, args);
14118 }
else if (type->tp_getattr != NULL) {
14119 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
14121 if (unlikely(called_object == NULL)) {
14125 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14126 Py_DECREF(called_object);
14129 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
14130 Nuitka_String_AsString_Unchecked(attr_name));
14135PyObject *CALL_METHOD_WITH_ARGS10(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
14136 CHECK_OBJECT(source);
14137 CHECK_OBJECT(attr_name);
14139 CHECK_OBJECTS(args, 10);
14141 PyTypeObject *type = Py_TYPE(source);
14143 if (hasTypeGenericGetAttr(type)) {
14145 if (unlikely(type->tp_dict == NULL)) {
14146 if (unlikely(PyType_Ready(type) < 0)) {
14151 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
14152 descrgetfunc func = NULL;
14154 if (descr != NULL) {
14157 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
14158 func = Py_TYPE(descr)->tp_descr_get;
14160 if (func != NULL && Nuitka_Descr_IsData(descr)) {
14161 PyObject *called_object = func(descr, source, (PyObject *)type);
14164 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14165 Py_DECREF(called_object);
14171 Py_ssize_t dictoffset = type->tp_dictoffset;
14172 PyObject *dict = NULL;
14174 if (dictoffset != 0) {
14176 if (dictoffset < 0) {
14180 tsize = ((PyVarObject *)source)->ob_size;
14184 size = _PyObject_VAR_SIZE(type, tsize);
14186 dictoffset += (long)size;
14189 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
14193 if (dict != NULL) {
14194 CHECK_OBJECT(dict);
14198 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
14200 if (called_object != NULL) {
14204 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14205 Py_DECREF(called_object);
14212 if (func != NULL) {
14213 if (func == Nuitka_Function_Type.tp_descr_get) {
14214 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
14220 PyObject *called_object = func(descr, source, (PyObject *)type);
14221 CHECK_OBJECT(called_object);
14225 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14226 Py_DECREF(called_object);
14231 if (descr != NULL) {
14232 CHECK_OBJECT(descr);
14234 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, descr, args);
14239#if PYTHON_VERSION < 0x300
14240 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
14241 PyString_AS_STRING(attr_name));
14243 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
14247#if PYTHON_VERSION < 0x300
14248 else if (type == &PyInstance_Type) {
14249 PyInstanceObject *source_instance = (PyInstanceObject *)source;
14253 assert(attr_name != const_str_plain___dict__);
14254 assert(attr_name != const_str_plain___class__);
14257 PyObject *called_object =
14258 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
14262 if (called_object != NULL) {
14263 return CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14267 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
14271 if (called_object != NULL) {
14272 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
14274 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
14275 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
14277 }
else if (descr_get != NULL) {
14278 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
14280 if (unlikely(method == NULL)) {
14284 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, method, args);
14288 return CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14291 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
14292 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
14293 PyString_AS_STRING(source_instance->in_class->cl_name),
14294 PyString_AS_STRING(attr_name));
14301 PyObject *args2[] = {source, attr_name};
14303 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
14305 if (unlikely(called_object == NULL)) {
14309 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14310 Py_DECREF(called_object);
14315 else if (type->tp_getattro != NULL) {
14316 PyObject *descr = (*type->tp_getattro)(source, attr_name);
14318 if (unlikely(descr == NULL)) {
14322 descrgetfunc func = NULL;
14323 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
14324 func = Py_TYPE(descr)->tp_descr_get;
14326 if (func != NULL && Nuitka_Descr_IsData(descr)) {
14327 PyObject *called_object = func(descr, source, (PyObject *)type);
14330 if (unlikely(called_object == NULL)) {
14334 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14335 Py_DECREF(called_object);
14340 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, descr, args);
14343 }
else if (type->tp_getattr != NULL) {
14344 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
14346 if (unlikely(called_object == NULL)) {
14350 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14351 Py_DECREF(called_object);
14354 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
14355 Nuitka_String_AsString_Unchecked(attr_name));
14360#if defined(__clang__)
14361#pragma clang diagnostic pop
14362#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
14363#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
14364#pragma GCC diagnostic pop
Definition compiled_function.h:22
Definition compiled_method.h:16