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 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
120 result = func(called, NULL, 0, NULL);
122 CHECK_OBJECT_X(result);
124 PyCFunction method = PyCFunction_GET_FUNCTION(called);
125 PyObject *self = PyCFunction_GET_SELF(called);
127 PyObject *pos_args = const_tuple_empty;
129 if (flags & METH_KEYWORDS) {
130 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
132 result = (*method)(self, pos_args);
136#ifdef _NUITKA_FULL_COMPAT
137 Py_LeaveRecursiveCall();
139 CHECK_OBJECT_X(result);
141 return Nuitka_CheckFunctionResult(tstate, called, result);
144 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
146 if (likely(flags & METH_NOARGS)) {
149#ifdef _NUITKA_FULL_COMPAT
150 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
154 PyCFunction method = PyCFunction_GET_FUNCTION(called);
155 PyObject *self = PyCFunction_GET_SELF(called);
157 PyObject *result = (*method)(self, NULL);
159#ifdef _NUITKA_FULL_COMPAT
160 Py_LeaveRecursiveCall();
162 CHECK_OBJECT_X(result);
164 return Nuitka_CheckFunctionResult(tstate, called, result);
165 }
else if (unlikely(flags & METH_O)) {
166 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (0 given)",
167 ((PyCFunctionObject *)called)->m_ml->ml_name);
169 }
else if (flags & METH_VARARGS) {
172#ifdef _NUITKA_FULL_COMPAT
173 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
177 PyCFunction method = PyCFunction_GET_FUNCTION(called);
178 PyObject *self = PyCFunction_GET_SELF(called);
182#if PYTHON_VERSION < 0x360
183 PyObject *pos_args = const_tuple_empty;
184 if (flags & METH_KEYWORDS) {
185 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
187 result = (*method)(self, pos_args);
191 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
192 PyObject *pos_args = const_tuple_empty;
193 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
194 }
else if (flags == METH_FASTCALL) {
195#if PYTHON_VERSION < 0x370
196 result = (*(_PyCFunctionFast)method)(self, NULL, 0, NULL);
198 PyObject *pos_args = const_tuple_empty;
199 result = (*(_PyCFunctionFast)method)(self, &pos_args, 0);
202 PyObject *pos_args = const_tuple_empty;
203 result = (*method)(self, pos_args);
207#ifdef _NUITKA_FULL_COMPAT
208 Py_LeaveRecursiveCall();
211 CHECK_OBJECT_X(result);
213 return Nuitka_CheckFunctionResult(tstate, called, result);
217#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
218 }
else if (PyFunction_Check(called)) {
219#if PYTHON_VERSION < 0x3b0
220 PyObject *result = callPythonFunctionNoArgs(called);
222 PyObject *result = _PyFunction_Vectorcall(called, NULL, 0, NULL);
224 CHECK_OBJECT_X(result);
228#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
229 }
else if (PyType_Check(called)) {
230 PyTypeObject *type = Py_TYPE(called);
232 if (type->tp_call == PyType_Type.tp_call) {
233 PyTypeObject *called_type = (PyTypeObject *)(called);
235 if (unlikely(called_type->tp_new == NULL)) {
236 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
240 PyObject *pos_args = const_tuple_empty;
243 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
244 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
245 formatCannotInstantiateAbstractClass(tstate, called_type);
249 obj = called_type->tp_alloc(called_type, 0);
252 obj = called_type->tp_new(called_type, pos_args, NULL);
255 if (likely(obj != NULL)) {
256 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
263 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
264 if (type->tp_init == default_tp_init_wrapper) {
266 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
269 assert(init_method != NULL);
271 bool is_compiled_function =
false;
272 bool init_method_needs_release =
false;
274 if (likely(init_method != NULL)) {
275 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
277 if (func == Nuitka_Function_Type.tp_descr_get) {
278 is_compiled_function =
true;
279 }
else if (func != NULL) {
280 init_method = func(init_method, obj, (PyObject *)(type));
281 init_method_needs_release =
true;
285 if (unlikely(init_method == NULL)) {
286 if (!HAS_ERROR_OCCURRED(tstate)) {
287 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
288 const_str_plain___init__);
295 if (is_compiled_function) {
296 result = Nuitka_CallMethodFunctionNoArgs(
299 result = CALL_FUNCTION_NO_ARGS(tstate, init_method);
301 if (init_method_needs_release) {
302 Py_DECREF(init_method);
306 if (unlikely(result == NULL)) {
313 if (unlikely(result != Py_None)) {
316 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
321 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
334#if PYTHON_VERSION < 0x300
335 }
else if (PyClass_Check(called)) {
336 PyObject *obj = PyInstance_NewRaw(called, NULL);
338 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
340 if ((init_method == NULL)) {
341 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
349 bool is_compiled_function =
false;
351 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
353 if (descr_get == NULL) {
354 Py_INCREF(init_method);
355 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
356 is_compiled_function =
true;
357 }
else if (descr_get != NULL) {
358 PyObject *descr_method = descr_get(init_method, obj, called);
360 if (unlikely(descr_method == NULL)) {
364 init_method = descr_method;
368 if (is_compiled_function) {
369 result = Nuitka_CallMethodFunctionNoArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj);
371 result = CALL_FUNCTION_NO_ARGS(tstate, init_method);
372 Py_DECREF(init_method);
374 if (unlikely(result == NULL)) {
380 if (unlikely(result != Py_None)) {
381 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
389#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
390 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
391 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
393 if (likely(func != NULL)) {
394 PyObject *result = func(called, NULL, 0, NULL);
396 CHECK_OBJECT_X(result);
398 return Nuitka_CheckFunctionResult(tstate, called, result);
405 PRINT_STRING(
"FALLBACK");
410 PyObject *result = CALL_FUNCTION(tstate, called, const_tuple_empty, NULL);
412 CHECK_OBJECT_X(result);
416PyObject *CALL_FUNCTION_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *called, PyObject *arg) {
417 PyObject *
const *args = &arg;
418 CHECK_OBJECT(called);
419 CHECK_OBJECTS(args, 1);
421 if (Nuitka_Function_Check(called)) {
422 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
429 if (function->m_args_simple && 1 == function->m_args_positional_count) {
431 result = function->m_c_code(tstate, function, (PyObject **)args);
432 }
else if (function->m_args_simple && 1 + function->m_defaults_given == function->m_args_positional_count) {
433 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
435 memcpy(python_pars, args, 1 *
sizeof(PyObject *));
436 memcpy(python_pars + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
437 function->m_defaults_given *
sizeof(PyObject *));
439 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
440 Py_INCREF(python_pars[i]);
443 result = function->m_c_code(tstate, function, python_pars);
445 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 1);
448 Py_LeaveRecursiveCall();
450 CHECK_OBJECT_X(result);
453 }
else if (Nuitka_Method_Check(called)) {
456 if (method->m_object == NULL) {
457 PyObject *self = args[0];
459 int res = PyObject_IsInstance(self, method->m_class);
461 if (unlikely(res < 0)) {
463 }
else if (unlikely(res == 0)) {
464 PyErr_Format(PyExc_TypeError,
465 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
467 GET_CALLABLE_NAME((PyObject *)method->m_function),
468 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
469 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
474 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 1);
476 CHECK_OBJECT_X(result);
480 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
488 if (function->m_args_simple && 1 + 1 == function->m_args_positional_count) {
489 PyObject *python_pars[1 + 1];
491 python_pars[0] = method->m_object;
492 Py_INCREF(method->m_object);
494 python_pars[1] = args[0];
496 result = function->m_c_code(tstate, function, python_pars);
497 }
else if (function->m_args_simple &&
498 1 + 1 + function->m_defaults_given == function->m_args_positional_count) {
499 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
501 python_pars[0] = method->m_object;
502 Py_INCREF(method->m_object);
504 memcpy(python_pars + 1, args, 1 *
sizeof(PyObject *));
505 memcpy(python_pars + 1 + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
506 function->m_defaults_given *
sizeof(PyObject *));
508 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
509 Py_INCREF(python_pars[i]);
512 result = function->m_c_code(tstate, function, python_pars);
514 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 1);
517 Py_LeaveRecursiveCall();
519 CHECK_OBJECT_X(result);
523#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
524 }
else if (PyCFunction_CheckExact(called)) {
525#if PYTHON_VERSION >= 0x380
526#ifdef _NUITKA_FULL_COMPAT
527 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
532 int flags = PyCFunction_GET_FLAGS(called);
536 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
539 result = func(called, args, 1, NULL);
541 CHECK_OBJECT_X(result);
543 PyCFunction method = PyCFunction_GET_FUNCTION(called);
544 PyObject *self = PyCFunction_GET_SELF(called);
546 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
548 if (flags & METH_KEYWORDS) {
549 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
551 result = (*method)(self, pos_args);
557#ifdef _NUITKA_FULL_COMPAT
558 Py_LeaveRecursiveCall();
560 CHECK_OBJECT_X(result);
562 return Nuitka_CheckFunctionResult(tstate, called, result);
565 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
567 if (unlikely(flags & METH_NOARGS)) {
568 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (1 given)",
569 ((PyCFunctionObject *)called)->m_ml->ml_name);
571 }
else if ((flags & METH_O)) {
574#ifdef _NUITKA_FULL_COMPAT
575 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
579 PyCFunction method = PyCFunction_GET_FUNCTION(called);
580 PyObject *self = PyCFunction_GET_SELF(called);
582 PyObject *result = (*method)(self, args[0]);
584#ifdef _NUITKA_FULL_COMPAT
585 Py_LeaveRecursiveCall();
588 CHECK_OBJECT_X(result);
590 return Nuitka_CheckFunctionResult(tstate, called, result);
591 }
else if (flags & METH_VARARGS) {
594#ifdef _NUITKA_FULL_COMPAT
595 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
599 PyCFunction method = PyCFunction_GET_FUNCTION(called);
600 PyObject *self = PyCFunction_GET_SELF(called);
604#if PYTHON_VERSION < 0x360
605 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
606 if (flags & METH_KEYWORDS) {
607 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
609 result = (*method)(self, pos_args);
614 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
615 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
616 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
618 }
else if (flags == METH_FASTCALL) {
619#if PYTHON_VERSION < 0x370
620 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 1, NULL);
622 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
623 result = (*(_PyCFunctionFast)method)(self, &pos_args, 1);
627 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
628 result = (*method)(self, pos_args);
633#ifdef _NUITKA_FULL_COMPAT
634 Py_LeaveRecursiveCall();
637 CHECK_OBJECT_X(result);
639 return Nuitka_CheckFunctionResult(tstate, called, result);
643#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
644 }
else if (PyFunction_Check(called)) {
645#if PYTHON_VERSION < 0x3b0
646 PyObject *result = callPythonFunction(called, args, 1);
648 PyObject *result = _PyFunction_Vectorcall(called, args, 1, NULL);
650 CHECK_OBJECT_X(result);
654#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
655 }
else if (PyType_Check(called)) {
656 PyTypeObject *type = Py_TYPE(called);
658 if (type->tp_call == PyType_Type.tp_call) {
659 PyTypeObject *called_type = (PyTypeObject *)(called);
661 if (unlikely(called == (PyObject *)&PyType_Type)) {
662 PyObject *result = (PyObject *)Py_TYPE(args[0]);
667 if (unlikely(called_type->tp_new == NULL)) {
668 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
672 PyObject *pos_args = NULL;
675 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
676 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
677 formatCannotInstantiateAbstractClass(tstate, called_type);
681 obj = called_type->tp_alloc(called_type, 0);
684 pos_args = MAKE_TUPLE(tstate, args, 1);
685 obj = called_type->tp_new(called_type, pos_args, NULL);
688 if (likely(obj != NULL)) {
689 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
697 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
698 if (type->tp_init == default_tp_init_wrapper) {
699 Py_XDECREF(pos_args);
702 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
705 assert(init_method != NULL);
707 bool is_compiled_function =
false;
708 bool init_method_needs_release =
false;
710 if (likely(init_method != NULL)) {
711 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
713 if (func == Nuitka_Function_Type.tp_descr_get) {
714 is_compiled_function =
true;
715 }
else if (func != NULL) {
716 init_method = func(init_method, obj, (PyObject *)(type));
717 init_method_needs_release =
true;
721 if (unlikely(init_method == NULL)) {
722 if (!HAS_ERROR_OCCURRED(tstate)) {
723 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
724 const_str_plain___init__);
731 if (is_compiled_function) {
732 result = Nuitka_CallMethodFunctionPosArgs(
735 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
737 if (init_method_needs_release) {
738 Py_DECREF(init_method);
742 if (unlikely(result == NULL)) {
749 if (unlikely(result != Py_None)) {
752 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
756 if (pos_args == NULL) {
757 pos_args = MAKE_TUPLE(tstate, args, 1);
760 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
762 Py_XDECREF(pos_args);
769 Py_XDECREF(pos_args);
776#if PYTHON_VERSION < 0x300
777 }
else if (PyClass_Check(called)) {
778 PyObject *obj = PyInstance_NewRaw(called, NULL);
780 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
782 if (unlikely(init_method == NULL)) {
783 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
790 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
794 bool is_compiled_function =
false;
796 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
798 if (descr_get == NULL) {
799 Py_INCREF(init_method);
800 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
801 is_compiled_function =
true;
802 }
else if (descr_get != NULL) {
803 PyObject *descr_method = descr_get(init_method, obj, called);
805 if (unlikely(descr_method == NULL)) {
809 init_method = descr_method;
813 if (is_compiled_function) {
814 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
817 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
818 Py_DECREF(init_method);
820 if (unlikely(result == NULL)) {
826 if (unlikely(result != Py_None)) {
827 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
835#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
836 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
837 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
839 if (likely(func != NULL)) {
840 PyObject *result = func(called, args, 1, NULL);
842 CHECK_OBJECT_X(result);
844 return Nuitka_CheckFunctionResult(tstate, called, result);
851 PRINT_STRING(
"FALLBACK");
856 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
858 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
862 CHECK_OBJECT_X(result);
866PyObject *CALL_FUNCTION_WITH_POS_ARGS1(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
867 assert(PyTuple_CheckExact(pos_args));
868 assert(PyTuple_GET_SIZE(pos_args) == 1);
869 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
870 CHECK_OBJECT(called);
871 CHECK_OBJECTS(args, 1);
873 if (Nuitka_Function_Check(called)) {
874 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
881 if (function->m_args_simple && 1 == function->m_args_positional_count) {
883 result = function->m_c_code(tstate, function, (PyObject **)args);
884 }
else if (function->m_args_simple && 1 + function->m_defaults_given == function->m_args_positional_count) {
885 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
887 memcpy(python_pars, args, 1 *
sizeof(PyObject *));
888 memcpy(python_pars + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
889 function->m_defaults_given *
sizeof(PyObject *));
891 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
892 Py_INCREF(python_pars[i]);
895 result = function->m_c_code(tstate, function, python_pars);
897 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 1);
900 Py_LeaveRecursiveCall();
902 CHECK_OBJECT_X(result);
905 }
else if (Nuitka_Method_Check(called)) {
908 if (method->m_object == NULL) {
909 PyObject *self = args[0];
911 int res = PyObject_IsInstance(self, method->m_class);
913 if (unlikely(res < 0)) {
915 }
else if (unlikely(res == 0)) {
916 PyErr_Format(PyExc_TypeError,
917 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
919 GET_CALLABLE_NAME((PyObject *)method->m_function),
920 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
921 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
926 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 1);
928 CHECK_OBJECT_X(result);
932 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
940 if (function->m_args_simple && 1 + 1 == function->m_args_positional_count) {
941 PyObject *python_pars[1 + 1];
943 python_pars[0] = method->m_object;
944 Py_INCREF(method->m_object);
946 python_pars[1] = args[0];
948 result = function->m_c_code(tstate, function, python_pars);
949 }
else if (function->m_args_simple &&
950 1 + 1 + function->m_defaults_given == function->m_args_positional_count) {
951 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
953 python_pars[0] = method->m_object;
954 Py_INCREF(method->m_object);
956 memcpy(python_pars + 1, args, 1 *
sizeof(PyObject *));
957 memcpy(python_pars + 1 + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
958 function->m_defaults_given *
sizeof(PyObject *));
960 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
961 Py_INCREF(python_pars[i]);
964 result = function->m_c_code(tstate, function, python_pars);
966 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 1);
969 Py_LeaveRecursiveCall();
971 CHECK_OBJECT_X(result);
975#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
976 }
else if (PyCFunction_CheckExact(called)) {
977#if PYTHON_VERSION >= 0x380
978#ifdef _NUITKA_FULL_COMPAT
979 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
984 int flags = PyCFunction_GET_FLAGS(called);
988 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
991 result = func(called, args, 1, NULL);
993 CHECK_OBJECT_X(result);
995 PyCFunction method = PyCFunction_GET_FUNCTION(called);
996 PyObject *self = PyCFunction_GET_SELF(called);
998 if (flags & METH_KEYWORDS) {
999 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
1001 result = (*method)(self, pos_args);
1005#ifdef _NUITKA_FULL_COMPAT
1006 Py_LeaveRecursiveCall();
1008 CHECK_OBJECT_X(result);
1010 return Nuitka_CheckFunctionResult(tstate, called, result);
1013 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
1015 if (unlikely(flags & METH_NOARGS)) {
1016 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (1 given)",
1017 ((PyCFunctionObject *)called)->m_ml->ml_name);
1019 }
else if ((flags & METH_O)) {
1022#ifdef _NUITKA_FULL_COMPAT
1023 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1027 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1028 PyObject *self = PyCFunction_GET_SELF(called);
1030 PyObject *result = (*method)(self, args[0]);
1032#ifdef _NUITKA_FULL_COMPAT
1033 Py_LeaveRecursiveCall();
1036 CHECK_OBJECT_X(result);
1038 return Nuitka_CheckFunctionResult(tstate, called, result);
1039 }
else if (flags & METH_VARARGS) {
1042#ifdef _NUITKA_FULL_COMPAT
1043 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1047 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1048 PyObject *self = PyCFunction_GET_SELF(called);
1052#if PYTHON_VERSION < 0x360
1053 if (flags & METH_KEYWORDS) {
1054 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1056 result = (*method)(self, pos_args);
1060 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
1061 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1062 }
else if (flags == METH_FASTCALL) {
1063#if PYTHON_VERSION < 0x370
1064 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 1, NULL);
1066 result = (*(_PyCFunctionFast)method)(self, &pos_args, 1);
1069 result = (*method)(self, pos_args);
1073#ifdef _NUITKA_FULL_COMPAT
1074 Py_LeaveRecursiveCall();
1077 CHECK_OBJECT_X(result);
1079 return Nuitka_CheckFunctionResult(tstate, called, result);
1083#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
1084 }
else if (PyFunction_Check(called)) {
1085#if PYTHON_VERSION < 0x3b0
1086 PyObject *result = callPythonFunction(called, args, 1);
1088 PyObject *result = _PyFunction_Vectorcall(called, args, 1, NULL);
1090 CHECK_OBJECT_X(result);
1094#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
1095 }
else if (PyType_Check(called)) {
1096 PyTypeObject *type = Py_TYPE(called);
1098 if (type->tp_call == PyType_Type.tp_call) {
1099 PyTypeObject *called_type = (PyTypeObject *)(called);
1101 if (unlikely(called == (PyObject *)&PyType_Type)) {
1102 PyObject *result = (PyObject *)Py_TYPE(args[0]);
1107 if (unlikely(called_type->tp_new == NULL)) {
1108 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
1114 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
1115 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
1116 formatCannotInstantiateAbstractClass(tstate, called_type);
1120 obj = called_type->tp_alloc(called_type, 0);
1123 obj = called_type->tp_new(called_type, pos_args, NULL);
1126 if (likely(obj != NULL)) {
1127 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
1132 type = Py_TYPE(obj);
1134 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
1135 if (type->tp_init == default_tp_init_wrapper) {
1137 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
1140 assert(init_method != NULL);
1142 bool is_compiled_function =
false;
1143 bool init_method_needs_release =
false;
1145 if (likely(init_method != NULL)) {
1146 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
1148 if (func == Nuitka_Function_Type.tp_descr_get) {
1149 is_compiled_function =
true;
1150 }
else if (func != NULL) {
1151 init_method = func(init_method, obj, (PyObject *)(type));
1152 init_method_needs_release =
true;
1156 if (unlikely(init_method == NULL)) {
1157 if (!HAS_ERROR_OCCURRED(tstate)) {
1158 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
1159 const_str_plain___init__);
1166 if (is_compiled_function) {
1167 result = Nuitka_CallMethodFunctionPosArgs(
1170 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
1172 if (init_method_needs_release) {
1173 Py_DECREF(init_method);
1177 if (unlikely(result == NULL)) {
1184 if (unlikely(result != Py_None)) {
1187 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
1192 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
1200 CHECK_OBJECT_X(obj);
1205#if PYTHON_VERSION < 0x300
1206 }
else if (PyClass_Check(called)) {
1207 PyObject *obj = PyInstance_NewRaw(called, NULL);
1209 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
1211 if (unlikely(init_method == NULL)) {
1212 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
1219 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
1223 bool is_compiled_function =
false;
1225 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
1227 if (descr_get == NULL) {
1228 Py_INCREF(init_method);
1229 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
1230 is_compiled_function =
true;
1231 }
else if (descr_get != NULL) {
1232 PyObject *descr_method = descr_get(init_method, obj, called);
1234 if (unlikely(descr_method == NULL)) {
1238 init_method = descr_method;
1242 if (is_compiled_function) {
1243 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
1246 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
1247 Py_DECREF(init_method);
1249 if (unlikely(result == NULL)) {
1255 if (unlikely(result != Py_None)) {
1256 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
1260 CHECK_OBJECT_X(obj);
1264#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
1265 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
1266 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1268 if (likely(func != NULL)) {
1269 PyObject *result = func(called, args, 1, NULL);
1271 CHECK_OBJECT_X(result);
1273 return Nuitka_CheckFunctionResult(tstate, called, result);
1280 PRINT_STRING(
"FALLBACK");
1285 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
1287 CHECK_OBJECT_X(result);
1291PyObject *CALL_FUNCTION_WITH_ARGS2(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
1292 CHECK_OBJECT(called);
1293 CHECK_OBJECTS(args, 2);
1295 if (Nuitka_Function_Check(called)) {
1296 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1303 if (function->m_args_simple && 2 == function->m_args_positional_count) {
1304 for (Py_ssize_t i = 0; i < 2; i++) {
1307 result = function->m_c_code(tstate, function, (PyObject **)args);
1308 }
else if (function->m_args_simple && 2 + function->m_defaults_given == function->m_args_positional_count) {
1309 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1311 memcpy(python_pars, args, 2 *
sizeof(PyObject *));
1312 memcpy(python_pars + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1313 function->m_defaults_given *
sizeof(PyObject *));
1315 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
1316 Py_INCREF(python_pars[i]);
1319 result = function->m_c_code(tstate, function, python_pars);
1321 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 2);
1324 Py_LeaveRecursiveCall();
1326 CHECK_OBJECT_X(result);
1329 }
else if (Nuitka_Method_Check(called)) {
1332 if (method->m_object == NULL) {
1333 PyObject *self = args[0];
1335 int res = PyObject_IsInstance(self, method->m_class);
1337 if (unlikely(res < 0)) {
1339 }
else if (unlikely(res == 0)) {
1340 PyErr_Format(PyExc_TypeError,
1341 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
1342 "instance instead)",
1343 GET_CALLABLE_NAME((PyObject *)method->m_function),
1344 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
1345 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
1350 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 2);
1352 CHECK_OBJECT_X(result);
1356 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1364 if (function->m_args_simple && 2 + 1 == function->m_args_positional_count) {
1365 PyObject *python_pars[2 + 1];
1367 python_pars[0] = method->m_object;
1368 Py_INCREF(method->m_object);
1370 for (Py_ssize_t i = 0; i < 2; i++) {
1371 python_pars[i + 1] = args[i];
1374 result = function->m_c_code(tstate, function, python_pars);
1375 }
else if (function->m_args_simple &&
1376 2 + 1 + function->m_defaults_given == function->m_args_positional_count) {
1377 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1379 python_pars[0] = method->m_object;
1380 Py_INCREF(method->m_object);
1382 memcpy(python_pars + 1, args, 2 *
sizeof(PyObject *));
1383 memcpy(python_pars + 1 + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1384 function->m_defaults_given *
sizeof(PyObject *));
1386 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
1387 Py_INCREF(python_pars[i]);
1390 result = function->m_c_code(tstate, function, python_pars);
1392 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 2);
1395 Py_LeaveRecursiveCall();
1397 CHECK_OBJECT_X(result);
1401#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
1402 }
else if (PyCFunction_CheckExact(called)) {
1403#if PYTHON_VERSION >= 0x380
1404#ifdef _NUITKA_FULL_COMPAT
1405 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1410 int flags = PyCFunction_GET_FLAGS(called);
1414 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1417 result = func(called, args, 2, NULL);
1419 CHECK_OBJECT_X(result);
1421 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1422 PyObject *self = PyCFunction_GET_SELF(called);
1424 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1426 if (flags & METH_KEYWORDS) {
1427 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
1429 result = (*method)(self, pos_args);
1432 Py_DECREF(pos_args);
1435#ifdef _NUITKA_FULL_COMPAT
1436 Py_LeaveRecursiveCall();
1438 CHECK_OBJECT_X(result);
1440 return Nuitka_CheckFunctionResult(tstate, called, result);
1443 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
1445 if (unlikely(flags & METH_NOARGS)) {
1446 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (2 given)",
1447 ((PyCFunctionObject *)called)->m_ml->ml_name);
1449 }
else if (unlikely(flags & METH_O)) {
1450 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (2 given)",
1451 ((PyCFunctionObject *)called)->m_ml->ml_name);
1453 }
else if (flags & METH_VARARGS) {
1456#ifdef _NUITKA_FULL_COMPAT
1457 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1461 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1462 PyObject *self = PyCFunction_GET_SELF(called);
1466#if PYTHON_VERSION < 0x360
1467 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1468 if (flags & METH_KEYWORDS) {
1469 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1471 result = (*method)(self, pos_args);
1474 Py_DECREF(pos_args);
1476 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
1477 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1478 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1479 Py_DECREF(pos_args);
1480 }
else if (flags == METH_FASTCALL) {
1481#if PYTHON_VERSION < 0x370
1482 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 2, NULL);
1484 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1485 result = (*(_PyCFunctionFast)method)(self, &pos_args, 2);
1486 Py_DECREF(pos_args);
1489 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1490 result = (*method)(self, pos_args);
1491 Py_DECREF(pos_args);
1495#ifdef _NUITKA_FULL_COMPAT
1496 Py_LeaveRecursiveCall();
1499 CHECK_OBJECT_X(result);
1501 return Nuitka_CheckFunctionResult(tstate, called, result);
1505#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
1506 }
else if (PyFunction_Check(called)) {
1507#if PYTHON_VERSION < 0x3b0
1508 PyObject *result = callPythonFunction(called, args, 2);
1510 PyObject *result = _PyFunction_Vectorcall(called, args, 2, NULL);
1512 CHECK_OBJECT_X(result);
1516#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
1517 }
else if (PyType_Check(called)) {
1518 PyTypeObject *type = Py_TYPE(called);
1520 if (type->tp_call == PyType_Type.tp_call) {
1521 PyTypeObject *called_type = (PyTypeObject *)(called);
1523 if (unlikely(called_type->tp_new == NULL)) {
1524 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
1528 PyObject *pos_args = NULL;
1531 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
1532 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
1533 formatCannotInstantiateAbstractClass(tstate, called_type);
1537 obj = called_type->tp_alloc(called_type, 0);
1540 pos_args = MAKE_TUPLE(tstate, args, 2);
1541 obj = called_type->tp_new(called_type, pos_args, NULL);
1544 if (likely(obj != NULL)) {
1545 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
1546 Py_DECREF(pos_args);
1551 type = Py_TYPE(obj);
1553 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
1554 if (type->tp_init == default_tp_init_wrapper) {
1555 Py_XDECREF(pos_args);
1558 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
1561 assert(init_method != NULL);
1563 bool is_compiled_function =
false;
1564 bool init_method_needs_release =
false;
1566 if (likely(init_method != NULL)) {
1567 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
1569 if (func == Nuitka_Function_Type.tp_descr_get) {
1570 is_compiled_function =
true;
1571 }
else if (func != NULL) {
1572 init_method = func(init_method, obj, (PyObject *)(type));
1573 init_method_needs_release =
true;
1577 if (unlikely(init_method == NULL)) {
1578 if (!HAS_ERROR_OCCURRED(tstate)) {
1579 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
1580 const_str_plain___init__);
1587 if (is_compiled_function) {
1588 result = Nuitka_CallMethodFunctionPosArgs(
1591 result = CALL_FUNCTION_WITH_ARGS2(tstate, init_method, args);
1592 if (init_method_needs_release) {
1593 Py_DECREF(init_method);
1597 if (unlikely(result == NULL)) {
1604 if (unlikely(result != Py_None)) {
1607 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
1611 if (pos_args == NULL) {
1612 pos_args = MAKE_TUPLE(tstate, args, 2);
1615 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
1617 Py_XDECREF(pos_args);
1624 Py_XDECREF(pos_args);
1626 CHECK_OBJECT_X(obj);
1631#if PYTHON_VERSION < 0x300
1632 }
else if (PyClass_Check(called)) {
1633 PyObject *obj = PyInstance_NewRaw(called, NULL);
1635 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
1637 if (unlikely(init_method == NULL)) {
1638 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
1645 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
1649 bool is_compiled_function =
false;
1651 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
1653 if (descr_get == NULL) {
1654 Py_INCREF(init_method);
1655 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
1656 is_compiled_function =
true;
1657 }
else if (descr_get != NULL) {
1658 PyObject *descr_method = descr_get(init_method, obj, called);
1660 if (unlikely(descr_method == NULL)) {
1664 init_method = descr_method;
1668 if (is_compiled_function) {
1669 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
1672 result = CALL_FUNCTION_WITH_ARGS2(tstate, init_method, args);
1673 Py_DECREF(init_method);
1675 if (unlikely(result == NULL)) {
1681 if (unlikely(result != Py_None)) {
1682 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
1686 CHECK_OBJECT_X(obj);
1690#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
1691 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
1692 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1694 if (likely(func != NULL)) {
1695 PyObject *result = func(called, args, 2, NULL);
1697 CHECK_OBJECT_X(result);
1699 return Nuitka_CheckFunctionResult(tstate, called, result);
1706 PRINT_STRING(
"FALLBACK");
1711 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1713 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
1715 Py_DECREF(pos_args);
1717 CHECK_OBJECT_X(result);
1721PyObject *CALL_FUNCTION_WITH_POS_ARGS2(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
1722 assert(PyTuple_CheckExact(pos_args));
1723 assert(PyTuple_GET_SIZE(pos_args) == 2);
1724 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
1725 CHECK_OBJECT(called);
1726 CHECK_OBJECTS(args, 2);
1728 if (Nuitka_Function_Check(called)) {
1729 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1736 if (function->m_args_simple && 2 == function->m_args_positional_count) {
1737 for (Py_ssize_t i = 0; i < 2; i++) {
1740 result = function->m_c_code(tstate, function, (PyObject **)args);
1741 }
else if (function->m_args_simple && 2 + function->m_defaults_given == function->m_args_positional_count) {
1742 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1744 memcpy(python_pars, args, 2 *
sizeof(PyObject *));
1745 memcpy(python_pars + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1746 function->m_defaults_given *
sizeof(PyObject *));
1748 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
1749 Py_INCREF(python_pars[i]);
1752 result = function->m_c_code(tstate, function, python_pars);
1754 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 2);
1757 Py_LeaveRecursiveCall();
1759 CHECK_OBJECT_X(result);
1762 }
else if (Nuitka_Method_Check(called)) {
1765 if (method->m_object == NULL) {
1766 PyObject *self = args[0];
1768 int res = PyObject_IsInstance(self, method->m_class);
1770 if (unlikely(res < 0)) {
1772 }
else if (unlikely(res == 0)) {
1773 PyErr_Format(PyExc_TypeError,
1774 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
1775 "instance instead)",
1776 GET_CALLABLE_NAME((PyObject *)method->m_function),
1777 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
1778 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
1783 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 2);
1785 CHECK_OBJECT_X(result);
1789 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1797 if (function->m_args_simple && 2 + 1 == function->m_args_positional_count) {
1798 PyObject *python_pars[2 + 1];
1800 python_pars[0] = method->m_object;
1801 Py_INCREF(method->m_object);
1803 for (Py_ssize_t i = 0; i < 2; i++) {
1804 python_pars[i + 1] = args[i];
1807 result = function->m_c_code(tstate, function, python_pars);
1808 }
else if (function->m_args_simple &&
1809 2 + 1 + function->m_defaults_given == function->m_args_positional_count) {
1810 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1812 python_pars[0] = method->m_object;
1813 Py_INCREF(method->m_object);
1815 memcpy(python_pars + 1, args, 2 *
sizeof(PyObject *));
1816 memcpy(python_pars + 1 + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1817 function->m_defaults_given *
sizeof(PyObject *));
1819 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
1820 Py_INCREF(python_pars[i]);
1823 result = function->m_c_code(tstate, function, python_pars);
1825 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 2);
1828 Py_LeaveRecursiveCall();
1830 CHECK_OBJECT_X(result);
1834#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
1835 }
else if (PyCFunction_CheckExact(called)) {
1836#if PYTHON_VERSION >= 0x380
1837#ifdef _NUITKA_FULL_COMPAT
1838 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1843 int flags = PyCFunction_GET_FLAGS(called);
1847 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1850 result = func(called, args, 2, NULL);
1852 CHECK_OBJECT_X(result);
1854 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1855 PyObject *self = PyCFunction_GET_SELF(called);
1857 if (flags & METH_KEYWORDS) {
1858 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
1860 result = (*method)(self, pos_args);
1864#ifdef _NUITKA_FULL_COMPAT
1865 Py_LeaveRecursiveCall();
1867 CHECK_OBJECT_X(result);
1869 return Nuitka_CheckFunctionResult(tstate, called, result);
1872 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
1874 if (unlikely(flags & METH_NOARGS)) {
1875 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (2 given)",
1876 ((PyCFunctionObject *)called)->m_ml->ml_name);
1878 }
else if (unlikely(flags & METH_O)) {
1879 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (2 given)",
1880 ((PyCFunctionObject *)called)->m_ml->ml_name);
1882 }
else if (flags & METH_VARARGS) {
1885#ifdef _NUITKA_FULL_COMPAT
1886 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
1890 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1891 PyObject *self = PyCFunction_GET_SELF(called);
1895#if PYTHON_VERSION < 0x360
1896 if (flags & METH_KEYWORDS) {
1897 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1899 result = (*method)(self, pos_args);
1903 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
1904 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1905 }
else if (flags == METH_FASTCALL) {
1906#if PYTHON_VERSION < 0x370
1907 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 2, NULL);
1909 result = (*(_PyCFunctionFast)method)(self, &pos_args, 2);
1912 result = (*method)(self, pos_args);
1916#ifdef _NUITKA_FULL_COMPAT
1917 Py_LeaveRecursiveCall();
1920 CHECK_OBJECT_X(result);
1922 return Nuitka_CheckFunctionResult(tstate, called, result);
1926#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
1927 }
else if (PyFunction_Check(called)) {
1928#if PYTHON_VERSION < 0x3b0
1929 PyObject *result = callPythonFunction(called, args, 2);
1931 PyObject *result = _PyFunction_Vectorcall(called, args, 2, NULL);
1933 CHECK_OBJECT_X(result);
1937#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
1938 }
else if (PyType_Check(called)) {
1939 PyTypeObject *type = Py_TYPE(called);
1941 if (type->tp_call == PyType_Type.tp_call) {
1942 PyTypeObject *called_type = (PyTypeObject *)(called);
1944 if (unlikely(called_type->tp_new == NULL)) {
1945 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
1951 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
1952 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
1953 formatCannotInstantiateAbstractClass(tstate, called_type);
1957 obj = called_type->tp_alloc(called_type, 0);
1960 obj = called_type->tp_new(called_type, pos_args, NULL);
1963 if (likely(obj != NULL)) {
1964 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
1969 type = Py_TYPE(obj);
1971 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
1972 if (type->tp_init == default_tp_init_wrapper) {
1974 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
1977 assert(init_method != NULL);
1979 bool is_compiled_function =
false;
1980 bool init_method_needs_release =
false;
1982 if (likely(init_method != NULL)) {
1983 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
1985 if (func == Nuitka_Function_Type.tp_descr_get) {
1986 is_compiled_function =
true;
1987 }
else if (func != NULL) {
1988 init_method = func(init_method, obj, (PyObject *)(type));
1989 init_method_needs_release =
true;
1993 if (unlikely(init_method == NULL)) {
1994 if (!HAS_ERROR_OCCURRED(tstate)) {
1995 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
1996 const_str_plain___init__);
2003 if (is_compiled_function) {
2004 result = Nuitka_CallMethodFunctionPosArgs(
2007 result = CALL_FUNCTION_WITH_POS_ARGS2(tstate, init_method, pos_args);
2008 if (init_method_needs_release) {
2009 Py_DECREF(init_method);
2013 if (unlikely(result == NULL)) {
2020 if (unlikely(result != Py_None)) {
2023 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2028 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
2036 CHECK_OBJECT_X(obj);
2041#if PYTHON_VERSION < 0x300
2042 }
else if (PyClass_Check(called)) {
2043 PyObject *obj = PyInstance_NewRaw(called, NULL);
2045 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
2047 if (unlikely(init_method == NULL)) {
2048 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
2055 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
2059 bool is_compiled_function =
false;
2061 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
2063 if (descr_get == NULL) {
2064 Py_INCREF(init_method);
2065 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
2066 is_compiled_function =
true;
2067 }
else if (descr_get != NULL) {
2068 PyObject *descr_method = descr_get(init_method, obj, called);
2070 if (unlikely(descr_method == NULL)) {
2074 init_method = descr_method;
2078 if (is_compiled_function) {
2079 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
2082 result = CALL_FUNCTION_WITH_POS_ARGS2(tstate, init_method, pos_args);
2083 Py_DECREF(init_method);
2085 if (unlikely(result == NULL)) {
2091 if (unlikely(result != Py_None)) {
2092 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2096 CHECK_OBJECT_X(obj);
2100#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
2101 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
2102 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2104 if (likely(func != NULL)) {
2105 PyObject *result = func(called, args, 2, NULL);
2107 CHECK_OBJECT_X(result);
2109 return Nuitka_CheckFunctionResult(tstate, called, result);
2116 PRINT_STRING(
"FALLBACK");
2121 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
2123 CHECK_OBJECT_X(result);
2127PyObject *CALL_FUNCTION_WITH_ARGS3(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
2128 CHECK_OBJECT(called);
2129 CHECK_OBJECTS(args, 3);
2131 if (Nuitka_Function_Check(called)) {
2132 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2139 if (function->m_args_simple && 3 == function->m_args_positional_count) {
2140 for (Py_ssize_t i = 0; i < 3; i++) {
2143 result = function->m_c_code(tstate, function, (PyObject **)args);
2144 }
else if (function->m_args_simple && 3 + function->m_defaults_given == function->m_args_positional_count) {
2145 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2147 memcpy(python_pars, args, 3 *
sizeof(PyObject *));
2148 memcpy(python_pars + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2149 function->m_defaults_given *
sizeof(PyObject *));
2151 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
2152 Py_INCREF(python_pars[i]);
2155 result = function->m_c_code(tstate, function, python_pars);
2157 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 3);
2160 Py_LeaveRecursiveCall();
2162 CHECK_OBJECT_X(result);
2165 }
else if (Nuitka_Method_Check(called)) {
2168 if (method->m_object == NULL) {
2169 PyObject *self = args[0];
2171 int res = PyObject_IsInstance(self, method->m_class);
2173 if (unlikely(res < 0)) {
2175 }
else if (unlikely(res == 0)) {
2176 PyErr_Format(PyExc_TypeError,
2177 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
2178 "instance instead)",
2179 GET_CALLABLE_NAME((PyObject *)method->m_function),
2180 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
2181 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
2186 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 3);
2188 CHECK_OBJECT_X(result);
2192 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2200 if (function->m_args_simple && 3 + 1 == function->m_args_positional_count) {
2201 PyObject *python_pars[3 + 1];
2203 python_pars[0] = method->m_object;
2204 Py_INCREF(method->m_object);
2206 for (Py_ssize_t i = 0; i < 3; i++) {
2207 python_pars[i + 1] = args[i];
2210 result = function->m_c_code(tstate, function, python_pars);
2211 }
else if (function->m_args_simple &&
2212 3 + 1 + function->m_defaults_given == function->m_args_positional_count) {
2213 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2215 python_pars[0] = method->m_object;
2216 Py_INCREF(method->m_object);
2218 memcpy(python_pars + 1, args, 3 *
sizeof(PyObject *));
2219 memcpy(python_pars + 1 + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2220 function->m_defaults_given *
sizeof(PyObject *));
2222 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
2223 Py_INCREF(python_pars[i]);
2226 result = function->m_c_code(tstate, function, python_pars);
2228 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 3);
2231 Py_LeaveRecursiveCall();
2233 CHECK_OBJECT_X(result);
2237#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
2238 }
else if (PyCFunction_CheckExact(called)) {
2239#if PYTHON_VERSION >= 0x380
2240#ifdef _NUITKA_FULL_COMPAT
2241 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2246 int flags = PyCFunction_GET_FLAGS(called);
2250 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2253 result = func(called, args, 3, NULL);
2255 CHECK_OBJECT_X(result);
2257 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2258 PyObject *self = PyCFunction_GET_SELF(called);
2260 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2262 if (flags & METH_KEYWORDS) {
2263 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
2265 result = (*method)(self, pos_args);
2268 Py_DECREF(pos_args);
2271#ifdef _NUITKA_FULL_COMPAT
2272 Py_LeaveRecursiveCall();
2274 CHECK_OBJECT_X(result);
2276 return Nuitka_CheckFunctionResult(tstate, called, result);
2279 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
2281 if (unlikely(flags & METH_NOARGS)) {
2282 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (3 given)",
2283 ((PyCFunctionObject *)called)->m_ml->ml_name);
2285 }
else if (unlikely(flags & METH_O)) {
2286 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (3 given)",
2287 ((PyCFunctionObject *)called)->m_ml->ml_name);
2289 }
else if (flags & METH_VARARGS) {
2292#ifdef _NUITKA_FULL_COMPAT
2293 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2297 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2298 PyObject *self = PyCFunction_GET_SELF(called);
2302#if PYTHON_VERSION < 0x360
2303 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2304 if (flags & METH_KEYWORDS) {
2305 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2307 result = (*method)(self, pos_args);
2310 Py_DECREF(pos_args);
2312 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
2313 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2314 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2315 Py_DECREF(pos_args);
2316 }
else if (flags == METH_FASTCALL) {
2317#if PYTHON_VERSION < 0x370
2318 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 3, NULL);
2320 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2321 result = (*(_PyCFunctionFast)method)(self, &pos_args, 3);
2322 Py_DECREF(pos_args);
2325 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2326 result = (*method)(self, pos_args);
2327 Py_DECREF(pos_args);
2331#ifdef _NUITKA_FULL_COMPAT
2332 Py_LeaveRecursiveCall();
2335 CHECK_OBJECT_X(result);
2337 return Nuitka_CheckFunctionResult(tstate, called, result);
2341#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
2342 }
else if (PyFunction_Check(called)) {
2343#if PYTHON_VERSION < 0x3b0
2344 PyObject *result = callPythonFunction(called, args, 3);
2346 PyObject *result = _PyFunction_Vectorcall(called, args, 3, NULL);
2348 CHECK_OBJECT_X(result);
2352#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
2353 }
else if (PyType_Check(called)) {
2354 PyTypeObject *type = Py_TYPE(called);
2356 if (type->tp_call == PyType_Type.tp_call) {
2357 PyTypeObject *called_type = (PyTypeObject *)(called);
2359 if (unlikely(called_type->tp_new == NULL)) {
2360 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
2364 PyObject *pos_args = NULL;
2367 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
2368 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
2369 formatCannotInstantiateAbstractClass(tstate, called_type);
2373 obj = called_type->tp_alloc(called_type, 0);
2376 pos_args = MAKE_TUPLE(tstate, args, 3);
2377 obj = called_type->tp_new(called_type, pos_args, NULL);
2380 if (likely(obj != NULL)) {
2381 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
2382 Py_DECREF(pos_args);
2387 type = Py_TYPE(obj);
2389 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
2390 if (type->tp_init == default_tp_init_wrapper) {
2391 Py_XDECREF(pos_args);
2394 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
2397 assert(init_method != NULL);
2399 bool is_compiled_function =
false;
2400 bool init_method_needs_release =
false;
2402 if (likely(init_method != NULL)) {
2403 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
2405 if (func == Nuitka_Function_Type.tp_descr_get) {
2406 is_compiled_function =
true;
2407 }
else if (func != NULL) {
2408 init_method = func(init_method, obj, (PyObject *)(type));
2409 init_method_needs_release =
true;
2413 if (unlikely(init_method == NULL)) {
2414 if (!HAS_ERROR_OCCURRED(tstate)) {
2415 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
2416 const_str_plain___init__);
2423 if (is_compiled_function) {
2424 result = Nuitka_CallMethodFunctionPosArgs(
2427 result = CALL_FUNCTION_WITH_ARGS3(tstate, init_method, args);
2428 if (init_method_needs_release) {
2429 Py_DECREF(init_method);
2433 if (unlikely(result == NULL)) {
2440 if (unlikely(result != Py_None)) {
2443 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2447 if (pos_args == NULL) {
2448 pos_args = MAKE_TUPLE(tstate, args, 3);
2451 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
2453 Py_XDECREF(pos_args);
2460 Py_XDECREF(pos_args);
2462 CHECK_OBJECT_X(obj);
2467#if PYTHON_VERSION < 0x300
2468 }
else if (PyClass_Check(called)) {
2469 PyObject *obj = PyInstance_NewRaw(called, NULL);
2471 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
2473 if (unlikely(init_method == NULL)) {
2474 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
2481 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
2485 bool is_compiled_function =
false;
2487 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
2489 if (descr_get == NULL) {
2490 Py_INCREF(init_method);
2491 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
2492 is_compiled_function =
true;
2493 }
else if (descr_get != NULL) {
2494 PyObject *descr_method = descr_get(init_method, obj, called);
2496 if (unlikely(descr_method == NULL)) {
2500 init_method = descr_method;
2504 if (is_compiled_function) {
2505 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
2508 result = CALL_FUNCTION_WITH_ARGS3(tstate, init_method, args);
2509 Py_DECREF(init_method);
2511 if (unlikely(result == NULL)) {
2517 if (unlikely(result != Py_None)) {
2518 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2522 CHECK_OBJECT_X(obj);
2526#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
2527 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
2528 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2530 if (likely(func != NULL)) {
2531 PyObject *result = func(called, args, 3, NULL);
2533 CHECK_OBJECT_X(result);
2535 return Nuitka_CheckFunctionResult(tstate, called, result);
2542 PRINT_STRING(
"FALLBACK");
2547 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2549 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
2551 Py_DECREF(pos_args);
2553 CHECK_OBJECT_X(result);
2557PyObject *CALL_FUNCTION_WITH_POS_ARGS3(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
2558 assert(PyTuple_CheckExact(pos_args));
2559 assert(PyTuple_GET_SIZE(pos_args) == 3);
2560 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
2561 CHECK_OBJECT(called);
2562 CHECK_OBJECTS(args, 3);
2564 if (Nuitka_Function_Check(called)) {
2565 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2572 if (function->m_args_simple && 3 == function->m_args_positional_count) {
2573 for (Py_ssize_t i = 0; i < 3; i++) {
2576 result = function->m_c_code(tstate, function, (PyObject **)args);
2577 }
else if (function->m_args_simple && 3 + function->m_defaults_given == function->m_args_positional_count) {
2578 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2580 memcpy(python_pars, args, 3 *
sizeof(PyObject *));
2581 memcpy(python_pars + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2582 function->m_defaults_given *
sizeof(PyObject *));
2584 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
2585 Py_INCREF(python_pars[i]);
2588 result = function->m_c_code(tstate, function, python_pars);
2590 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 3);
2593 Py_LeaveRecursiveCall();
2595 CHECK_OBJECT_X(result);
2598 }
else if (Nuitka_Method_Check(called)) {
2601 if (method->m_object == NULL) {
2602 PyObject *self = args[0];
2604 int res = PyObject_IsInstance(self, method->m_class);
2606 if (unlikely(res < 0)) {
2608 }
else if (unlikely(res == 0)) {
2609 PyErr_Format(PyExc_TypeError,
2610 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
2611 "instance instead)",
2612 GET_CALLABLE_NAME((PyObject *)method->m_function),
2613 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
2614 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
2619 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 3);
2621 CHECK_OBJECT_X(result);
2625 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2633 if (function->m_args_simple && 3 + 1 == function->m_args_positional_count) {
2634 PyObject *python_pars[3 + 1];
2636 python_pars[0] = method->m_object;
2637 Py_INCREF(method->m_object);
2639 for (Py_ssize_t i = 0; i < 3; i++) {
2640 python_pars[i + 1] = args[i];
2643 result = function->m_c_code(tstate, function, python_pars);
2644 }
else if (function->m_args_simple &&
2645 3 + 1 + function->m_defaults_given == function->m_args_positional_count) {
2646 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2648 python_pars[0] = method->m_object;
2649 Py_INCREF(method->m_object);
2651 memcpy(python_pars + 1, args, 3 *
sizeof(PyObject *));
2652 memcpy(python_pars + 1 + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2653 function->m_defaults_given *
sizeof(PyObject *));
2655 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
2656 Py_INCREF(python_pars[i]);
2659 result = function->m_c_code(tstate, function, python_pars);
2661 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 3);
2664 Py_LeaveRecursiveCall();
2666 CHECK_OBJECT_X(result);
2670#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
2671 }
else if (PyCFunction_CheckExact(called)) {
2672#if PYTHON_VERSION >= 0x380
2673#ifdef _NUITKA_FULL_COMPAT
2674 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2679 int flags = PyCFunction_GET_FLAGS(called);
2683 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2686 result = func(called, args, 3, NULL);
2688 CHECK_OBJECT_X(result);
2690 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2691 PyObject *self = PyCFunction_GET_SELF(called);
2693 if (flags & METH_KEYWORDS) {
2694 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
2696 result = (*method)(self, pos_args);
2700#ifdef _NUITKA_FULL_COMPAT
2701 Py_LeaveRecursiveCall();
2703 CHECK_OBJECT_X(result);
2705 return Nuitka_CheckFunctionResult(tstate, called, result);
2708 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
2710 if (unlikely(flags & METH_NOARGS)) {
2711 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (3 given)",
2712 ((PyCFunctionObject *)called)->m_ml->ml_name);
2714 }
else if (unlikely(flags & METH_O)) {
2715 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (3 given)",
2716 ((PyCFunctionObject *)called)->m_ml->ml_name);
2718 }
else if (flags & METH_VARARGS) {
2721#ifdef _NUITKA_FULL_COMPAT
2722 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2726 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2727 PyObject *self = PyCFunction_GET_SELF(called);
2731#if PYTHON_VERSION < 0x360
2732 if (flags & METH_KEYWORDS) {
2733 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2735 result = (*method)(self, pos_args);
2739 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
2740 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2741 }
else if (flags == METH_FASTCALL) {
2742#if PYTHON_VERSION < 0x370
2743 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 3, NULL);
2745 result = (*(_PyCFunctionFast)method)(self, &pos_args, 3);
2748 result = (*method)(self, pos_args);
2752#ifdef _NUITKA_FULL_COMPAT
2753 Py_LeaveRecursiveCall();
2756 CHECK_OBJECT_X(result);
2758 return Nuitka_CheckFunctionResult(tstate, called, result);
2762#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
2763 }
else if (PyFunction_Check(called)) {
2764#if PYTHON_VERSION < 0x3b0
2765 PyObject *result = callPythonFunction(called, args, 3);
2767 PyObject *result = _PyFunction_Vectorcall(called, args, 3, NULL);
2769 CHECK_OBJECT_X(result);
2773#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
2774 }
else if (PyType_Check(called)) {
2775 PyTypeObject *type = Py_TYPE(called);
2777 if (type->tp_call == PyType_Type.tp_call) {
2778 PyTypeObject *called_type = (PyTypeObject *)(called);
2780 if (unlikely(called_type->tp_new == NULL)) {
2781 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
2787 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
2788 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
2789 formatCannotInstantiateAbstractClass(tstate, called_type);
2793 obj = called_type->tp_alloc(called_type, 0);
2796 obj = called_type->tp_new(called_type, pos_args, NULL);
2799 if (likely(obj != NULL)) {
2800 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
2805 type = Py_TYPE(obj);
2807 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
2808 if (type->tp_init == default_tp_init_wrapper) {
2810 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
2813 assert(init_method != NULL);
2815 bool is_compiled_function =
false;
2816 bool init_method_needs_release =
false;
2818 if (likely(init_method != NULL)) {
2819 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
2821 if (func == Nuitka_Function_Type.tp_descr_get) {
2822 is_compiled_function =
true;
2823 }
else if (func != NULL) {
2824 init_method = func(init_method, obj, (PyObject *)(type));
2825 init_method_needs_release =
true;
2829 if (unlikely(init_method == NULL)) {
2830 if (!HAS_ERROR_OCCURRED(tstate)) {
2831 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
2832 const_str_plain___init__);
2839 if (is_compiled_function) {
2840 result = Nuitka_CallMethodFunctionPosArgs(
2843 result = CALL_FUNCTION_WITH_POS_ARGS3(tstate, init_method, pos_args);
2844 if (init_method_needs_release) {
2845 Py_DECREF(init_method);
2849 if (unlikely(result == NULL)) {
2856 if (unlikely(result != Py_None)) {
2859 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2864 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
2872 CHECK_OBJECT_X(obj);
2877#if PYTHON_VERSION < 0x300
2878 }
else if (PyClass_Check(called)) {
2879 PyObject *obj = PyInstance_NewRaw(called, NULL);
2881 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
2883 if (unlikely(init_method == NULL)) {
2884 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
2891 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
2895 bool is_compiled_function =
false;
2897 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
2899 if (descr_get == NULL) {
2900 Py_INCREF(init_method);
2901 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
2902 is_compiled_function =
true;
2903 }
else if (descr_get != NULL) {
2904 PyObject *descr_method = descr_get(init_method, obj, called);
2906 if (unlikely(descr_method == NULL)) {
2910 init_method = descr_method;
2914 if (is_compiled_function) {
2915 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
2918 result = CALL_FUNCTION_WITH_POS_ARGS3(tstate, init_method, pos_args);
2919 Py_DECREF(init_method);
2921 if (unlikely(result == NULL)) {
2927 if (unlikely(result != Py_None)) {
2928 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
2932 CHECK_OBJECT_X(obj);
2936#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
2937 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
2938 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2940 if (likely(func != NULL)) {
2941 PyObject *result = func(called, args, 3, NULL);
2943 CHECK_OBJECT_X(result);
2945 return Nuitka_CheckFunctionResult(tstate, called, result);
2952 PRINT_STRING(
"FALLBACK");
2957 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
2959 CHECK_OBJECT_X(result);
2963PyObject *CALL_FUNCTION_WITH_ARGS4(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
2964 CHECK_OBJECT(called);
2965 CHECK_OBJECTS(args, 4);
2967 if (Nuitka_Function_Check(called)) {
2968 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
2975 if (function->m_args_simple && 4 == function->m_args_positional_count) {
2976 for (Py_ssize_t i = 0; i < 4; i++) {
2979 result = function->m_c_code(tstate, function, (PyObject **)args);
2980 }
else if (function->m_args_simple && 4 + function->m_defaults_given == function->m_args_positional_count) {
2981 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2983 memcpy(python_pars, args, 4 *
sizeof(PyObject *));
2984 memcpy(python_pars + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
2985 function->m_defaults_given *
sizeof(PyObject *));
2987 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
2988 Py_INCREF(python_pars[i]);
2991 result = function->m_c_code(tstate, function, python_pars);
2993 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 4);
2996 Py_LeaveRecursiveCall();
2998 CHECK_OBJECT_X(result);
3001 }
else if (Nuitka_Method_Check(called)) {
3004 if (method->m_object == NULL) {
3005 PyObject *self = args[0];
3007 int res = PyObject_IsInstance(self, method->m_class);
3009 if (unlikely(res < 0)) {
3011 }
else if (unlikely(res == 0)) {
3012 PyErr_Format(PyExc_TypeError,
3013 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
3014 "instance instead)",
3015 GET_CALLABLE_NAME((PyObject *)method->m_function),
3016 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
3017 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
3022 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 4);
3024 CHECK_OBJECT_X(result);
3028 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3036 if (function->m_args_simple && 4 + 1 == function->m_args_positional_count) {
3037 PyObject *python_pars[4 + 1];
3039 python_pars[0] = method->m_object;
3040 Py_INCREF(method->m_object);
3042 for (Py_ssize_t i = 0; i < 4; i++) {
3043 python_pars[i + 1] = args[i];
3046 result = function->m_c_code(tstate, function, python_pars);
3047 }
else if (function->m_args_simple &&
3048 4 + 1 + function->m_defaults_given == function->m_args_positional_count) {
3049 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3051 python_pars[0] = method->m_object;
3052 Py_INCREF(method->m_object);
3054 memcpy(python_pars + 1, args, 4 *
sizeof(PyObject *));
3055 memcpy(python_pars + 1 + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
3056 function->m_defaults_given *
sizeof(PyObject *));
3058 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
3059 Py_INCREF(python_pars[i]);
3062 result = function->m_c_code(tstate, function, python_pars);
3064 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 4);
3067 Py_LeaveRecursiveCall();
3069 CHECK_OBJECT_X(result);
3073#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
3074 }
else if (PyCFunction_CheckExact(called)) {
3075#if PYTHON_VERSION >= 0x380
3076#ifdef _NUITKA_FULL_COMPAT
3077 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3082 int flags = PyCFunction_GET_FLAGS(called);
3086 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3089 result = func(called, args, 4, NULL);
3091 CHECK_OBJECT_X(result);
3093 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3094 PyObject *self = PyCFunction_GET_SELF(called);
3096 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3098 if (flags & METH_KEYWORDS) {
3099 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
3101 result = (*method)(self, pos_args);
3104 Py_DECREF(pos_args);
3107#ifdef _NUITKA_FULL_COMPAT
3108 Py_LeaveRecursiveCall();
3110 CHECK_OBJECT_X(result);
3112 return Nuitka_CheckFunctionResult(tstate, called, result);
3115 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
3117 if (unlikely(flags & METH_NOARGS)) {
3118 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (4 given)",
3119 ((PyCFunctionObject *)called)->m_ml->ml_name);
3121 }
else if (unlikely(flags & METH_O)) {
3122 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (4 given)",
3123 ((PyCFunctionObject *)called)->m_ml->ml_name);
3125 }
else if (flags & METH_VARARGS) {
3128#ifdef _NUITKA_FULL_COMPAT
3129 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3133 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3134 PyObject *self = PyCFunction_GET_SELF(called);
3138#if PYTHON_VERSION < 0x360
3139 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3140 if (flags & METH_KEYWORDS) {
3141 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3143 result = (*method)(self, pos_args);
3146 Py_DECREF(pos_args);
3148 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
3149 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3150 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3151 Py_DECREF(pos_args);
3152 }
else if (flags == METH_FASTCALL) {
3153#if PYTHON_VERSION < 0x370
3154 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 4, NULL);
3156 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3157 result = (*(_PyCFunctionFast)method)(self, &pos_args, 4);
3158 Py_DECREF(pos_args);
3161 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3162 result = (*method)(self, pos_args);
3163 Py_DECREF(pos_args);
3167#ifdef _NUITKA_FULL_COMPAT
3168 Py_LeaveRecursiveCall();
3171 CHECK_OBJECT_X(result);
3173 return Nuitka_CheckFunctionResult(tstate, called, result);
3177#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
3178 }
else if (PyFunction_Check(called)) {
3179#if PYTHON_VERSION < 0x3b0
3180 PyObject *result = callPythonFunction(called, args, 4);
3182 PyObject *result = _PyFunction_Vectorcall(called, args, 4, NULL);
3184 CHECK_OBJECT_X(result);
3188#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
3189 }
else if (PyType_Check(called)) {
3190 PyTypeObject *type = Py_TYPE(called);
3192 if (type->tp_call == PyType_Type.tp_call) {
3193 PyTypeObject *called_type = (PyTypeObject *)(called);
3195 if (unlikely(called_type->tp_new == NULL)) {
3196 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
3200 PyObject *pos_args = NULL;
3203 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
3204 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
3205 formatCannotInstantiateAbstractClass(tstate, called_type);
3209 obj = called_type->tp_alloc(called_type, 0);
3212 pos_args = MAKE_TUPLE(tstate, args, 4);
3213 obj = called_type->tp_new(called_type, pos_args, NULL);
3216 if (likely(obj != NULL)) {
3217 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
3218 Py_DECREF(pos_args);
3223 type = Py_TYPE(obj);
3225 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
3226 if (type->tp_init == default_tp_init_wrapper) {
3227 Py_XDECREF(pos_args);
3230 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
3233 assert(init_method != NULL);
3235 bool is_compiled_function =
false;
3236 bool init_method_needs_release =
false;
3238 if (likely(init_method != NULL)) {
3239 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
3241 if (func == Nuitka_Function_Type.tp_descr_get) {
3242 is_compiled_function =
true;
3243 }
else if (func != NULL) {
3244 init_method = func(init_method, obj, (PyObject *)(type));
3245 init_method_needs_release =
true;
3249 if (unlikely(init_method == NULL)) {
3250 if (!HAS_ERROR_OCCURRED(tstate)) {
3251 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
3252 const_str_plain___init__);
3259 if (is_compiled_function) {
3260 result = Nuitka_CallMethodFunctionPosArgs(
3263 result = CALL_FUNCTION_WITH_ARGS4(tstate, init_method, args);
3264 if (init_method_needs_release) {
3265 Py_DECREF(init_method);
3269 if (unlikely(result == NULL)) {
3276 if (unlikely(result != Py_None)) {
3279 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
3283 if (pos_args == NULL) {
3284 pos_args = MAKE_TUPLE(tstate, args, 4);
3287 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
3289 Py_XDECREF(pos_args);
3296 Py_XDECREF(pos_args);
3298 CHECK_OBJECT_X(obj);
3303#if PYTHON_VERSION < 0x300
3304 }
else if (PyClass_Check(called)) {
3305 PyObject *obj = PyInstance_NewRaw(called, NULL);
3307 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
3309 if (unlikely(init_method == NULL)) {
3310 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
3317 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
3321 bool is_compiled_function =
false;
3323 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
3325 if (descr_get == NULL) {
3326 Py_INCREF(init_method);
3327 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
3328 is_compiled_function =
true;
3329 }
else if (descr_get != NULL) {
3330 PyObject *descr_method = descr_get(init_method, obj, called);
3332 if (unlikely(descr_method == NULL)) {
3336 init_method = descr_method;
3340 if (is_compiled_function) {
3341 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
3344 result = CALL_FUNCTION_WITH_ARGS4(tstate, init_method, args);
3345 Py_DECREF(init_method);
3347 if (unlikely(result == NULL)) {
3353 if (unlikely(result != Py_None)) {
3354 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
3358 CHECK_OBJECT_X(obj);
3362#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
3363 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
3364 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3366 if (likely(func != NULL)) {
3367 PyObject *result = func(called, args, 4, NULL);
3369 CHECK_OBJECT_X(result);
3371 return Nuitka_CheckFunctionResult(tstate, called, result);
3378 PRINT_STRING(
"FALLBACK");
3383 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3385 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
3387 Py_DECREF(pos_args);
3389 CHECK_OBJECT_X(result);
3393PyObject *CALL_FUNCTION_WITH_POS_ARGS4(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
3394 assert(PyTuple_CheckExact(pos_args));
3395 assert(PyTuple_GET_SIZE(pos_args) == 4);
3396 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
3397 CHECK_OBJECT(called);
3398 CHECK_OBJECTS(args, 4);
3400 if (Nuitka_Function_Check(called)) {
3401 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3408 if (function->m_args_simple && 4 == function->m_args_positional_count) {
3409 for (Py_ssize_t i = 0; i < 4; i++) {
3412 result = function->m_c_code(tstate, function, (PyObject **)args);
3413 }
else if (function->m_args_simple && 4 + function->m_defaults_given == function->m_args_positional_count) {
3414 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3416 memcpy(python_pars, args, 4 *
sizeof(PyObject *));
3417 memcpy(python_pars + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
3418 function->m_defaults_given *
sizeof(PyObject *));
3420 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
3421 Py_INCREF(python_pars[i]);
3424 result = function->m_c_code(tstate, function, python_pars);
3426 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 4);
3429 Py_LeaveRecursiveCall();
3431 CHECK_OBJECT_X(result);
3434 }
else if (Nuitka_Method_Check(called)) {
3437 if (method->m_object == NULL) {
3438 PyObject *self = args[0];
3440 int res = PyObject_IsInstance(self, method->m_class);
3442 if (unlikely(res < 0)) {
3444 }
else if (unlikely(res == 0)) {
3445 PyErr_Format(PyExc_TypeError,
3446 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
3447 "instance instead)",
3448 GET_CALLABLE_NAME((PyObject *)method->m_function),
3449 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
3450 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
3455 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 4);
3457 CHECK_OBJECT_X(result);
3461 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3469 if (function->m_args_simple && 4 + 1 == function->m_args_positional_count) {
3470 PyObject *python_pars[4 + 1];
3472 python_pars[0] = method->m_object;
3473 Py_INCREF(method->m_object);
3475 for (Py_ssize_t i = 0; i < 4; i++) {
3476 python_pars[i + 1] = args[i];
3479 result = function->m_c_code(tstate, function, python_pars);
3480 }
else if (function->m_args_simple &&
3481 4 + 1 + function->m_defaults_given == function->m_args_positional_count) {
3482 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3484 python_pars[0] = method->m_object;
3485 Py_INCREF(method->m_object);
3487 memcpy(python_pars + 1, args, 4 *
sizeof(PyObject *));
3488 memcpy(python_pars + 1 + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
3489 function->m_defaults_given *
sizeof(PyObject *));
3491 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
3492 Py_INCREF(python_pars[i]);
3495 result = function->m_c_code(tstate, function, python_pars);
3497 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 4);
3500 Py_LeaveRecursiveCall();
3502 CHECK_OBJECT_X(result);
3506#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
3507 }
else if (PyCFunction_CheckExact(called)) {
3508#if PYTHON_VERSION >= 0x380
3509#ifdef _NUITKA_FULL_COMPAT
3510 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3515 int flags = PyCFunction_GET_FLAGS(called);
3519 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3522 result = func(called, args, 4, NULL);
3524 CHECK_OBJECT_X(result);
3526 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3527 PyObject *self = PyCFunction_GET_SELF(called);
3529 if (flags & METH_KEYWORDS) {
3530 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
3532 result = (*method)(self, pos_args);
3536#ifdef _NUITKA_FULL_COMPAT
3537 Py_LeaveRecursiveCall();
3539 CHECK_OBJECT_X(result);
3541 return Nuitka_CheckFunctionResult(tstate, called, result);
3544 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
3546 if (unlikely(flags & METH_NOARGS)) {
3547 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (4 given)",
3548 ((PyCFunctionObject *)called)->m_ml->ml_name);
3550 }
else if (unlikely(flags & METH_O)) {
3551 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (4 given)",
3552 ((PyCFunctionObject *)called)->m_ml->ml_name);
3554 }
else if (flags & METH_VARARGS) {
3557#ifdef _NUITKA_FULL_COMPAT
3558 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3562 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3563 PyObject *self = PyCFunction_GET_SELF(called);
3567#if PYTHON_VERSION < 0x360
3568 if (flags & METH_KEYWORDS) {
3569 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3571 result = (*method)(self, pos_args);
3575 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
3576 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3577 }
else if (flags == METH_FASTCALL) {
3578#if PYTHON_VERSION < 0x370
3579 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 4, NULL);
3581 result = (*(_PyCFunctionFast)method)(self, &pos_args, 4);
3584 result = (*method)(self, pos_args);
3588#ifdef _NUITKA_FULL_COMPAT
3589 Py_LeaveRecursiveCall();
3592 CHECK_OBJECT_X(result);
3594 return Nuitka_CheckFunctionResult(tstate, called, result);
3598#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
3599 }
else if (PyFunction_Check(called)) {
3600#if PYTHON_VERSION < 0x3b0
3601 PyObject *result = callPythonFunction(called, args, 4);
3603 PyObject *result = _PyFunction_Vectorcall(called, args, 4, NULL);
3605 CHECK_OBJECT_X(result);
3609#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
3610 }
else if (PyType_Check(called)) {
3611 PyTypeObject *type = Py_TYPE(called);
3613 if (type->tp_call == PyType_Type.tp_call) {
3614 PyTypeObject *called_type = (PyTypeObject *)(called);
3616 if (unlikely(called_type->tp_new == NULL)) {
3617 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
3623 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
3624 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
3625 formatCannotInstantiateAbstractClass(tstate, called_type);
3629 obj = called_type->tp_alloc(called_type, 0);
3632 obj = called_type->tp_new(called_type, pos_args, NULL);
3635 if (likely(obj != NULL)) {
3636 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
3641 type = Py_TYPE(obj);
3643 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
3644 if (type->tp_init == default_tp_init_wrapper) {
3646 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
3649 assert(init_method != NULL);
3651 bool is_compiled_function =
false;
3652 bool init_method_needs_release =
false;
3654 if (likely(init_method != NULL)) {
3655 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
3657 if (func == Nuitka_Function_Type.tp_descr_get) {
3658 is_compiled_function =
true;
3659 }
else if (func != NULL) {
3660 init_method = func(init_method, obj, (PyObject *)(type));
3661 init_method_needs_release =
true;
3665 if (unlikely(init_method == NULL)) {
3666 if (!HAS_ERROR_OCCURRED(tstate)) {
3667 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
3668 const_str_plain___init__);
3675 if (is_compiled_function) {
3676 result = Nuitka_CallMethodFunctionPosArgs(
3679 result = CALL_FUNCTION_WITH_POS_ARGS4(tstate, init_method, pos_args);
3680 if (init_method_needs_release) {
3681 Py_DECREF(init_method);
3685 if (unlikely(result == NULL)) {
3692 if (unlikely(result != Py_None)) {
3695 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
3700 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
3708 CHECK_OBJECT_X(obj);
3713#if PYTHON_VERSION < 0x300
3714 }
else if (PyClass_Check(called)) {
3715 PyObject *obj = PyInstance_NewRaw(called, NULL);
3717 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
3719 if (unlikely(init_method == NULL)) {
3720 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
3727 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
3731 bool is_compiled_function =
false;
3733 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
3735 if (descr_get == NULL) {
3736 Py_INCREF(init_method);
3737 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
3738 is_compiled_function =
true;
3739 }
else if (descr_get != NULL) {
3740 PyObject *descr_method = descr_get(init_method, obj, called);
3742 if (unlikely(descr_method == NULL)) {
3746 init_method = descr_method;
3750 if (is_compiled_function) {
3751 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
3754 result = CALL_FUNCTION_WITH_POS_ARGS4(tstate, init_method, pos_args);
3755 Py_DECREF(init_method);
3757 if (unlikely(result == NULL)) {
3763 if (unlikely(result != Py_None)) {
3764 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
3768 CHECK_OBJECT_X(obj);
3772#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
3773 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
3774 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3776 if (likely(func != NULL)) {
3777 PyObject *result = func(called, args, 4, NULL);
3779 CHECK_OBJECT_X(result);
3781 return Nuitka_CheckFunctionResult(tstate, called, result);
3788 PRINT_STRING(
"FALLBACK");
3793 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
3795 CHECK_OBJECT_X(result);
3799PyObject *CALL_FUNCTION_WITH_ARGS5(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
3800 CHECK_OBJECT(called);
3801 CHECK_OBJECTS(args, 5);
3803 if (Nuitka_Function_Check(called)) {
3804 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3811 if (function->m_args_simple && 5 == function->m_args_positional_count) {
3812 for (Py_ssize_t i = 0; i < 5; i++) {
3815 result = function->m_c_code(tstate, function, (PyObject **)args);
3816 }
else if (function->m_args_simple && 5 + function->m_defaults_given == function->m_args_positional_count) {
3817 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3819 memcpy(python_pars, args, 5 *
sizeof(PyObject *));
3820 memcpy(python_pars + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
3821 function->m_defaults_given *
sizeof(PyObject *));
3823 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
3824 Py_INCREF(python_pars[i]);
3827 result = function->m_c_code(tstate, function, python_pars);
3829 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 5);
3832 Py_LeaveRecursiveCall();
3834 CHECK_OBJECT_X(result);
3837 }
else if (Nuitka_Method_Check(called)) {
3840 if (method->m_object == NULL) {
3841 PyObject *self = args[0];
3843 int res = PyObject_IsInstance(self, method->m_class);
3845 if (unlikely(res < 0)) {
3847 }
else if (unlikely(res == 0)) {
3848 PyErr_Format(PyExc_TypeError,
3849 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
3850 "instance instead)",
3851 GET_CALLABLE_NAME((PyObject *)method->m_function),
3852 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
3853 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
3858 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 5);
3860 CHECK_OBJECT_X(result);
3864 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3872 if (function->m_args_simple && 5 + 1 == function->m_args_positional_count) {
3873 PyObject *python_pars[5 + 1];
3875 python_pars[0] = method->m_object;
3876 Py_INCREF(method->m_object);
3878 for (Py_ssize_t i = 0; i < 5; i++) {
3879 python_pars[i + 1] = args[i];
3882 result = function->m_c_code(tstate, function, python_pars);
3883 }
else if (function->m_args_simple &&
3884 5 + 1 + function->m_defaults_given == function->m_args_positional_count) {
3885 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3887 python_pars[0] = method->m_object;
3888 Py_INCREF(method->m_object);
3890 memcpy(python_pars + 1, args, 5 *
sizeof(PyObject *));
3891 memcpy(python_pars + 1 + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
3892 function->m_defaults_given *
sizeof(PyObject *));
3894 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
3895 Py_INCREF(python_pars[i]);
3898 result = function->m_c_code(tstate, function, python_pars);
3900 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 5);
3903 Py_LeaveRecursiveCall();
3905 CHECK_OBJECT_X(result);
3909#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
3910 }
else if (PyCFunction_CheckExact(called)) {
3911#if PYTHON_VERSION >= 0x380
3912#ifdef _NUITKA_FULL_COMPAT
3913 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3918 int flags = PyCFunction_GET_FLAGS(called);
3922 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3925 result = func(called, args, 5, NULL);
3927 CHECK_OBJECT_X(result);
3929 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3930 PyObject *self = PyCFunction_GET_SELF(called);
3932 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3934 if (flags & METH_KEYWORDS) {
3935 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
3937 result = (*method)(self, pos_args);
3940 Py_DECREF(pos_args);
3943#ifdef _NUITKA_FULL_COMPAT
3944 Py_LeaveRecursiveCall();
3946 CHECK_OBJECT_X(result);
3948 return Nuitka_CheckFunctionResult(tstate, called, result);
3951 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
3953 if (unlikely(flags & METH_NOARGS)) {
3954 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (5 given)",
3955 ((PyCFunctionObject *)called)->m_ml->ml_name);
3957 }
else if (unlikely(flags & METH_O)) {
3958 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (5 given)",
3959 ((PyCFunctionObject *)called)->m_ml->ml_name);
3961 }
else if (flags & METH_VARARGS) {
3964#ifdef _NUITKA_FULL_COMPAT
3965 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
3969 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3970 PyObject *self = PyCFunction_GET_SELF(called);
3974#if PYTHON_VERSION < 0x360
3975 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3976 if (flags & METH_KEYWORDS) {
3977 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3979 result = (*method)(self, pos_args);
3982 Py_DECREF(pos_args);
3984 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
3985 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3986 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3987 Py_DECREF(pos_args);
3988 }
else if (flags == METH_FASTCALL) {
3989#if PYTHON_VERSION < 0x370
3990 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 5, NULL);
3992 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3993 result = (*(_PyCFunctionFast)method)(self, &pos_args, 5);
3994 Py_DECREF(pos_args);
3997 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3998 result = (*method)(self, pos_args);
3999 Py_DECREF(pos_args);
4003#ifdef _NUITKA_FULL_COMPAT
4004 Py_LeaveRecursiveCall();
4007 CHECK_OBJECT_X(result);
4009 return Nuitka_CheckFunctionResult(tstate, called, result);
4013#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
4014 }
else if (PyFunction_Check(called)) {
4015#if PYTHON_VERSION < 0x3b0
4016 PyObject *result = callPythonFunction(called, args, 5);
4018 PyObject *result = _PyFunction_Vectorcall(called, args, 5, NULL);
4020 CHECK_OBJECT_X(result);
4024#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
4025 }
else if (PyType_Check(called)) {
4026 PyTypeObject *type = Py_TYPE(called);
4028 if (type->tp_call == PyType_Type.tp_call) {
4029 PyTypeObject *called_type = (PyTypeObject *)(called);
4031 if (unlikely(called_type->tp_new == NULL)) {
4032 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
4036 PyObject *pos_args = NULL;
4039 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
4040 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
4041 formatCannotInstantiateAbstractClass(tstate, called_type);
4045 obj = called_type->tp_alloc(called_type, 0);
4048 pos_args = MAKE_TUPLE(tstate, args, 5);
4049 obj = called_type->tp_new(called_type, pos_args, NULL);
4052 if (likely(obj != NULL)) {
4053 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
4054 Py_DECREF(pos_args);
4059 type = Py_TYPE(obj);
4061 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
4062 if (type->tp_init == default_tp_init_wrapper) {
4063 Py_XDECREF(pos_args);
4066 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
4069 assert(init_method != NULL);
4071 bool is_compiled_function =
false;
4072 bool init_method_needs_release =
false;
4074 if (likely(init_method != NULL)) {
4075 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
4077 if (func == Nuitka_Function_Type.tp_descr_get) {
4078 is_compiled_function =
true;
4079 }
else if (func != NULL) {
4080 init_method = func(init_method, obj, (PyObject *)(type));
4081 init_method_needs_release =
true;
4085 if (unlikely(init_method == NULL)) {
4086 if (!HAS_ERROR_OCCURRED(tstate)) {
4087 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
4088 const_str_plain___init__);
4095 if (is_compiled_function) {
4096 result = Nuitka_CallMethodFunctionPosArgs(
4099 result = CALL_FUNCTION_WITH_ARGS5(tstate, init_method, args);
4100 if (init_method_needs_release) {
4101 Py_DECREF(init_method);
4105 if (unlikely(result == NULL)) {
4112 if (unlikely(result != Py_None)) {
4115 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4119 if (pos_args == NULL) {
4120 pos_args = MAKE_TUPLE(tstate, args, 5);
4123 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
4125 Py_XDECREF(pos_args);
4132 Py_XDECREF(pos_args);
4134 CHECK_OBJECT_X(obj);
4139#if PYTHON_VERSION < 0x300
4140 }
else if (PyClass_Check(called)) {
4141 PyObject *obj = PyInstance_NewRaw(called, NULL);
4143 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
4145 if (unlikely(init_method == NULL)) {
4146 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
4153 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
4157 bool is_compiled_function =
false;
4159 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
4161 if (descr_get == NULL) {
4162 Py_INCREF(init_method);
4163 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
4164 is_compiled_function =
true;
4165 }
else if (descr_get != NULL) {
4166 PyObject *descr_method = descr_get(init_method, obj, called);
4168 if (unlikely(descr_method == NULL)) {
4172 init_method = descr_method;
4176 if (is_compiled_function) {
4177 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
4180 result = CALL_FUNCTION_WITH_ARGS5(tstate, init_method, args);
4181 Py_DECREF(init_method);
4183 if (unlikely(result == NULL)) {
4189 if (unlikely(result != Py_None)) {
4190 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4194 CHECK_OBJECT_X(obj);
4198#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
4199 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
4200 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4202 if (likely(func != NULL)) {
4203 PyObject *result = func(called, args, 5, NULL);
4205 CHECK_OBJECT_X(result);
4207 return Nuitka_CheckFunctionResult(tstate, called, result);
4214 PRINT_STRING(
"FALLBACK");
4219 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
4221 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
4223 Py_DECREF(pos_args);
4225 CHECK_OBJECT_X(result);
4229PyObject *CALL_FUNCTION_WITH_POS_ARGS5(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
4230 assert(PyTuple_CheckExact(pos_args));
4231 assert(PyTuple_GET_SIZE(pos_args) == 5);
4232 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
4233 CHECK_OBJECT(called);
4234 CHECK_OBJECTS(args, 5);
4236 if (Nuitka_Function_Check(called)) {
4237 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4244 if (function->m_args_simple && 5 == function->m_args_positional_count) {
4245 for (Py_ssize_t i = 0; i < 5; i++) {
4248 result = function->m_c_code(tstate, function, (PyObject **)args);
4249 }
else if (function->m_args_simple && 5 + function->m_defaults_given == function->m_args_positional_count) {
4250 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4252 memcpy(python_pars, args, 5 *
sizeof(PyObject *));
4253 memcpy(python_pars + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
4254 function->m_defaults_given *
sizeof(PyObject *));
4256 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
4257 Py_INCREF(python_pars[i]);
4260 result = function->m_c_code(tstate, function, python_pars);
4262 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 5);
4265 Py_LeaveRecursiveCall();
4267 CHECK_OBJECT_X(result);
4270 }
else if (Nuitka_Method_Check(called)) {
4273 if (method->m_object == NULL) {
4274 PyObject *self = args[0];
4276 int res = PyObject_IsInstance(self, method->m_class);
4278 if (unlikely(res < 0)) {
4280 }
else if (unlikely(res == 0)) {
4281 PyErr_Format(PyExc_TypeError,
4282 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
4283 "instance instead)",
4284 GET_CALLABLE_NAME((PyObject *)method->m_function),
4285 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
4286 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
4291 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 5);
4293 CHECK_OBJECT_X(result);
4297 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4305 if (function->m_args_simple && 5 + 1 == function->m_args_positional_count) {
4306 PyObject *python_pars[5 + 1];
4308 python_pars[0] = method->m_object;
4309 Py_INCREF(method->m_object);
4311 for (Py_ssize_t i = 0; i < 5; i++) {
4312 python_pars[i + 1] = args[i];
4315 result = function->m_c_code(tstate, function, python_pars);
4316 }
else if (function->m_args_simple &&
4317 5 + 1 + function->m_defaults_given == function->m_args_positional_count) {
4318 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4320 python_pars[0] = method->m_object;
4321 Py_INCREF(method->m_object);
4323 memcpy(python_pars + 1, args, 5 *
sizeof(PyObject *));
4324 memcpy(python_pars + 1 + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
4325 function->m_defaults_given *
sizeof(PyObject *));
4327 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
4328 Py_INCREF(python_pars[i]);
4331 result = function->m_c_code(tstate, function, python_pars);
4333 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 5);
4336 Py_LeaveRecursiveCall();
4338 CHECK_OBJECT_X(result);
4342#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
4343 }
else if (PyCFunction_CheckExact(called)) {
4344#if PYTHON_VERSION >= 0x380
4345#ifdef _NUITKA_FULL_COMPAT
4346 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4351 int flags = PyCFunction_GET_FLAGS(called);
4355 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4358 result = func(called, args, 5, NULL);
4360 CHECK_OBJECT_X(result);
4362 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4363 PyObject *self = PyCFunction_GET_SELF(called);
4365 if (flags & METH_KEYWORDS) {
4366 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
4368 result = (*method)(self, pos_args);
4372#ifdef _NUITKA_FULL_COMPAT
4373 Py_LeaveRecursiveCall();
4375 CHECK_OBJECT_X(result);
4377 return Nuitka_CheckFunctionResult(tstate, called, result);
4380 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
4382 if (unlikely(flags & METH_NOARGS)) {
4383 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (5 given)",
4384 ((PyCFunctionObject *)called)->m_ml->ml_name);
4386 }
else if (unlikely(flags & METH_O)) {
4387 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (5 given)",
4388 ((PyCFunctionObject *)called)->m_ml->ml_name);
4390 }
else if (flags & METH_VARARGS) {
4393#ifdef _NUITKA_FULL_COMPAT
4394 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4398 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4399 PyObject *self = PyCFunction_GET_SELF(called);
4403#if PYTHON_VERSION < 0x360
4404 if (flags & METH_KEYWORDS) {
4405 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4407 result = (*method)(self, pos_args);
4411 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
4412 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4413 }
else if (flags == METH_FASTCALL) {
4414#if PYTHON_VERSION < 0x370
4415 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 5, NULL);
4417 result = (*(_PyCFunctionFast)method)(self, &pos_args, 5);
4420 result = (*method)(self, pos_args);
4424#ifdef _NUITKA_FULL_COMPAT
4425 Py_LeaveRecursiveCall();
4428 CHECK_OBJECT_X(result);
4430 return Nuitka_CheckFunctionResult(tstate, called, result);
4434#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
4435 }
else if (PyFunction_Check(called)) {
4436#if PYTHON_VERSION < 0x3b0
4437 PyObject *result = callPythonFunction(called, args, 5);
4439 PyObject *result = _PyFunction_Vectorcall(called, args, 5, NULL);
4441 CHECK_OBJECT_X(result);
4445#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
4446 }
else if (PyType_Check(called)) {
4447 PyTypeObject *type = Py_TYPE(called);
4449 if (type->tp_call == PyType_Type.tp_call) {
4450 PyTypeObject *called_type = (PyTypeObject *)(called);
4452 if (unlikely(called_type->tp_new == NULL)) {
4453 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
4459 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
4460 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
4461 formatCannotInstantiateAbstractClass(tstate, called_type);
4465 obj = called_type->tp_alloc(called_type, 0);
4468 obj = called_type->tp_new(called_type, pos_args, NULL);
4471 if (likely(obj != NULL)) {
4472 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
4477 type = Py_TYPE(obj);
4479 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
4480 if (type->tp_init == default_tp_init_wrapper) {
4482 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
4485 assert(init_method != NULL);
4487 bool is_compiled_function =
false;
4488 bool init_method_needs_release =
false;
4490 if (likely(init_method != NULL)) {
4491 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
4493 if (func == Nuitka_Function_Type.tp_descr_get) {
4494 is_compiled_function =
true;
4495 }
else if (func != NULL) {
4496 init_method = func(init_method, obj, (PyObject *)(type));
4497 init_method_needs_release =
true;
4501 if (unlikely(init_method == NULL)) {
4502 if (!HAS_ERROR_OCCURRED(tstate)) {
4503 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
4504 const_str_plain___init__);
4511 if (is_compiled_function) {
4512 result = Nuitka_CallMethodFunctionPosArgs(
4515 result = CALL_FUNCTION_WITH_POS_ARGS5(tstate, init_method, pos_args);
4516 if (init_method_needs_release) {
4517 Py_DECREF(init_method);
4521 if (unlikely(result == NULL)) {
4528 if (unlikely(result != Py_None)) {
4531 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4536 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
4544 CHECK_OBJECT_X(obj);
4549#if PYTHON_VERSION < 0x300
4550 }
else if (PyClass_Check(called)) {
4551 PyObject *obj = PyInstance_NewRaw(called, NULL);
4553 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
4555 if (unlikely(init_method == NULL)) {
4556 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
4563 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
4567 bool is_compiled_function =
false;
4569 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
4571 if (descr_get == NULL) {
4572 Py_INCREF(init_method);
4573 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
4574 is_compiled_function =
true;
4575 }
else if (descr_get != NULL) {
4576 PyObject *descr_method = descr_get(init_method, obj, called);
4578 if (unlikely(descr_method == NULL)) {
4582 init_method = descr_method;
4586 if (is_compiled_function) {
4587 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
4590 result = CALL_FUNCTION_WITH_POS_ARGS5(tstate, init_method, pos_args);
4591 Py_DECREF(init_method);
4593 if (unlikely(result == NULL)) {
4599 if (unlikely(result != Py_None)) {
4600 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4604 CHECK_OBJECT_X(obj);
4608#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
4609 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
4610 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4612 if (likely(func != NULL)) {
4613 PyObject *result = func(called, args, 5, NULL);
4615 CHECK_OBJECT_X(result);
4617 return Nuitka_CheckFunctionResult(tstate, called, result);
4624 PRINT_STRING(
"FALLBACK");
4629 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
4631 CHECK_OBJECT_X(result);
4635PyObject *CALL_FUNCTION_WITH_ARGS6(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
4636 CHECK_OBJECT(called);
4637 CHECK_OBJECTS(args, 6);
4639 if (Nuitka_Function_Check(called)) {
4640 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4647 if (function->m_args_simple && 6 == function->m_args_positional_count) {
4648 for (Py_ssize_t i = 0; i < 6; i++) {
4651 result = function->m_c_code(tstate, function, (PyObject **)args);
4652 }
else if (function->m_args_simple && 6 + function->m_defaults_given == function->m_args_positional_count) {
4653 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4655 memcpy(python_pars, args, 6 *
sizeof(PyObject *));
4656 memcpy(python_pars + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
4657 function->m_defaults_given *
sizeof(PyObject *));
4659 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
4660 Py_INCREF(python_pars[i]);
4663 result = function->m_c_code(tstate, function, python_pars);
4665 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 6);
4668 Py_LeaveRecursiveCall();
4670 CHECK_OBJECT_X(result);
4673 }
else if (Nuitka_Method_Check(called)) {
4676 if (method->m_object == NULL) {
4677 PyObject *self = args[0];
4679 int res = PyObject_IsInstance(self, method->m_class);
4681 if (unlikely(res < 0)) {
4683 }
else if (unlikely(res == 0)) {
4684 PyErr_Format(PyExc_TypeError,
4685 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
4686 "instance instead)",
4687 GET_CALLABLE_NAME((PyObject *)method->m_function),
4688 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
4689 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
4694 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 6);
4696 CHECK_OBJECT_X(result);
4700 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4708 if (function->m_args_simple && 6 + 1 == function->m_args_positional_count) {
4709 PyObject *python_pars[6 + 1];
4711 python_pars[0] = method->m_object;
4712 Py_INCREF(method->m_object);
4714 for (Py_ssize_t i = 0; i < 6; i++) {
4715 python_pars[i + 1] = args[i];
4718 result = function->m_c_code(tstate, function, python_pars);
4719 }
else if (function->m_args_simple &&
4720 6 + 1 + function->m_defaults_given == function->m_args_positional_count) {
4721 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4723 python_pars[0] = method->m_object;
4724 Py_INCREF(method->m_object);
4726 memcpy(python_pars + 1, args, 6 *
sizeof(PyObject *));
4727 memcpy(python_pars + 1 + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
4728 function->m_defaults_given *
sizeof(PyObject *));
4730 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
4731 Py_INCREF(python_pars[i]);
4734 result = function->m_c_code(tstate, function, python_pars);
4736 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 6);
4739 Py_LeaveRecursiveCall();
4741 CHECK_OBJECT_X(result);
4745#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
4746 }
else if (PyCFunction_CheckExact(called)) {
4747#if PYTHON_VERSION >= 0x380
4748#ifdef _NUITKA_FULL_COMPAT
4749 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4754 int flags = PyCFunction_GET_FLAGS(called);
4758 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4761 result = func(called, args, 6, NULL);
4763 CHECK_OBJECT_X(result);
4765 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4766 PyObject *self = PyCFunction_GET_SELF(called);
4768 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4770 if (flags & METH_KEYWORDS) {
4771 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
4773 result = (*method)(self, pos_args);
4776 Py_DECREF(pos_args);
4779#ifdef _NUITKA_FULL_COMPAT
4780 Py_LeaveRecursiveCall();
4782 CHECK_OBJECT_X(result);
4784 return Nuitka_CheckFunctionResult(tstate, called, result);
4787 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
4789 if (unlikely(flags & METH_NOARGS)) {
4790 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (6 given)",
4791 ((PyCFunctionObject *)called)->m_ml->ml_name);
4793 }
else if (unlikely(flags & METH_O)) {
4794 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (6 given)",
4795 ((PyCFunctionObject *)called)->m_ml->ml_name);
4797 }
else if (flags & METH_VARARGS) {
4800#ifdef _NUITKA_FULL_COMPAT
4801 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
4805 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4806 PyObject *self = PyCFunction_GET_SELF(called);
4810#if PYTHON_VERSION < 0x360
4811 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4812 if (flags & METH_KEYWORDS) {
4813 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4815 result = (*method)(self, pos_args);
4818 Py_DECREF(pos_args);
4820 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
4821 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4822 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4823 Py_DECREF(pos_args);
4824 }
else if (flags == METH_FASTCALL) {
4825#if PYTHON_VERSION < 0x370
4826 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 6, NULL);
4828 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4829 result = (*(_PyCFunctionFast)method)(self, &pos_args, 6);
4830 Py_DECREF(pos_args);
4833 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4834 result = (*method)(self, pos_args);
4835 Py_DECREF(pos_args);
4839#ifdef _NUITKA_FULL_COMPAT
4840 Py_LeaveRecursiveCall();
4843 CHECK_OBJECT_X(result);
4845 return Nuitka_CheckFunctionResult(tstate, called, result);
4849#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
4850 }
else if (PyFunction_Check(called)) {
4851#if PYTHON_VERSION < 0x3b0
4852 PyObject *result = callPythonFunction(called, args, 6);
4854 PyObject *result = _PyFunction_Vectorcall(called, args, 6, NULL);
4856 CHECK_OBJECT_X(result);
4860#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
4861 }
else if (PyType_Check(called)) {
4862 PyTypeObject *type = Py_TYPE(called);
4864 if (type->tp_call == PyType_Type.tp_call) {
4865 PyTypeObject *called_type = (PyTypeObject *)(called);
4867 if (unlikely(called_type->tp_new == NULL)) {
4868 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
4872 PyObject *pos_args = NULL;
4875 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
4876 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
4877 formatCannotInstantiateAbstractClass(tstate, called_type);
4881 obj = called_type->tp_alloc(called_type, 0);
4884 pos_args = MAKE_TUPLE(tstate, args, 6);
4885 obj = called_type->tp_new(called_type, pos_args, NULL);
4888 if (likely(obj != NULL)) {
4889 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
4890 Py_DECREF(pos_args);
4895 type = Py_TYPE(obj);
4897 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
4898 if (type->tp_init == default_tp_init_wrapper) {
4899 Py_XDECREF(pos_args);
4902 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
4905 assert(init_method != NULL);
4907 bool is_compiled_function =
false;
4908 bool init_method_needs_release =
false;
4910 if (likely(init_method != NULL)) {
4911 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
4913 if (func == Nuitka_Function_Type.tp_descr_get) {
4914 is_compiled_function =
true;
4915 }
else if (func != NULL) {
4916 init_method = func(init_method, obj, (PyObject *)(type));
4917 init_method_needs_release =
true;
4921 if (unlikely(init_method == NULL)) {
4922 if (!HAS_ERROR_OCCURRED(tstate)) {
4923 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
4924 const_str_plain___init__);
4931 if (is_compiled_function) {
4932 result = Nuitka_CallMethodFunctionPosArgs(
4935 result = CALL_FUNCTION_WITH_ARGS6(tstate, init_method, args);
4936 if (init_method_needs_release) {
4937 Py_DECREF(init_method);
4941 if (unlikely(result == NULL)) {
4948 if (unlikely(result != Py_None)) {
4951 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
4955 if (pos_args == NULL) {
4956 pos_args = MAKE_TUPLE(tstate, args, 6);
4959 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
4961 Py_XDECREF(pos_args);
4968 Py_XDECREF(pos_args);
4970 CHECK_OBJECT_X(obj);
4975#if PYTHON_VERSION < 0x300
4976 }
else if (PyClass_Check(called)) {
4977 PyObject *obj = PyInstance_NewRaw(called, NULL);
4979 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
4981 if (unlikely(init_method == NULL)) {
4982 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
4989 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
4993 bool is_compiled_function =
false;
4995 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
4997 if (descr_get == NULL) {
4998 Py_INCREF(init_method);
4999 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
5000 is_compiled_function =
true;
5001 }
else if (descr_get != NULL) {
5002 PyObject *descr_method = descr_get(init_method, obj, called);
5004 if (unlikely(descr_method == NULL)) {
5008 init_method = descr_method;
5012 if (is_compiled_function) {
5013 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
5016 result = CALL_FUNCTION_WITH_ARGS6(tstate, init_method, args);
5017 Py_DECREF(init_method);
5019 if (unlikely(result == NULL)) {
5025 if (unlikely(result != Py_None)) {
5026 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5030 CHECK_OBJECT_X(obj);
5034#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
5035 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
5036 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5038 if (likely(func != NULL)) {
5039 PyObject *result = func(called, args, 6, NULL);
5041 CHECK_OBJECT_X(result);
5043 return Nuitka_CheckFunctionResult(tstate, called, result);
5050 PRINT_STRING(
"FALLBACK");
5055 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
5057 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
5059 Py_DECREF(pos_args);
5061 CHECK_OBJECT_X(result);
5065PyObject *CALL_FUNCTION_WITH_POS_ARGS6(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
5066 assert(PyTuple_CheckExact(pos_args));
5067 assert(PyTuple_GET_SIZE(pos_args) == 6);
5068 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
5069 CHECK_OBJECT(called);
5070 CHECK_OBJECTS(args, 6);
5072 if (Nuitka_Function_Check(called)) {
5073 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5080 if (function->m_args_simple && 6 == function->m_args_positional_count) {
5081 for (Py_ssize_t i = 0; i < 6; i++) {
5084 result = function->m_c_code(tstate, function, (PyObject **)args);
5085 }
else if (function->m_args_simple && 6 + function->m_defaults_given == function->m_args_positional_count) {
5086 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5088 memcpy(python_pars, args, 6 *
sizeof(PyObject *));
5089 memcpy(python_pars + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
5090 function->m_defaults_given *
sizeof(PyObject *));
5092 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
5093 Py_INCREF(python_pars[i]);
5096 result = function->m_c_code(tstate, function, python_pars);
5098 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 6);
5101 Py_LeaveRecursiveCall();
5103 CHECK_OBJECT_X(result);
5106 }
else if (Nuitka_Method_Check(called)) {
5109 if (method->m_object == NULL) {
5110 PyObject *self = args[0];
5112 int res = PyObject_IsInstance(self, method->m_class);
5114 if (unlikely(res < 0)) {
5116 }
else if (unlikely(res == 0)) {
5117 PyErr_Format(PyExc_TypeError,
5118 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
5119 "instance instead)",
5120 GET_CALLABLE_NAME((PyObject *)method->m_function),
5121 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
5122 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
5127 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 6);
5129 CHECK_OBJECT_X(result);
5133 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5141 if (function->m_args_simple && 6 + 1 == function->m_args_positional_count) {
5142 PyObject *python_pars[6 + 1];
5144 python_pars[0] = method->m_object;
5145 Py_INCREF(method->m_object);
5147 for (Py_ssize_t i = 0; i < 6; i++) {
5148 python_pars[i + 1] = args[i];
5151 result = function->m_c_code(tstate, function, python_pars);
5152 }
else if (function->m_args_simple &&
5153 6 + 1 + function->m_defaults_given == function->m_args_positional_count) {
5154 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5156 python_pars[0] = method->m_object;
5157 Py_INCREF(method->m_object);
5159 memcpy(python_pars + 1, args, 6 *
sizeof(PyObject *));
5160 memcpy(python_pars + 1 + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
5161 function->m_defaults_given *
sizeof(PyObject *));
5163 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
5164 Py_INCREF(python_pars[i]);
5167 result = function->m_c_code(tstate, function, python_pars);
5169 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 6);
5172 Py_LeaveRecursiveCall();
5174 CHECK_OBJECT_X(result);
5178#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
5179 }
else if (PyCFunction_CheckExact(called)) {
5180#if PYTHON_VERSION >= 0x380
5181#ifdef _NUITKA_FULL_COMPAT
5182 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5187 int flags = PyCFunction_GET_FLAGS(called);
5191 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5194 result = func(called, args, 6, NULL);
5196 CHECK_OBJECT_X(result);
5198 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5199 PyObject *self = PyCFunction_GET_SELF(called);
5201 if (flags & METH_KEYWORDS) {
5202 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
5204 result = (*method)(self, pos_args);
5208#ifdef _NUITKA_FULL_COMPAT
5209 Py_LeaveRecursiveCall();
5211 CHECK_OBJECT_X(result);
5213 return Nuitka_CheckFunctionResult(tstate, called, result);
5216 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
5218 if (unlikely(flags & METH_NOARGS)) {
5219 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (6 given)",
5220 ((PyCFunctionObject *)called)->m_ml->ml_name);
5222 }
else if (unlikely(flags & METH_O)) {
5223 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (6 given)",
5224 ((PyCFunctionObject *)called)->m_ml->ml_name);
5226 }
else if (flags & METH_VARARGS) {
5229#ifdef _NUITKA_FULL_COMPAT
5230 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5234 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5235 PyObject *self = PyCFunction_GET_SELF(called);
5239#if PYTHON_VERSION < 0x360
5240 if (flags & METH_KEYWORDS) {
5241 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5243 result = (*method)(self, pos_args);
5247 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
5248 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5249 }
else if (flags == METH_FASTCALL) {
5250#if PYTHON_VERSION < 0x370
5251 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 6, NULL);
5253 result = (*(_PyCFunctionFast)method)(self, &pos_args, 6);
5256 result = (*method)(self, pos_args);
5260#ifdef _NUITKA_FULL_COMPAT
5261 Py_LeaveRecursiveCall();
5264 CHECK_OBJECT_X(result);
5266 return Nuitka_CheckFunctionResult(tstate, called, result);
5270#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
5271 }
else if (PyFunction_Check(called)) {
5272#if PYTHON_VERSION < 0x3b0
5273 PyObject *result = callPythonFunction(called, args, 6);
5275 PyObject *result = _PyFunction_Vectorcall(called, args, 6, NULL);
5277 CHECK_OBJECT_X(result);
5281#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
5282 }
else if (PyType_Check(called)) {
5283 PyTypeObject *type = Py_TYPE(called);
5285 if (type->tp_call == PyType_Type.tp_call) {
5286 PyTypeObject *called_type = (PyTypeObject *)(called);
5288 if (unlikely(called_type->tp_new == NULL)) {
5289 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
5295 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
5296 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
5297 formatCannotInstantiateAbstractClass(tstate, called_type);
5301 obj = called_type->tp_alloc(called_type, 0);
5304 obj = called_type->tp_new(called_type, pos_args, NULL);
5307 if (likely(obj != NULL)) {
5308 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
5313 type = Py_TYPE(obj);
5315 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
5316 if (type->tp_init == default_tp_init_wrapper) {
5318 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
5321 assert(init_method != NULL);
5323 bool is_compiled_function =
false;
5324 bool init_method_needs_release =
false;
5326 if (likely(init_method != NULL)) {
5327 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
5329 if (func == Nuitka_Function_Type.tp_descr_get) {
5330 is_compiled_function =
true;
5331 }
else if (func != NULL) {
5332 init_method = func(init_method, obj, (PyObject *)(type));
5333 init_method_needs_release =
true;
5337 if (unlikely(init_method == NULL)) {
5338 if (!HAS_ERROR_OCCURRED(tstate)) {
5339 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
5340 const_str_plain___init__);
5347 if (is_compiled_function) {
5348 result = Nuitka_CallMethodFunctionPosArgs(
5351 result = CALL_FUNCTION_WITH_POS_ARGS6(tstate, init_method, pos_args);
5352 if (init_method_needs_release) {
5353 Py_DECREF(init_method);
5357 if (unlikely(result == NULL)) {
5364 if (unlikely(result != Py_None)) {
5367 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5372 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
5380 CHECK_OBJECT_X(obj);
5385#if PYTHON_VERSION < 0x300
5386 }
else if (PyClass_Check(called)) {
5387 PyObject *obj = PyInstance_NewRaw(called, NULL);
5389 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
5391 if (unlikely(init_method == NULL)) {
5392 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
5399 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
5403 bool is_compiled_function =
false;
5405 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
5407 if (descr_get == NULL) {
5408 Py_INCREF(init_method);
5409 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
5410 is_compiled_function =
true;
5411 }
else if (descr_get != NULL) {
5412 PyObject *descr_method = descr_get(init_method, obj, called);
5414 if (unlikely(descr_method == NULL)) {
5418 init_method = descr_method;
5422 if (is_compiled_function) {
5423 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
5426 result = CALL_FUNCTION_WITH_POS_ARGS6(tstate, init_method, pos_args);
5427 Py_DECREF(init_method);
5429 if (unlikely(result == NULL)) {
5435 if (unlikely(result != Py_None)) {
5436 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5440 CHECK_OBJECT_X(obj);
5444#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
5445 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
5446 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5448 if (likely(func != NULL)) {
5449 PyObject *result = func(called, args, 6, NULL);
5451 CHECK_OBJECT_X(result);
5453 return Nuitka_CheckFunctionResult(tstate, called, result);
5460 PRINT_STRING(
"FALLBACK");
5465 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
5467 CHECK_OBJECT_X(result);
5471PyObject *CALL_FUNCTION_WITH_ARGS7(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
5472 CHECK_OBJECT(called);
5473 CHECK_OBJECTS(args, 7);
5475 if (Nuitka_Function_Check(called)) {
5476 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5483 if (function->m_args_simple && 7 == function->m_args_positional_count) {
5484 for (Py_ssize_t i = 0; i < 7; i++) {
5487 result = function->m_c_code(tstate, function, (PyObject **)args);
5488 }
else if (function->m_args_simple && 7 + function->m_defaults_given == function->m_args_positional_count) {
5489 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5491 memcpy(python_pars, args, 7 *
sizeof(PyObject *));
5492 memcpy(python_pars + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
5493 function->m_defaults_given *
sizeof(PyObject *));
5495 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
5496 Py_INCREF(python_pars[i]);
5499 result = function->m_c_code(tstate, function, python_pars);
5501 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 7);
5504 Py_LeaveRecursiveCall();
5506 CHECK_OBJECT_X(result);
5509 }
else if (Nuitka_Method_Check(called)) {
5512 if (method->m_object == NULL) {
5513 PyObject *self = args[0];
5515 int res = PyObject_IsInstance(self, method->m_class);
5517 if (unlikely(res < 0)) {
5519 }
else if (unlikely(res == 0)) {
5520 PyErr_Format(PyExc_TypeError,
5521 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
5522 "instance instead)",
5523 GET_CALLABLE_NAME((PyObject *)method->m_function),
5524 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
5525 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
5530 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 7);
5532 CHECK_OBJECT_X(result);
5536 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5544 if (function->m_args_simple && 7 + 1 == function->m_args_positional_count) {
5545 PyObject *python_pars[7 + 1];
5547 python_pars[0] = method->m_object;
5548 Py_INCREF(method->m_object);
5550 for (Py_ssize_t i = 0; i < 7; i++) {
5551 python_pars[i + 1] = args[i];
5554 result = function->m_c_code(tstate, function, python_pars);
5555 }
else if (function->m_args_simple &&
5556 7 + 1 + function->m_defaults_given == function->m_args_positional_count) {
5557 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5559 python_pars[0] = method->m_object;
5560 Py_INCREF(method->m_object);
5562 memcpy(python_pars + 1, args, 7 *
sizeof(PyObject *));
5563 memcpy(python_pars + 1 + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
5564 function->m_defaults_given *
sizeof(PyObject *));
5566 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
5567 Py_INCREF(python_pars[i]);
5570 result = function->m_c_code(tstate, function, python_pars);
5572 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 7);
5575 Py_LeaveRecursiveCall();
5577 CHECK_OBJECT_X(result);
5581#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
5582 }
else if (PyCFunction_CheckExact(called)) {
5583#if PYTHON_VERSION >= 0x380
5584#ifdef _NUITKA_FULL_COMPAT
5585 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5590 int flags = PyCFunction_GET_FLAGS(called);
5594 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5597 result = func(called, args, 7, NULL);
5599 CHECK_OBJECT_X(result);
5601 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5602 PyObject *self = PyCFunction_GET_SELF(called);
5604 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5606 if (flags & METH_KEYWORDS) {
5607 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
5609 result = (*method)(self, pos_args);
5612 Py_DECREF(pos_args);
5615#ifdef _NUITKA_FULL_COMPAT
5616 Py_LeaveRecursiveCall();
5618 CHECK_OBJECT_X(result);
5620 return Nuitka_CheckFunctionResult(tstate, called, result);
5623 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
5625 if (unlikely(flags & METH_NOARGS)) {
5626 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (7 given)",
5627 ((PyCFunctionObject *)called)->m_ml->ml_name);
5629 }
else if (unlikely(flags & METH_O)) {
5630 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (7 given)",
5631 ((PyCFunctionObject *)called)->m_ml->ml_name);
5633 }
else if (flags & METH_VARARGS) {
5636#ifdef _NUITKA_FULL_COMPAT
5637 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5641 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5642 PyObject *self = PyCFunction_GET_SELF(called);
5646#if PYTHON_VERSION < 0x360
5647 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5648 if (flags & METH_KEYWORDS) {
5649 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5651 result = (*method)(self, pos_args);
5654 Py_DECREF(pos_args);
5656 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
5657 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5658 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5659 Py_DECREF(pos_args);
5660 }
else if (flags == METH_FASTCALL) {
5661#if PYTHON_VERSION < 0x370
5662 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 7, NULL);
5664 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5665 result = (*(_PyCFunctionFast)method)(self, &pos_args, 7);
5666 Py_DECREF(pos_args);
5669 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5670 result = (*method)(self, pos_args);
5671 Py_DECREF(pos_args);
5675#ifdef _NUITKA_FULL_COMPAT
5676 Py_LeaveRecursiveCall();
5679 CHECK_OBJECT_X(result);
5681 return Nuitka_CheckFunctionResult(tstate, called, result);
5685#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
5686 }
else if (PyFunction_Check(called)) {
5687#if PYTHON_VERSION < 0x3b0
5688 PyObject *result = callPythonFunction(called, args, 7);
5690 PyObject *result = _PyFunction_Vectorcall(called, args, 7, NULL);
5692 CHECK_OBJECT_X(result);
5696#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
5697 }
else if (PyType_Check(called)) {
5698 PyTypeObject *type = Py_TYPE(called);
5700 if (type->tp_call == PyType_Type.tp_call) {
5701 PyTypeObject *called_type = (PyTypeObject *)(called);
5703 if (unlikely(called_type->tp_new == NULL)) {
5704 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
5708 PyObject *pos_args = NULL;
5711 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
5712 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
5713 formatCannotInstantiateAbstractClass(tstate, called_type);
5717 obj = called_type->tp_alloc(called_type, 0);
5720 pos_args = MAKE_TUPLE(tstate, args, 7);
5721 obj = called_type->tp_new(called_type, pos_args, NULL);
5724 if (likely(obj != NULL)) {
5725 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
5726 Py_DECREF(pos_args);
5731 type = Py_TYPE(obj);
5733 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
5734 if (type->tp_init == default_tp_init_wrapper) {
5735 Py_XDECREF(pos_args);
5738 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
5741 assert(init_method != NULL);
5743 bool is_compiled_function =
false;
5744 bool init_method_needs_release =
false;
5746 if (likely(init_method != NULL)) {
5747 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
5749 if (func == Nuitka_Function_Type.tp_descr_get) {
5750 is_compiled_function =
true;
5751 }
else if (func != NULL) {
5752 init_method = func(init_method, obj, (PyObject *)(type));
5753 init_method_needs_release =
true;
5757 if (unlikely(init_method == NULL)) {
5758 if (!HAS_ERROR_OCCURRED(tstate)) {
5759 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
5760 const_str_plain___init__);
5767 if (is_compiled_function) {
5768 result = Nuitka_CallMethodFunctionPosArgs(
5771 result = CALL_FUNCTION_WITH_ARGS7(tstate, init_method, args);
5772 if (init_method_needs_release) {
5773 Py_DECREF(init_method);
5777 if (unlikely(result == NULL)) {
5784 if (unlikely(result != Py_None)) {
5787 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5791 if (pos_args == NULL) {
5792 pos_args = MAKE_TUPLE(tstate, args, 7);
5795 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
5797 Py_XDECREF(pos_args);
5804 Py_XDECREF(pos_args);
5806 CHECK_OBJECT_X(obj);
5811#if PYTHON_VERSION < 0x300
5812 }
else if (PyClass_Check(called)) {
5813 PyObject *obj = PyInstance_NewRaw(called, NULL);
5815 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
5817 if (unlikely(init_method == NULL)) {
5818 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
5825 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
5829 bool is_compiled_function =
false;
5831 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
5833 if (descr_get == NULL) {
5834 Py_INCREF(init_method);
5835 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
5836 is_compiled_function =
true;
5837 }
else if (descr_get != NULL) {
5838 PyObject *descr_method = descr_get(init_method, obj, called);
5840 if (unlikely(descr_method == NULL)) {
5844 init_method = descr_method;
5848 if (is_compiled_function) {
5849 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
5852 result = CALL_FUNCTION_WITH_ARGS7(tstate, init_method, args);
5853 Py_DECREF(init_method);
5855 if (unlikely(result == NULL)) {
5861 if (unlikely(result != Py_None)) {
5862 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
5866 CHECK_OBJECT_X(obj);
5870#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
5871 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
5872 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5874 if (likely(func != NULL)) {
5875 PyObject *result = func(called, args, 7, NULL);
5877 CHECK_OBJECT_X(result);
5879 return Nuitka_CheckFunctionResult(tstate, called, result);
5886 PRINT_STRING(
"FALLBACK");
5891 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5893 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
5895 Py_DECREF(pos_args);
5897 CHECK_OBJECT_X(result);
5901PyObject *CALL_FUNCTION_WITH_POS_ARGS7(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
5902 assert(PyTuple_CheckExact(pos_args));
5903 assert(PyTuple_GET_SIZE(pos_args) == 7);
5904 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
5905 CHECK_OBJECT(called);
5906 CHECK_OBJECTS(args, 7);
5908 if (Nuitka_Function_Check(called)) {
5909 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5916 if (function->m_args_simple && 7 == function->m_args_positional_count) {
5917 for (Py_ssize_t i = 0; i < 7; i++) {
5920 result = function->m_c_code(tstate, function, (PyObject **)args);
5921 }
else if (function->m_args_simple && 7 + function->m_defaults_given == function->m_args_positional_count) {
5922 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5924 memcpy(python_pars, args, 7 *
sizeof(PyObject *));
5925 memcpy(python_pars + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
5926 function->m_defaults_given *
sizeof(PyObject *));
5928 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
5929 Py_INCREF(python_pars[i]);
5932 result = function->m_c_code(tstate, function, python_pars);
5934 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 7);
5937 Py_LeaveRecursiveCall();
5939 CHECK_OBJECT_X(result);
5942 }
else if (Nuitka_Method_Check(called)) {
5945 if (method->m_object == NULL) {
5946 PyObject *self = args[0];
5948 int res = PyObject_IsInstance(self, method->m_class);
5950 if (unlikely(res < 0)) {
5952 }
else if (unlikely(res == 0)) {
5953 PyErr_Format(PyExc_TypeError,
5954 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
5955 "instance instead)",
5956 GET_CALLABLE_NAME((PyObject *)method->m_function),
5957 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
5958 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
5963 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 7);
5965 CHECK_OBJECT_X(result);
5969 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
5977 if (function->m_args_simple && 7 + 1 == function->m_args_positional_count) {
5978 PyObject *python_pars[7 + 1];
5980 python_pars[0] = method->m_object;
5981 Py_INCREF(method->m_object);
5983 for (Py_ssize_t i = 0; i < 7; i++) {
5984 python_pars[i + 1] = args[i];
5987 result = function->m_c_code(tstate, function, python_pars);
5988 }
else if (function->m_args_simple &&
5989 7 + 1 + function->m_defaults_given == function->m_args_positional_count) {
5990 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5992 python_pars[0] = method->m_object;
5993 Py_INCREF(method->m_object);
5995 memcpy(python_pars + 1, args, 7 *
sizeof(PyObject *));
5996 memcpy(python_pars + 1 + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
5997 function->m_defaults_given *
sizeof(PyObject *));
5999 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
6000 Py_INCREF(python_pars[i]);
6003 result = function->m_c_code(tstate, function, python_pars);
6005 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 7);
6008 Py_LeaveRecursiveCall();
6010 CHECK_OBJECT_X(result);
6014#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
6015 }
else if (PyCFunction_CheckExact(called)) {
6016#if PYTHON_VERSION >= 0x380
6017#ifdef _NUITKA_FULL_COMPAT
6018 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6023 int flags = PyCFunction_GET_FLAGS(called);
6027 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6030 result = func(called, args, 7, NULL);
6032 CHECK_OBJECT_X(result);
6034 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6035 PyObject *self = PyCFunction_GET_SELF(called);
6037 if (flags & METH_KEYWORDS) {
6038 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
6040 result = (*method)(self, pos_args);
6044#ifdef _NUITKA_FULL_COMPAT
6045 Py_LeaveRecursiveCall();
6047 CHECK_OBJECT_X(result);
6049 return Nuitka_CheckFunctionResult(tstate, called, result);
6052 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
6054 if (unlikely(flags & METH_NOARGS)) {
6055 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (7 given)",
6056 ((PyCFunctionObject *)called)->m_ml->ml_name);
6058 }
else if (unlikely(flags & METH_O)) {
6059 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (7 given)",
6060 ((PyCFunctionObject *)called)->m_ml->ml_name);
6062 }
else if (flags & METH_VARARGS) {
6065#ifdef _NUITKA_FULL_COMPAT
6066 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6070 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6071 PyObject *self = PyCFunction_GET_SELF(called);
6075#if PYTHON_VERSION < 0x360
6076 if (flags & METH_KEYWORDS) {
6077 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6079 result = (*method)(self, pos_args);
6083 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
6084 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6085 }
else if (flags == METH_FASTCALL) {
6086#if PYTHON_VERSION < 0x370
6087 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 7, NULL);
6089 result = (*(_PyCFunctionFast)method)(self, &pos_args, 7);
6092 result = (*method)(self, pos_args);
6096#ifdef _NUITKA_FULL_COMPAT
6097 Py_LeaveRecursiveCall();
6100 CHECK_OBJECT_X(result);
6102 return Nuitka_CheckFunctionResult(tstate, called, result);
6106#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
6107 }
else if (PyFunction_Check(called)) {
6108#if PYTHON_VERSION < 0x3b0
6109 PyObject *result = callPythonFunction(called, args, 7);
6111 PyObject *result = _PyFunction_Vectorcall(called, args, 7, NULL);
6113 CHECK_OBJECT_X(result);
6117#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
6118 }
else if (PyType_Check(called)) {
6119 PyTypeObject *type = Py_TYPE(called);
6121 if (type->tp_call == PyType_Type.tp_call) {
6122 PyTypeObject *called_type = (PyTypeObject *)(called);
6124 if (unlikely(called_type->tp_new == NULL)) {
6125 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
6131 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
6132 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
6133 formatCannotInstantiateAbstractClass(tstate, called_type);
6137 obj = called_type->tp_alloc(called_type, 0);
6140 obj = called_type->tp_new(called_type, pos_args, NULL);
6143 if (likely(obj != NULL)) {
6144 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
6149 type = Py_TYPE(obj);
6151 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
6152 if (type->tp_init == default_tp_init_wrapper) {
6154 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
6157 assert(init_method != NULL);
6159 bool is_compiled_function =
false;
6160 bool init_method_needs_release =
false;
6162 if (likely(init_method != NULL)) {
6163 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
6165 if (func == Nuitka_Function_Type.tp_descr_get) {
6166 is_compiled_function =
true;
6167 }
else if (func != NULL) {
6168 init_method = func(init_method, obj, (PyObject *)(type));
6169 init_method_needs_release =
true;
6173 if (unlikely(init_method == NULL)) {
6174 if (!HAS_ERROR_OCCURRED(tstate)) {
6175 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
6176 const_str_plain___init__);
6183 if (is_compiled_function) {
6184 result = Nuitka_CallMethodFunctionPosArgs(
6187 result = CALL_FUNCTION_WITH_POS_ARGS7(tstate, init_method, pos_args);
6188 if (init_method_needs_release) {
6189 Py_DECREF(init_method);
6193 if (unlikely(result == NULL)) {
6200 if (unlikely(result != Py_None)) {
6203 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
6208 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
6216 CHECK_OBJECT_X(obj);
6221#if PYTHON_VERSION < 0x300
6222 }
else if (PyClass_Check(called)) {
6223 PyObject *obj = PyInstance_NewRaw(called, NULL);
6225 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
6227 if (unlikely(init_method == NULL)) {
6228 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
6235 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
6239 bool is_compiled_function =
false;
6241 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
6243 if (descr_get == NULL) {
6244 Py_INCREF(init_method);
6245 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
6246 is_compiled_function =
true;
6247 }
else if (descr_get != NULL) {
6248 PyObject *descr_method = descr_get(init_method, obj, called);
6250 if (unlikely(descr_method == NULL)) {
6254 init_method = descr_method;
6258 if (is_compiled_function) {
6259 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
6262 result = CALL_FUNCTION_WITH_POS_ARGS7(tstate, init_method, pos_args);
6263 Py_DECREF(init_method);
6265 if (unlikely(result == NULL)) {
6271 if (unlikely(result != Py_None)) {
6272 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
6276 CHECK_OBJECT_X(obj);
6280#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
6281 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
6282 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6284 if (likely(func != NULL)) {
6285 PyObject *result = func(called, args, 7, NULL);
6287 CHECK_OBJECT_X(result);
6289 return Nuitka_CheckFunctionResult(tstate, called, result);
6296 PRINT_STRING(
"FALLBACK");
6301 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
6303 CHECK_OBJECT_X(result);
6307PyObject *CALL_FUNCTION_WITH_ARGS8(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
6308 CHECK_OBJECT(called);
6309 CHECK_OBJECTS(args, 8);
6311 if (Nuitka_Function_Check(called)) {
6312 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6319 if (function->m_args_simple && 8 == function->m_args_positional_count) {
6320 for (Py_ssize_t i = 0; i < 8; i++) {
6323 result = function->m_c_code(tstate, function, (PyObject **)args);
6324 }
else if (function->m_args_simple && 8 + function->m_defaults_given == function->m_args_positional_count) {
6325 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6327 memcpy(python_pars, args, 8 *
sizeof(PyObject *));
6328 memcpy(python_pars + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6329 function->m_defaults_given *
sizeof(PyObject *));
6331 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
6332 Py_INCREF(python_pars[i]);
6335 result = function->m_c_code(tstate, function, python_pars);
6337 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 8);
6340 Py_LeaveRecursiveCall();
6342 CHECK_OBJECT_X(result);
6345 }
else if (Nuitka_Method_Check(called)) {
6348 if (method->m_object == NULL) {
6349 PyObject *self = args[0];
6351 int res = PyObject_IsInstance(self, method->m_class);
6353 if (unlikely(res < 0)) {
6355 }
else if (unlikely(res == 0)) {
6356 PyErr_Format(PyExc_TypeError,
6357 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
6358 "instance instead)",
6359 GET_CALLABLE_NAME((PyObject *)method->m_function),
6360 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
6361 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
6366 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 8);
6368 CHECK_OBJECT_X(result);
6372 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6380 if (function->m_args_simple && 8 + 1 == function->m_args_positional_count) {
6381 PyObject *python_pars[8 + 1];
6383 python_pars[0] = method->m_object;
6384 Py_INCREF(method->m_object);
6386 for (Py_ssize_t i = 0; i < 8; i++) {
6387 python_pars[i + 1] = args[i];
6390 result = function->m_c_code(tstate, function, python_pars);
6391 }
else if (function->m_args_simple &&
6392 8 + 1 + function->m_defaults_given == function->m_args_positional_count) {
6393 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6395 python_pars[0] = method->m_object;
6396 Py_INCREF(method->m_object);
6398 memcpy(python_pars + 1, args, 8 *
sizeof(PyObject *));
6399 memcpy(python_pars + 1 + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6400 function->m_defaults_given *
sizeof(PyObject *));
6402 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
6403 Py_INCREF(python_pars[i]);
6406 result = function->m_c_code(tstate, function, python_pars);
6408 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 8);
6411 Py_LeaveRecursiveCall();
6413 CHECK_OBJECT_X(result);
6417#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
6418 }
else if (PyCFunction_CheckExact(called)) {
6419#if PYTHON_VERSION >= 0x380
6420#ifdef _NUITKA_FULL_COMPAT
6421 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6426 int flags = PyCFunction_GET_FLAGS(called);
6430 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6433 result = func(called, args, 8, NULL);
6435 CHECK_OBJECT_X(result);
6437 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6438 PyObject *self = PyCFunction_GET_SELF(called);
6440 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6442 if (flags & METH_KEYWORDS) {
6443 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
6445 result = (*method)(self, pos_args);
6448 Py_DECREF(pos_args);
6451#ifdef _NUITKA_FULL_COMPAT
6452 Py_LeaveRecursiveCall();
6454 CHECK_OBJECT_X(result);
6456 return Nuitka_CheckFunctionResult(tstate, called, result);
6459 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
6461 if (unlikely(flags & METH_NOARGS)) {
6462 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (8 given)",
6463 ((PyCFunctionObject *)called)->m_ml->ml_name);
6465 }
else if (unlikely(flags & METH_O)) {
6466 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (8 given)",
6467 ((PyCFunctionObject *)called)->m_ml->ml_name);
6469 }
else if (flags & METH_VARARGS) {
6472#ifdef _NUITKA_FULL_COMPAT
6473 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6477 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6478 PyObject *self = PyCFunction_GET_SELF(called);
6482#if PYTHON_VERSION < 0x360
6483 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6484 if (flags & METH_KEYWORDS) {
6485 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6487 result = (*method)(self, pos_args);
6490 Py_DECREF(pos_args);
6492 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
6493 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6494 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6495 Py_DECREF(pos_args);
6496 }
else if (flags == METH_FASTCALL) {
6497#if PYTHON_VERSION < 0x370
6498 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 8, NULL);
6500 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6501 result = (*(_PyCFunctionFast)method)(self, &pos_args, 8);
6502 Py_DECREF(pos_args);
6505 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6506 result = (*method)(self, pos_args);
6507 Py_DECREF(pos_args);
6511#ifdef _NUITKA_FULL_COMPAT
6512 Py_LeaveRecursiveCall();
6515 CHECK_OBJECT_X(result);
6517 return Nuitka_CheckFunctionResult(tstate, called, result);
6521#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
6522 }
else if (PyFunction_Check(called)) {
6523#if PYTHON_VERSION < 0x3b0
6524 PyObject *result = callPythonFunction(called, args, 8);
6526 PyObject *result = _PyFunction_Vectorcall(called, args, 8, NULL);
6528 CHECK_OBJECT_X(result);
6532#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
6533 }
else if (PyType_Check(called)) {
6534 PyTypeObject *type = Py_TYPE(called);
6536 if (type->tp_call == PyType_Type.tp_call) {
6537 PyTypeObject *called_type = (PyTypeObject *)(called);
6539 if (unlikely(called_type->tp_new == NULL)) {
6540 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
6544 PyObject *pos_args = NULL;
6547 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
6548 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
6549 formatCannotInstantiateAbstractClass(tstate, called_type);
6553 obj = called_type->tp_alloc(called_type, 0);
6556 pos_args = MAKE_TUPLE(tstate, args, 8);
6557 obj = called_type->tp_new(called_type, pos_args, NULL);
6560 if (likely(obj != NULL)) {
6561 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
6562 Py_DECREF(pos_args);
6567 type = Py_TYPE(obj);
6569 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
6570 if (type->tp_init == default_tp_init_wrapper) {
6571 Py_XDECREF(pos_args);
6574 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
6577 assert(init_method != NULL);
6579 bool is_compiled_function =
false;
6580 bool init_method_needs_release =
false;
6582 if (likely(init_method != NULL)) {
6583 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
6585 if (func == Nuitka_Function_Type.tp_descr_get) {
6586 is_compiled_function =
true;
6587 }
else if (func != NULL) {
6588 init_method = func(init_method, obj, (PyObject *)(type));
6589 init_method_needs_release =
true;
6593 if (unlikely(init_method == NULL)) {
6594 if (!HAS_ERROR_OCCURRED(tstate)) {
6595 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
6596 const_str_plain___init__);
6603 if (is_compiled_function) {
6604 result = Nuitka_CallMethodFunctionPosArgs(
6607 result = CALL_FUNCTION_WITH_ARGS8(tstate, init_method, args);
6608 if (init_method_needs_release) {
6609 Py_DECREF(init_method);
6613 if (unlikely(result == NULL)) {
6620 if (unlikely(result != Py_None)) {
6623 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
6627 if (pos_args == NULL) {
6628 pos_args = MAKE_TUPLE(tstate, args, 8);
6631 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
6633 Py_XDECREF(pos_args);
6640 Py_XDECREF(pos_args);
6642 CHECK_OBJECT_X(obj);
6647#if PYTHON_VERSION < 0x300
6648 }
else if (PyClass_Check(called)) {
6649 PyObject *obj = PyInstance_NewRaw(called, NULL);
6651 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
6653 if (unlikely(init_method == NULL)) {
6654 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
6661 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
6665 bool is_compiled_function =
false;
6667 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
6669 if (descr_get == NULL) {
6670 Py_INCREF(init_method);
6671 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
6672 is_compiled_function =
true;
6673 }
else if (descr_get != NULL) {
6674 PyObject *descr_method = descr_get(init_method, obj, called);
6676 if (unlikely(descr_method == NULL)) {
6680 init_method = descr_method;
6684 if (is_compiled_function) {
6685 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
6688 result = CALL_FUNCTION_WITH_ARGS8(tstate, init_method, args);
6689 Py_DECREF(init_method);
6691 if (unlikely(result == NULL)) {
6697 if (unlikely(result != Py_None)) {
6698 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
6702 CHECK_OBJECT_X(obj);
6706#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
6707 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
6708 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6710 if (likely(func != NULL)) {
6711 PyObject *result = func(called, args, 8, NULL);
6713 CHECK_OBJECT_X(result);
6715 return Nuitka_CheckFunctionResult(tstate, called, result);
6722 PRINT_STRING(
"FALLBACK");
6727 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6729 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
6731 Py_DECREF(pos_args);
6733 CHECK_OBJECT_X(result);
6737PyObject *CALL_FUNCTION_WITH_POS_ARGS8(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
6738 assert(PyTuple_CheckExact(pos_args));
6739 assert(PyTuple_GET_SIZE(pos_args) == 8);
6740 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
6741 CHECK_OBJECT(called);
6742 CHECK_OBJECTS(args, 8);
6744 if (Nuitka_Function_Check(called)) {
6745 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6752 if (function->m_args_simple && 8 == function->m_args_positional_count) {
6753 for (Py_ssize_t i = 0; i < 8; i++) {
6756 result = function->m_c_code(tstate, function, (PyObject **)args);
6757 }
else if (function->m_args_simple && 8 + function->m_defaults_given == function->m_args_positional_count) {
6758 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6760 memcpy(python_pars, args, 8 *
sizeof(PyObject *));
6761 memcpy(python_pars + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6762 function->m_defaults_given *
sizeof(PyObject *));
6764 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
6765 Py_INCREF(python_pars[i]);
6768 result = function->m_c_code(tstate, function, python_pars);
6770 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 8);
6773 Py_LeaveRecursiveCall();
6775 CHECK_OBJECT_X(result);
6778 }
else if (Nuitka_Method_Check(called)) {
6781 if (method->m_object == NULL) {
6782 PyObject *self = args[0];
6784 int res = PyObject_IsInstance(self, method->m_class);
6786 if (unlikely(res < 0)) {
6788 }
else if (unlikely(res == 0)) {
6789 PyErr_Format(PyExc_TypeError,
6790 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
6791 "instance instead)",
6792 GET_CALLABLE_NAME((PyObject *)method->m_function),
6793 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
6794 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
6799 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 8);
6801 CHECK_OBJECT_X(result);
6805 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6813 if (function->m_args_simple && 8 + 1 == function->m_args_positional_count) {
6814 PyObject *python_pars[8 + 1];
6816 python_pars[0] = method->m_object;
6817 Py_INCREF(method->m_object);
6819 for (Py_ssize_t i = 0; i < 8; i++) {
6820 python_pars[i + 1] = args[i];
6823 result = function->m_c_code(tstate, function, python_pars);
6824 }
else if (function->m_args_simple &&
6825 8 + 1 + function->m_defaults_given == function->m_args_positional_count) {
6826 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6828 python_pars[0] = method->m_object;
6829 Py_INCREF(method->m_object);
6831 memcpy(python_pars + 1, args, 8 *
sizeof(PyObject *));
6832 memcpy(python_pars + 1 + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6833 function->m_defaults_given *
sizeof(PyObject *));
6835 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
6836 Py_INCREF(python_pars[i]);
6839 result = function->m_c_code(tstate, function, python_pars);
6841 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 8);
6844 Py_LeaveRecursiveCall();
6846 CHECK_OBJECT_X(result);
6850#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
6851 }
else if (PyCFunction_CheckExact(called)) {
6852#if PYTHON_VERSION >= 0x380
6853#ifdef _NUITKA_FULL_COMPAT
6854 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6859 int flags = PyCFunction_GET_FLAGS(called);
6863 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6866 result = func(called, args, 8, NULL);
6868 CHECK_OBJECT_X(result);
6870 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6871 PyObject *self = PyCFunction_GET_SELF(called);
6873 if (flags & METH_KEYWORDS) {
6874 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
6876 result = (*method)(self, pos_args);
6880#ifdef _NUITKA_FULL_COMPAT
6881 Py_LeaveRecursiveCall();
6883 CHECK_OBJECT_X(result);
6885 return Nuitka_CheckFunctionResult(tstate, called, result);
6888 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
6890 if (unlikely(flags & METH_NOARGS)) {
6891 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (8 given)",
6892 ((PyCFunctionObject *)called)->m_ml->ml_name);
6894 }
else if (unlikely(flags & METH_O)) {
6895 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (8 given)",
6896 ((PyCFunctionObject *)called)->m_ml->ml_name);
6898 }
else if (flags & METH_VARARGS) {
6901#ifdef _NUITKA_FULL_COMPAT
6902 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
6906 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6907 PyObject *self = PyCFunction_GET_SELF(called);
6911#if PYTHON_VERSION < 0x360
6912 if (flags & METH_KEYWORDS) {
6913 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6915 result = (*method)(self, pos_args);
6919 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
6920 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6921 }
else if (flags == METH_FASTCALL) {
6922#if PYTHON_VERSION < 0x370
6923 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 8, NULL);
6925 result = (*(_PyCFunctionFast)method)(self, &pos_args, 8);
6928 result = (*method)(self, pos_args);
6932#ifdef _NUITKA_FULL_COMPAT
6933 Py_LeaveRecursiveCall();
6936 CHECK_OBJECT_X(result);
6938 return Nuitka_CheckFunctionResult(tstate, called, result);
6942#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
6943 }
else if (PyFunction_Check(called)) {
6944#if PYTHON_VERSION < 0x3b0
6945 PyObject *result = callPythonFunction(called, args, 8);
6947 PyObject *result = _PyFunction_Vectorcall(called, args, 8, NULL);
6949 CHECK_OBJECT_X(result);
6953#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
6954 }
else if (PyType_Check(called)) {
6955 PyTypeObject *type = Py_TYPE(called);
6957 if (type->tp_call == PyType_Type.tp_call) {
6958 PyTypeObject *called_type = (PyTypeObject *)(called);
6960 if (unlikely(called_type->tp_new == NULL)) {
6961 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
6967 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
6968 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
6969 formatCannotInstantiateAbstractClass(tstate, called_type);
6973 obj = called_type->tp_alloc(called_type, 0);
6976 obj = called_type->tp_new(called_type, pos_args, NULL);
6979 if (likely(obj != NULL)) {
6980 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
6985 type = Py_TYPE(obj);
6987 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
6988 if (type->tp_init == default_tp_init_wrapper) {
6990 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
6993 assert(init_method != NULL);
6995 bool is_compiled_function =
false;
6996 bool init_method_needs_release =
false;
6998 if (likely(init_method != NULL)) {
6999 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
7001 if (func == Nuitka_Function_Type.tp_descr_get) {
7002 is_compiled_function =
true;
7003 }
else if (func != NULL) {
7004 init_method = func(init_method, obj, (PyObject *)(type));
7005 init_method_needs_release =
true;
7009 if (unlikely(init_method == NULL)) {
7010 if (!HAS_ERROR_OCCURRED(tstate)) {
7011 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
7012 const_str_plain___init__);
7019 if (is_compiled_function) {
7020 result = Nuitka_CallMethodFunctionPosArgs(
7023 result = CALL_FUNCTION_WITH_POS_ARGS8(tstate, init_method, pos_args);
7024 if (init_method_needs_release) {
7025 Py_DECREF(init_method);
7029 if (unlikely(result == NULL)) {
7036 if (unlikely(result != Py_None)) {
7039 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7044 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
7052 CHECK_OBJECT_X(obj);
7057#if PYTHON_VERSION < 0x300
7058 }
else if (PyClass_Check(called)) {
7059 PyObject *obj = PyInstance_NewRaw(called, NULL);
7061 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
7063 if (unlikely(init_method == NULL)) {
7064 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
7071 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
7075 bool is_compiled_function =
false;
7077 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
7079 if (descr_get == NULL) {
7080 Py_INCREF(init_method);
7081 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
7082 is_compiled_function =
true;
7083 }
else if (descr_get != NULL) {
7084 PyObject *descr_method = descr_get(init_method, obj, called);
7086 if (unlikely(descr_method == NULL)) {
7090 init_method = descr_method;
7094 if (is_compiled_function) {
7095 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
7098 result = CALL_FUNCTION_WITH_POS_ARGS8(tstate, init_method, pos_args);
7099 Py_DECREF(init_method);
7101 if (unlikely(result == NULL)) {
7107 if (unlikely(result != Py_None)) {
7108 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7112 CHECK_OBJECT_X(obj);
7116#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
7117 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
7118 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7120 if (likely(func != NULL)) {
7121 PyObject *result = func(called, args, 8, NULL);
7123 CHECK_OBJECT_X(result);
7125 return Nuitka_CheckFunctionResult(tstate, called, result);
7132 PRINT_STRING(
"FALLBACK");
7137 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
7139 CHECK_OBJECT_X(result);
7143PyObject *CALL_FUNCTION_WITH_ARGS9(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
7144 CHECK_OBJECT(called);
7145 CHECK_OBJECTS(args, 9);
7147 if (Nuitka_Function_Check(called)) {
7148 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7155 if (function->m_args_simple && 9 == function->m_args_positional_count) {
7156 for (Py_ssize_t i = 0; i < 9; i++) {
7159 result = function->m_c_code(tstate, function, (PyObject **)args);
7160 }
else if (function->m_args_simple && 9 + function->m_defaults_given == function->m_args_positional_count) {
7161 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7163 memcpy(python_pars, args, 9 *
sizeof(PyObject *));
7164 memcpy(python_pars + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7165 function->m_defaults_given *
sizeof(PyObject *));
7167 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
7168 Py_INCREF(python_pars[i]);
7171 result = function->m_c_code(tstate, function, python_pars);
7173 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 9);
7176 Py_LeaveRecursiveCall();
7178 CHECK_OBJECT_X(result);
7181 }
else if (Nuitka_Method_Check(called)) {
7184 if (method->m_object == NULL) {
7185 PyObject *self = args[0];
7187 int res = PyObject_IsInstance(self, method->m_class);
7189 if (unlikely(res < 0)) {
7191 }
else if (unlikely(res == 0)) {
7192 PyErr_Format(PyExc_TypeError,
7193 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
7194 "instance instead)",
7195 GET_CALLABLE_NAME((PyObject *)method->m_function),
7196 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
7197 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
7202 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 9);
7204 CHECK_OBJECT_X(result);
7208 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7216 if (function->m_args_simple && 9 + 1 == function->m_args_positional_count) {
7217 PyObject *python_pars[9 + 1];
7219 python_pars[0] = method->m_object;
7220 Py_INCREF(method->m_object);
7222 for (Py_ssize_t i = 0; i < 9; i++) {
7223 python_pars[i + 1] = args[i];
7226 result = function->m_c_code(tstate, function, python_pars);
7227 }
else if (function->m_args_simple &&
7228 9 + 1 + function->m_defaults_given == function->m_args_positional_count) {
7229 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7231 python_pars[0] = method->m_object;
7232 Py_INCREF(method->m_object);
7234 memcpy(python_pars + 1, args, 9 *
sizeof(PyObject *));
7235 memcpy(python_pars + 1 + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7236 function->m_defaults_given *
sizeof(PyObject *));
7238 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
7239 Py_INCREF(python_pars[i]);
7242 result = function->m_c_code(tstate, function, python_pars);
7244 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 9);
7247 Py_LeaveRecursiveCall();
7249 CHECK_OBJECT_X(result);
7253#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
7254 }
else if (PyCFunction_CheckExact(called)) {
7255#if PYTHON_VERSION >= 0x380
7256#ifdef _NUITKA_FULL_COMPAT
7257 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7262 int flags = PyCFunction_GET_FLAGS(called);
7266 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7269 result = func(called, args, 9, NULL);
7271 CHECK_OBJECT_X(result);
7273 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7274 PyObject *self = PyCFunction_GET_SELF(called);
7276 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7278 if (flags & METH_KEYWORDS) {
7279 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
7281 result = (*method)(self, pos_args);
7284 Py_DECREF(pos_args);
7287#ifdef _NUITKA_FULL_COMPAT
7288 Py_LeaveRecursiveCall();
7290 CHECK_OBJECT_X(result);
7292 return Nuitka_CheckFunctionResult(tstate, called, result);
7295 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
7297 if (unlikely(flags & METH_NOARGS)) {
7298 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (9 given)",
7299 ((PyCFunctionObject *)called)->m_ml->ml_name);
7301 }
else if (unlikely(flags & METH_O)) {
7302 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (9 given)",
7303 ((PyCFunctionObject *)called)->m_ml->ml_name);
7305 }
else if (flags & METH_VARARGS) {
7308#ifdef _NUITKA_FULL_COMPAT
7309 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7313 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7314 PyObject *self = PyCFunction_GET_SELF(called);
7318#if PYTHON_VERSION < 0x360
7319 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7320 if (flags & METH_KEYWORDS) {
7321 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7323 result = (*method)(self, pos_args);
7326 Py_DECREF(pos_args);
7328 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
7329 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7330 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7331 Py_DECREF(pos_args);
7332 }
else if (flags == METH_FASTCALL) {
7333#if PYTHON_VERSION < 0x370
7334 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 9, NULL);
7336 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7337 result = (*(_PyCFunctionFast)method)(self, &pos_args, 9);
7338 Py_DECREF(pos_args);
7341 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7342 result = (*method)(self, pos_args);
7343 Py_DECREF(pos_args);
7347#ifdef _NUITKA_FULL_COMPAT
7348 Py_LeaveRecursiveCall();
7351 CHECK_OBJECT_X(result);
7353 return Nuitka_CheckFunctionResult(tstate, called, result);
7357#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
7358 }
else if (PyFunction_Check(called)) {
7359#if PYTHON_VERSION < 0x3b0
7360 PyObject *result = callPythonFunction(called, args, 9);
7362 PyObject *result = _PyFunction_Vectorcall(called, args, 9, NULL);
7364 CHECK_OBJECT_X(result);
7368#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
7369 }
else if (PyType_Check(called)) {
7370 PyTypeObject *type = Py_TYPE(called);
7372 if (type->tp_call == PyType_Type.tp_call) {
7373 PyTypeObject *called_type = (PyTypeObject *)(called);
7375 if (unlikely(called_type->tp_new == NULL)) {
7376 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
7380 PyObject *pos_args = NULL;
7383 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
7384 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
7385 formatCannotInstantiateAbstractClass(tstate, called_type);
7389 obj = called_type->tp_alloc(called_type, 0);
7392 pos_args = MAKE_TUPLE(tstate, args, 9);
7393 obj = called_type->tp_new(called_type, pos_args, NULL);
7396 if (likely(obj != NULL)) {
7397 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
7398 Py_DECREF(pos_args);
7403 type = Py_TYPE(obj);
7405 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
7406 if (type->tp_init == default_tp_init_wrapper) {
7407 Py_XDECREF(pos_args);
7410 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
7413 assert(init_method != NULL);
7415 bool is_compiled_function =
false;
7416 bool init_method_needs_release =
false;
7418 if (likely(init_method != NULL)) {
7419 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
7421 if (func == Nuitka_Function_Type.tp_descr_get) {
7422 is_compiled_function =
true;
7423 }
else if (func != NULL) {
7424 init_method = func(init_method, obj, (PyObject *)(type));
7425 init_method_needs_release =
true;
7429 if (unlikely(init_method == NULL)) {
7430 if (!HAS_ERROR_OCCURRED(tstate)) {
7431 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
7432 const_str_plain___init__);
7439 if (is_compiled_function) {
7440 result = Nuitka_CallMethodFunctionPosArgs(
7443 result = CALL_FUNCTION_WITH_ARGS9(tstate, init_method, args);
7444 if (init_method_needs_release) {
7445 Py_DECREF(init_method);
7449 if (unlikely(result == NULL)) {
7456 if (unlikely(result != Py_None)) {
7459 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7463 if (pos_args == NULL) {
7464 pos_args = MAKE_TUPLE(tstate, args, 9);
7467 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
7469 Py_XDECREF(pos_args);
7476 Py_XDECREF(pos_args);
7478 CHECK_OBJECT_X(obj);
7483#if PYTHON_VERSION < 0x300
7484 }
else if (PyClass_Check(called)) {
7485 PyObject *obj = PyInstance_NewRaw(called, NULL);
7487 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
7489 if (unlikely(init_method == NULL)) {
7490 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
7497 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
7501 bool is_compiled_function =
false;
7503 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
7505 if (descr_get == NULL) {
7506 Py_INCREF(init_method);
7507 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
7508 is_compiled_function =
true;
7509 }
else if (descr_get != NULL) {
7510 PyObject *descr_method = descr_get(init_method, obj, called);
7512 if (unlikely(descr_method == NULL)) {
7516 init_method = descr_method;
7520 if (is_compiled_function) {
7521 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
7524 result = CALL_FUNCTION_WITH_ARGS9(tstate, init_method, args);
7525 Py_DECREF(init_method);
7527 if (unlikely(result == NULL)) {
7533 if (unlikely(result != Py_None)) {
7534 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7538 CHECK_OBJECT_X(obj);
7542#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
7543 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
7544 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7546 if (likely(func != NULL)) {
7547 PyObject *result = func(called, args, 9, NULL);
7549 CHECK_OBJECT_X(result);
7551 return Nuitka_CheckFunctionResult(tstate, called, result);
7558 PRINT_STRING(
"FALLBACK");
7563 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7565 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
7567 Py_DECREF(pos_args);
7569 CHECK_OBJECT_X(result);
7573PyObject *CALL_FUNCTION_WITH_POS_ARGS9(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
7574 assert(PyTuple_CheckExact(pos_args));
7575 assert(PyTuple_GET_SIZE(pos_args) == 9);
7576 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
7577 CHECK_OBJECT(called);
7578 CHECK_OBJECTS(args, 9);
7580 if (Nuitka_Function_Check(called)) {
7581 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7588 if (function->m_args_simple && 9 == function->m_args_positional_count) {
7589 for (Py_ssize_t i = 0; i < 9; i++) {
7592 result = function->m_c_code(tstate, function, (PyObject **)args);
7593 }
else if (function->m_args_simple && 9 + function->m_defaults_given == function->m_args_positional_count) {
7594 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7596 memcpy(python_pars, args, 9 *
sizeof(PyObject *));
7597 memcpy(python_pars + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7598 function->m_defaults_given *
sizeof(PyObject *));
7600 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
7601 Py_INCREF(python_pars[i]);
7604 result = function->m_c_code(tstate, function, python_pars);
7606 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 9);
7609 Py_LeaveRecursiveCall();
7611 CHECK_OBJECT_X(result);
7614 }
else if (Nuitka_Method_Check(called)) {
7617 if (method->m_object == NULL) {
7618 PyObject *self = args[0];
7620 int res = PyObject_IsInstance(self, method->m_class);
7622 if (unlikely(res < 0)) {
7624 }
else if (unlikely(res == 0)) {
7625 PyErr_Format(PyExc_TypeError,
7626 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
7627 "instance instead)",
7628 GET_CALLABLE_NAME((PyObject *)method->m_function),
7629 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
7630 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
7635 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 9);
7637 CHECK_OBJECT_X(result);
7641 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7649 if (function->m_args_simple && 9 + 1 == function->m_args_positional_count) {
7650 PyObject *python_pars[9 + 1];
7652 python_pars[0] = method->m_object;
7653 Py_INCREF(method->m_object);
7655 for (Py_ssize_t i = 0; i < 9; i++) {
7656 python_pars[i + 1] = args[i];
7659 result = function->m_c_code(tstate, function, python_pars);
7660 }
else if (function->m_args_simple &&
7661 9 + 1 + function->m_defaults_given == function->m_args_positional_count) {
7662 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7664 python_pars[0] = method->m_object;
7665 Py_INCREF(method->m_object);
7667 memcpy(python_pars + 1, args, 9 *
sizeof(PyObject *));
7668 memcpy(python_pars + 1 + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7669 function->m_defaults_given *
sizeof(PyObject *));
7671 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
7672 Py_INCREF(python_pars[i]);
7675 result = function->m_c_code(tstate, function, python_pars);
7677 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 9);
7680 Py_LeaveRecursiveCall();
7682 CHECK_OBJECT_X(result);
7686#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
7687 }
else if (PyCFunction_CheckExact(called)) {
7688#if PYTHON_VERSION >= 0x380
7689#ifdef _NUITKA_FULL_COMPAT
7690 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7695 int flags = PyCFunction_GET_FLAGS(called);
7699 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7702 result = func(called, args, 9, NULL);
7704 CHECK_OBJECT_X(result);
7706 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7707 PyObject *self = PyCFunction_GET_SELF(called);
7709 if (flags & METH_KEYWORDS) {
7710 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
7712 result = (*method)(self, pos_args);
7716#ifdef _NUITKA_FULL_COMPAT
7717 Py_LeaveRecursiveCall();
7719 CHECK_OBJECT_X(result);
7721 return Nuitka_CheckFunctionResult(tstate, called, result);
7724 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
7726 if (unlikely(flags & METH_NOARGS)) {
7727 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (9 given)",
7728 ((PyCFunctionObject *)called)->m_ml->ml_name);
7730 }
else if (unlikely(flags & METH_O)) {
7731 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (9 given)",
7732 ((PyCFunctionObject *)called)->m_ml->ml_name);
7734 }
else if (flags & METH_VARARGS) {
7737#ifdef _NUITKA_FULL_COMPAT
7738 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7742 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7743 PyObject *self = PyCFunction_GET_SELF(called);
7747#if PYTHON_VERSION < 0x360
7748 if (flags & METH_KEYWORDS) {
7749 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7751 result = (*method)(self, pos_args);
7755 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
7756 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7757 }
else if (flags == METH_FASTCALL) {
7758#if PYTHON_VERSION < 0x370
7759 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 9, NULL);
7761 result = (*(_PyCFunctionFast)method)(self, &pos_args, 9);
7764 result = (*method)(self, pos_args);
7768#ifdef _NUITKA_FULL_COMPAT
7769 Py_LeaveRecursiveCall();
7772 CHECK_OBJECT_X(result);
7774 return Nuitka_CheckFunctionResult(tstate, called, result);
7778#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
7779 }
else if (PyFunction_Check(called)) {
7780#if PYTHON_VERSION < 0x3b0
7781 PyObject *result = callPythonFunction(called, args, 9);
7783 PyObject *result = _PyFunction_Vectorcall(called, args, 9, NULL);
7785 CHECK_OBJECT_X(result);
7789#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
7790 }
else if (PyType_Check(called)) {
7791 PyTypeObject *type = Py_TYPE(called);
7793 if (type->tp_call == PyType_Type.tp_call) {
7794 PyTypeObject *called_type = (PyTypeObject *)(called);
7796 if (unlikely(called_type->tp_new == NULL)) {
7797 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
7803 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
7804 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
7805 formatCannotInstantiateAbstractClass(tstate, called_type);
7809 obj = called_type->tp_alloc(called_type, 0);
7812 obj = called_type->tp_new(called_type, pos_args, NULL);
7815 if (likely(obj != NULL)) {
7816 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
7821 type = Py_TYPE(obj);
7823 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
7824 if (type->tp_init == default_tp_init_wrapper) {
7826 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
7829 assert(init_method != NULL);
7831 bool is_compiled_function =
false;
7832 bool init_method_needs_release =
false;
7834 if (likely(init_method != NULL)) {
7835 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
7837 if (func == Nuitka_Function_Type.tp_descr_get) {
7838 is_compiled_function =
true;
7839 }
else if (func != NULL) {
7840 init_method = func(init_method, obj, (PyObject *)(type));
7841 init_method_needs_release =
true;
7845 if (unlikely(init_method == NULL)) {
7846 if (!HAS_ERROR_OCCURRED(tstate)) {
7847 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
7848 const_str_plain___init__);
7855 if (is_compiled_function) {
7856 result = Nuitka_CallMethodFunctionPosArgs(
7859 result = CALL_FUNCTION_WITH_POS_ARGS9(tstate, init_method, pos_args);
7860 if (init_method_needs_release) {
7861 Py_DECREF(init_method);
7865 if (unlikely(result == NULL)) {
7872 if (unlikely(result != Py_None)) {
7875 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7880 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
7888 CHECK_OBJECT_X(obj);
7893#if PYTHON_VERSION < 0x300
7894 }
else if (PyClass_Check(called)) {
7895 PyObject *obj = PyInstance_NewRaw(called, NULL);
7897 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
7899 if (unlikely(init_method == NULL)) {
7900 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
7907 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
7911 bool is_compiled_function =
false;
7913 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
7915 if (descr_get == NULL) {
7916 Py_INCREF(init_method);
7917 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
7918 is_compiled_function =
true;
7919 }
else if (descr_get != NULL) {
7920 PyObject *descr_method = descr_get(init_method, obj, called);
7922 if (unlikely(descr_method == NULL)) {
7926 init_method = descr_method;
7930 if (is_compiled_function) {
7931 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
7934 result = CALL_FUNCTION_WITH_POS_ARGS9(tstate, init_method, pos_args);
7935 Py_DECREF(init_method);
7937 if (unlikely(result == NULL)) {
7943 if (unlikely(result != Py_None)) {
7944 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
7948 CHECK_OBJECT_X(obj);
7952#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
7953 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
7954 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7956 if (likely(func != NULL)) {
7957 PyObject *result = func(called, args, 9, NULL);
7959 CHECK_OBJECT_X(result);
7961 return Nuitka_CheckFunctionResult(tstate, called, result);
7968 PRINT_STRING(
"FALLBACK");
7973 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
7975 CHECK_OBJECT_X(result);
7979PyObject *CALL_FUNCTION_WITH_ARGS10(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
7980 CHECK_OBJECT(called);
7981 CHECK_OBJECTS(args, 10);
7983 if (Nuitka_Function_Check(called)) {
7984 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
7991 if (function->m_args_simple && 10 == function->m_args_positional_count) {
7992 for (Py_ssize_t i = 0; i < 10; i++) {
7995 result = function->m_c_code(tstate, function, (PyObject **)args);
7996 }
else if (function->m_args_simple && 10 + function->m_defaults_given == function->m_args_positional_count) {
7997 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7999 memcpy(python_pars, args, 10 *
sizeof(PyObject *));
8000 memcpy(python_pars + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8001 function->m_defaults_given *
sizeof(PyObject *));
8003 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
8004 Py_INCREF(python_pars[i]);
8007 result = function->m_c_code(tstate, function, python_pars);
8009 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 10);
8012 Py_LeaveRecursiveCall();
8014 CHECK_OBJECT_X(result);
8017 }
else if (Nuitka_Method_Check(called)) {
8020 if (method->m_object == NULL) {
8021 PyObject *self = args[0];
8023 int res = PyObject_IsInstance(self, method->m_class);
8025 if (unlikely(res < 0)) {
8027 }
else if (unlikely(res == 0)) {
8028 PyErr_Format(PyExc_TypeError,
8029 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
8030 "instance instead)",
8031 GET_CALLABLE_NAME((PyObject *)method->m_function),
8032 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
8033 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
8038 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 10);
8040 CHECK_OBJECT_X(result);
8044 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8052 if (function->m_args_simple && 10 + 1 == function->m_args_positional_count) {
8053 PyObject *python_pars[10 + 1];
8055 python_pars[0] = method->m_object;
8056 Py_INCREF(method->m_object);
8058 for (Py_ssize_t i = 0; i < 10; i++) {
8059 python_pars[i + 1] = args[i];
8062 result = function->m_c_code(tstate, function, python_pars);
8063 }
else if (function->m_args_simple &&
8064 10 + 1 + function->m_defaults_given == function->m_args_positional_count) {
8065 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8067 python_pars[0] = method->m_object;
8068 Py_INCREF(method->m_object);
8070 memcpy(python_pars + 1, args, 10 *
sizeof(PyObject *));
8071 memcpy(python_pars + 1 + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8072 function->m_defaults_given *
sizeof(PyObject *));
8074 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
8075 Py_INCREF(python_pars[i]);
8078 result = function->m_c_code(tstate, function, python_pars);
8080 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 10);
8083 Py_LeaveRecursiveCall();
8085 CHECK_OBJECT_X(result);
8089#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
8090 }
else if (PyCFunction_CheckExact(called)) {
8091#if PYTHON_VERSION >= 0x380
8092#ifdef _NUITKA_FULL_COMPAT
8093 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8098 int flags = PyCFunction_GET_FLAGS(called);
8102 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8105 result = func(called, args, 10, NULL);
8107 CHECK_OBJECT_X(result);
8109 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8110 PyObject *self = PyCFunction_GET_SELF(called);
8112 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8114 if (flags & METH_KEYWORDS) {
8115 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
8117 result = (*method)(self, pos_args);
8120 Py_DECREF(pos_args);
8123#ifdef _NUITKA_FULL_COMPAT
8124 Py_LeaveRecursiveCall();
8126 CHECK_OBJECT_X(result);
8128 return Nuitka_CheckFunctionResult(tstate, called, result);
8131 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
8133 if (unlikely(flags & METH_NOARGS)) {
8134 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (10 given)",
8135 ((PyCFunctionObject *)called)->m_ml->ml_name);
8137 }
else if (unlikely(flags & METH_O)) {
8138 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (10 given)",
8139 ((PyCFunctionObject *)called)->m_ml->ml_name);
8141 }
else if (flags & METH_VARARGS) {
8144#ifdef _NUITKA_FULL_COMPAT
8145 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8149 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8150 PyObject *self = PyCFunction_GET_SELF(called);
8154#if PYTHON_VERSION < 0x360
8155 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8156 if (flags & METH_KEYWORDS) {
8157 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8159 result = (*method)(self, pos_args);
8162 Py_DECREF(pos_args);
8164 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
8165 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8166 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8167 Py_DECREF(pos_args);
8168 }
else if (flags == METH_FASTCALL) {
8169#if PYTHON_VERSION < 0x370
8170 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 10, NULL);
8172 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8173 result = (*(_PyCFunctionFast)method)(self, &pos_args, 10);
8174 Py_DECREF(pos_args);
8177 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8178 result = (*method)(self, pos_args);
8179 Py_DECREF(pos_args);
8183#ifdef _NUITKA_FULL_COMPAT
8184 Py_LeaveRecursiveCall();
8187 CHECK_OBJECT_X(result);
8189 return Nuitka_CheckFunctionResult(tstate, called, result);
8193#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
8194 }
else if (PyFunction_Check(called)) {
8195#if PYTHON_VERSION < 0x3b0
8196 PyObject *result = callPythonFunction(called, args, 10);
8198 PyObject *result = _PyFunction_Vectorcall(called, args, 10, NULL);
8200 CHECK_OBJECT_X(result);
8204#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
8205 }
else if (PyType_Check(called)) {
8206 PyTypeObject *type = Py_TYPE(called);
8208 if (type->tp_call == PyType_Type.tp_call) {
8209 PyTypeObject *called_type = (PyTypeObject *)(called);
8211 if (unlikely(called_type->tp_new == NULL)) {
8212 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
8216 PyObject *pos_args = NULL;
8219 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
8220 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
8221 formatCannotInstantiateAbstractClass(tstate, called_type);
8225 obj = called_type->tp_alloc(called_type, 0);
8228 pos_args = MAKE_TUPLE(tstate, args, 10);
8229 obj = called_type->tp_new(called_type, pos_args, NULL);
8232 if (likely(obj != NULL)) {
8233 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
8234 Py_DECREF(pos_args);
8239 type = Py_TYPE(obj);
8241 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
8242 if (type->tp_init == default_tp_init_wrapper) {
8243 Py_XDECREF(pos_args);
8246 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
8249 assert(init_method != NULL);
8251 bool is_compiled_function =
false;
8252 bool init_method_needs_release =
false;
8254 if (likely(init_method != NULL)) {
8255 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
8257 if (func == Nuitka_Function_Type.tp_descr_get) {
8258 is_compiled_function =
true;
8259 }
else if (func != NULL) {
8260 init_method = func(init_method, obj, (PyObject *)(type));
8261 init_method_needs_release =
true;
8265 if (unlikely(init_method == NULL)) {
8266 if (!HAS_ERROR_OCCURRED(tstate)) {
8267 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
8268 const_str_plain___init__);
8275 if (is_compiled_function) {
8276 result = Nuitka_CallMethodFunctionPosArgs(
8279 result = CALL_FUNCTION_WITH_ARGS10(tstate, init_method, args);
8280 if (init_method_needs_release) {
8281 Py_DECREF(init_method);
8285 if (unlikely(result == NULL)) {
8292 if (unlikely(result != Py_None)) {
8295 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
8299 if (pos_args == NULL) {
8300 pos_args = MAKE_TUPLE(tstate, args, 10);
8303 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
8305 Py_XDECREF(pos_args);
8312 Py_XDECREF(pos_args);
8314 CHECK_OBJECT_X(obj);
8319#if PYTHON_VERSION < 0x300
8320 }
else if (PyClass_Check(called)) {
8321 PyObject *obj = PyInstance_NewRaw(called, NULL);
8323 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
8325 if (unlikely(init_method == NULL)) {
8326 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
8333 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
8337 bool is_compiled_function =
false;
8339 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
8341 if (descr_get == NULL) {
8342 Py_INCREF(init_method);
8343 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
8344 is_compiled_function =
true;
8345 }
else if (descr_get != NULL) {
8346 PyObject *descr_method = descr_get(init_method, obj, called);
8348 if (unlikely(descr_method == NULL)) {
8352 init_method = descr_method;
8356 if (is_compiled_function) {
8357 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
8360 result = CALL_FUNCTION_WITH_ARGS10(tstate, init_method, args);
8361 Py_DECREF(init_method);
8363 if (unlikely(result == NULL)) {
8369 if (unlikely(result != Py_None)) {
8370 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
8374 CHECK_OBJECT_X(obj);
8378#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8379 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8380 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8382 if (likely(func != NULL)) {
8383 PyObject *result = func(called, args, 10, NULL);
8385 CHECK_OBJECT_X(result);
8387 return Nuitka_CheckFunctionResult(tstate, called, result);
8394 PRINT_STRING(
"FALLBACK");
8399 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8401 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
8403 Py_DECREF(pos_args);
8405 CHECK_OBJECT_X(result);
8409PyObject *CALL_FUNCTION_WITH_POS_ARGS10(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
8410 assert(PyTuple_CheckExact(pos_args));
8411 assert(PyTuple_GET_SIZE(pos_args) == 10);
8412 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
8413 CHECK_OBJECT(called);
8414 CHECK_OBJECTS(args, 10);
8416 if (Nuitka_Function_Check(called)) {
8417 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8424 if (function->m_args_simple && 10 == function->m_args_positional_count) {
8425 for (Py_ssize_t i = 0; i < 10; i++) {
8428 result = function->m_c_code(tstate, function, (PyObject **)args);
8429 }
else if (function->m_args_simple && 10 + function->m_defaults_given == function->m_args_positional_count) {
8430 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8432 memcpy(python_pars, args, 10 *
sizeof(PyObject *));
8433 memcpy(python_pars + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8434 function->m_defaults_given *
sizeof(PyObject *));
8436 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
8437 Py_INCREF(python_pars[i]);
8440 result = function->m_c_code(tstate, function, python_pars);
8442 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 10);
8445 Py_LeaveRecursiveCall();
8447 CHECK_OBJECT_X(result);
8450 }
else if (Nuitka_Method_Check(called)) {
8453 if (method->m_object == NULL) {
8454 PyObject *self = args[0];
8456 int res = PyObject_IsInstance(self, method->m_class);
8458 if (unlikely(res < 0)) {
8460 }
else if (unlikely(res == 0)) {
8461 PyErr_Format(PyExc_TypeError,
8462 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
8463 "instance instead)",
8464 GET_CALLABLE_NAME((PyObject *)method->m_function),
8465 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
8466 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
8471 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 10);
8473 CHECK_OBJECT_X(result);
8477 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8485 if (function->m_args_simple && 10 + 1 == function->m_args_positional_count) {
8486 PyObject *python_pars[10 + 1];
8488 python_pars[0] = method->m_object;
8489 Py_INCREF(method->m_object);
8491 for (Py_ssize_t i = 0; i < 10; i++) {
8492 python_pars[i + 1] = args[i];
8495 result = function->m_c_code(tstate, function, python_pars);
8496 }
else if (function->m_args_simple &&
8497 10 + 1 + function->m_defaults_given == function->m_args_positional_count) {
8498 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8500 python_pars[0] = method->m_object;
8501 Py_INCREF(method->m_object);
8503 memcpy(python_pars + 1, args, 10 *
sizeof(PyObject *));
8504 memcpy(python_pars + 1 + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8505 function->m_defaults_given *
sizeof(PyObject *));
8507 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
8508 Py_INCREF(python_pars[i]);
8511 result = function->m_c_code(tstate, function, python_pars);
8513 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 10);
8516 Py_LeaveRecursiveCall();
8518 CHECK_OBJECT_X(result);
8522#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
8523 }
else if (PyCFunction_CheckExact(called)) {
8524#if PYTHON_VERSION >= 0x380
8525#ifdef _NUITKA_FULL_COMPAT
8526 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8531 int flags = PyCFunction_GET_FLAGS(called);
8535 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8538 result = func(called, args, 10, NULL);
8540 CHECK_OBJECT_X(result);
8542 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8543 PyObject *self = PyCFunction_GET_SELF(called);
8545 if (flags & METH_KEYWORDS) {
8546 result = (*(PyCFunctionWithKeywords)(
void (*)(void))method)(self, pos_args, NULL);
8548 result = (*method)(self, pos_args);
8552#ifdef _NUITKA_FULL_COMPAT
8553 Py_LeaveRecursiveCall();
8555 CHECK_OBJECT_X(result);
8557 return Nuitka_CheckFunctionResult(tstate, called, result);
8560 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
8562 if (unlikely(flags & METH_NOARGS)) {
8563 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes no arguments (10 given)",
8564 ((PyCFunctionObject *)called)->m_ml->ml_name);
8566 }
else if (unlikely(flags & METH_O)) {
8567 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (10 given)",
8568 ((PyCFunctionObject *)called)->m_ml->ml_name);
8570 }
else if (flags & METH_VARARGS) {
8573#ifdef _NUITKA_FULL_COMPAT
8574 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8578 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8579 PyObject *self = PyCFunction_GET_SELF(called);
8583#if PYTHON_VERSION < 0x360
8584 if (flags & METH_KEYWORDS) {
8585 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8587 result = (*method)(self, pos_args);
8591 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
8592 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8593 }
else if (flags == METH_FASTCALL) {
8594#if PYTHON_VERSION < 0x370
8595 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 10, NULL);
8597 result = (*(_PyCFunctionFast)method)(self, &pos_args, 10);
8600 result = (*method)(self, pos_args);
8604#ifdef _NUITKA_FULL_COMPAT
8605 Py_LeaveRecursiveCall();
8608 CHECK_OBJECT_X(result);
8610 return Nuitka_CheckFunctionResult(tstate, called, result);
8614#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
8615 }
else if (PyFunction_Check(called)) {
8616#if PYTHON_VERSION < 0x3b0
8617 PyObject *result = callPythonFunction(called, args, 10);
8619 PyObject *result = _PyFunction_Vectorcall(called, args, 10, NULL);
8621 CHECK_OBJECT_X(result);
8625#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
8626 }
else if (PyType_Check(called)) {
8627 PyTypeObject *type = Py_TYPE(called);
8629 if (type->tp_call == PyType_Type.tp_call) {
8630 PyTypeObject *called_type = (PyTypeObject *)(called);
8632 if (unlikely(called_type->tp_new == NULL)) {
8633 PyErr_Format(PyExc_TypeError,
"cannot create '%s' instances", called_type->tp_name);
8639 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
8640 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
8641 formatCannotInstantiateAbstractClass(tstate, called_type);
8645 obj = called_type->tp_alloc(called_type, 0);
8648 obj = called_type->tp_new(called_type, pos_args, NULL);
8651 if (likely(obj != NULL)) {
8652 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
8657 type = Py_TYPE(obj);
8659 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
8660 if (type->tp_init == default_tp_init_wrapper) {
8662 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
8665 assert(init_method != NULL);
8667 bool is_compiled_function =
false;
8668 bool init_method_needs_release =
false;
8670 if (likely(init_method != NULL)) {
8671 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
8673 if (func == Nuitka_Function_Type.tp_descr_get) {
8674 is_compiled_function =
true;
8675 }
else if (func != NULL) {
8676 init_method = func(init_method, obj, (PyObject *)(type));
8677 init_method_needs_release =
true;
8681 if (unlikely(init_method == NULL)) {
8682 if (!HAS_ERROR_OCCURRED(tstate)) {
8683 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
8684 const_str_plain___init__);
8691 if (is_compiled_function) {
8692 result = Nuitka_CallMethodFunctionPosArgs(
8695 result = CALL_FUNCTION_WITH_POS_ARGS10(tstate, init_method, pos_args);
8696 if (init_method_needs_release) {
8697 Py_DECREF(init_method);
8701 if (unlikely(result == NULL)) {
8708 if (unlikely(result != Py_None)) {
8711 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
8716 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
8724 CHECK_OBJECT_X(obj);
8729#if PYTHON_VERSION < 0x300
8730 }
else if (PyClass_Check(called)) {
8731 PyObject *obj = PyInstance_NewRaw(called, NULL);
8733 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
8735 if (unlikely(init_method == NULL)) {
8736 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
8743 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError,
"this constructor takes no arguments");
8747 bool is_compiled_function =
false;
8749 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
8751 if (descr_get == NULL) {
8752 Py_INCREF(init_method);
8753 }
else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
8754 is_compiled_function =
true;
8755 }
else if (descr_get != NULL) {
8756 PyObject *descr_method = descr_get(init_method, obj, called);
8758 if (unlikely(descr_method == NULL)) {
8762 init_method = descr_method;
8766 if (is_compiled_function) {
8767 result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)init_method, obj,
8770 result = CALL_FUNCTION_WITH_POS_ARGS10(tstate, init_method, pos_args);
8771 Py_DECREF(init_method);
8773 if (unlikely(result == NULL)) {
8779 if (unlikely(result != Py_None)) {
8780 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"__init__() should return None, not '%s'", result);
8784 CHECK_OBJECT_X(obj);
8788#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8789 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8790 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8792 if (likely(func != NULL)) {
8793 PyObject *result = func(called, args, 10, NULL);
8795 CHECK_OBJECT_X(result);
8797 return Nuitka_CheckFunctionResult(tstate, called, result);
8804 PRINT_STRING(
"FALLBACK");
8809 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
8811 CHECK_OBJECT_X(result);
8815PyObject *CALL_FUNCTION_WITH_NO_ARGS_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *kw_values,
8816 PyObject *kw_names) {
8818 CHECK_OBJECT(kw_names);
8819 assert(PyTuple_CheckExact(kw_names));
8820 CHECK_OBJECT(called);
8822 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
8824 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
8826 if (Nuitka_Function_Check(called)) {
8827 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8833 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, NULL, 0, kw_values, kw_names);
8835 Py_LeaveRecursiveCall();
8837 CHECK_OBJECT_X(result);
8840#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8841 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8842 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8844 if (likely(func != NULL)) {
8845 PyObject *result = func(called, kw_values, 0, kw_names);
8847 CHECK_OBJECT_X(result);
8849 return Nuitka_CheckFunctionResult(tstate, called, result);
8855 PRINT_STRING(
"FALLBACK");
8860 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
8862 if (unlikely(call_slot == NULL)) {
8863 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
8868 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8872 PyObject *pos_args = const_tuple_empty;
8874 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
8876 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
8877 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
8879 PyObject *value = kw_values[i];
8882 CHECK_OBJECT(value);
8884 DICT_SET_ITEM(named_args, key, value);
8887 PyObject *result = (*call_slot)(called, pos_args, named_args);
8889 Py_DECREF(named_args);
8891 Py_LeaveRecursiveCall();
8893 CHECK_OBJECT_X(result);
8895 return Nuitka_CheckFunctionResult(tstate, called, result);
8897PyObject *CALL_FUNCTION_WITH_ARGS1_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
8898 PyObject *kw_names) {
8899 CHECK_OBJECTS(args, 1);
8900 CHECK_OBJECT(kw_names);
8901 assert(PyTuple_CheckExact(kw_names));
8902 CHECK_OBJECT(called);
8904 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
8906 CHECK_OBJECTS(&args[1], kwargs_count);
8908 if (Nuitka_Function_Check(called)) {
8909 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8916 Nuitka_CallFunctionVectorcall(tstate, function, args, 1, &PyTuple_GET_ITEM(kw_names, 0), kwargs_count);
8918 Py_LeaveRecursiveCall();
8920 CHECK_OBJECT_X(result);
8923#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8924 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8925 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8927 if (likely(func != NULL)) {
8928 PyObject *result = func(called, args, 1, kw_names);
8930 CHECK_OBJECT_X(result);
8932 return Nuitka_CheckFunctionResult(tstate, called, result);
8938 PRINT_STRING(
"FALLBACK");
8943 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
8945 if (unlikely(call_slot == NULL)) {
8946 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
8951 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8955 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
8957 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
8959 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
8960 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
8962 PyObject *value = args[1 + i];
8965 CHECK_OBJECT(value);
8967 DICT_SET_ITEM(named_args, key, value);
8970 PyObject *result = (*call_slot)(called, pos_args, named_args);
8972 Py_DECREF(pos_args);
8973 Py_DECREF(named_args);
8975 Py_LeaveRecursiveCall();
8977 CHECK_OBJECT_X(result);
8979 return Nuitka_CheckFunctionResult(tstate, called, result);
8981PyObject *CALL_FUNCTION_WITH_ARGS1_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
8982 PyObject *
const *kw_values, PyObject *kw_names) {
8983 CHECK_OBJECTS(args, 1);
8984 CHECK_OBJECT(kw_names);
8985 assert(PyTuple_CheckExact(kw_names));
8986 CHECK_OBJECT(called);
8988 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
8990 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
8992 if (Nuitka_Function_Check(called)) {
8993 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
8999 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 1, kw_values, kw_names);
9001 Py_LeaveRecursiveCall();
9003 CHECK_OBJECT_X(result);
9006#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9007 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9008 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9010 if (likely(func != NULL)) {
9011 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 1 + kwargs_count);
9013 memcpy(vectorcall_args, args, 1 *
sizeof(PyObject *));
9014 memcpy(&vectorcall_args[1], kw_values, kwargs_count *
sizeof(PyObject *));
9016 PyObject *result = func(called, vectorcall_args, 1, kw_names);
9018 CHECK_OBJECT_X(result);
9020 return Nuitka_CheckFunctionResult(tstate, called, result);
9026 PRINT_STRING(
"FALLBACK");
9031 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9033 if (unlikely(call_slot == NULL)) {
9034 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9039 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9043 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
9045 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
9047 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
9048 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9050 PyObject *value = kw_values[i];
9053 CHECK_OBJECT(value);
9055 DICT_SET_ITEM(named_args, key, value);
9058 PyObject *result = (*call_slot)(called, pos_args, named_args);
9060 Py_DECREF(pos_args);
9061 Py_DECREF(named_args);
9063 Py_LeaveRecursiveCall();
9065 CHECK_OBJECT_X(result);
9067 return Nuitka_CheckFunctionResult(tstate, called, result);
9069PyObject *CALL_FUNCTION_WITH_POS_ARGS1_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9070 PyObject *
const *kw_values, PyObject *kw_names) {
9071 assert(PyTuple_CheckExact(pos_args));
9072 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
9073 CHECK_OBJECTS(args, 1);
9074 CHECK_OBJECT(kw_names);
9075 assert(PyTuple_CheckExact(kw_names));
9076 CHECK_OBJECT(called);
9078 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
9080 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9082 if (Nuitka_Function_Check(called)) {
9083 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9089 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 1, kw_values, kw_names);
9091 Py_LeaveRecursiveCall();
9093 CHECK_OBJECT_X(result);
9096#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9097 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9098 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9100 if (likely(func != NULL)) {
9101 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 1 + kwargs_count);
9103 memcpy(vectorcall_args, args, 1 *
sizeof(PyObject *));
9104 memcpy(&vectorcall_args[1], kw_values, kwargs_count *
sizeof(PyObject *));
9106 PyObject *result = func(called, vectorcall_args, 1, kw_names);
9108 CHECK_OBJECT_X(result);
9110 return Nuitka_CheckFunctionResult(tstate, called, result);
9116 PRINT_STRING(
"FALLBACK");
9121 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9123 if (unlikely(call_slot == NULL)) {
9124 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9129 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9133 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
9135 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
9136 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9138 PyObject *value = kw_values[i];
9141 CHECK_OBJECT(value);
9143 DICT_SET_ITEM(named_args, key, value);
9146 PyObject *result = (*call_slot)(called, pos_args, named_args);
9148 Py_DECREF(named_args);
9150 Py_LeaveRecursiveCall();
9152 CHECK_OBJECT_X(result);
9154 return Nuitka_CheckFunctionResult(tstate, called, result);
9156PyObject *CALL_FUNCTION_WITH_ARGS2_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9157 PyObject *kw_names) {
9158 CHECK_OBJECTS(args, 2);
9159 CHECK_OBJECT(kw_names);
9160 assert(PyTuple_CheckExact(kw_names));
9161 CHECK_OBJECT(called);
9163 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
9165 CHECK_OBJECTS(&args[2], kwargs_count);
9167 if (Nuitka_Function_Check(called)) {
9168 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9175 Nuitka_CallFunctionVectorcall(tstate, function, args, 2, &PyTuple_GET_ITEM(kw_names, 0), kwargs_count);
9177 Py_LeaveRecursiveCall();
9179 CHECK_OBJECT_X(result);
9182#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9183 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9184 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9186 if (likely(func != NULL)) {
9187 PyObject *result = func(called, args, 2, kw_names);
9189 CHECK_OBJECT_X(result);
9191 return Nuitka_CheckFunctionResult(tstate, called, result);
9197 PRINT_STRING(
"FALLBACK");
9202 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9204 if (unlikely(call_slot == NULL)) {
9205 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9210 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9214 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
9216 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
9218 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
9219 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9221 PyObject *value = args[2 + i];
9224 CHECK_OBJECT(value);
9226 DICT_SET_ITEM(named_args, key, value);
9229 PyObject *result = (*call_slot)(called, pos_args, named_args);
9231 Py_DECREF(pos_args);
9232 Py_DECREF(named_args);
9234 Py_LeaveRecursiveCall();
9236 CHECK_OBJECT_X(result);
9238 return Nuitka_CheckFunctionResult(tstate, called, result);
9240PyObject *CALL_FUNCTION_WITH_ARGS2_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9241 PyObject *
const *kw_values, PyObject *kw_names) {
9242 CHECK_OBJECTS(args, 2);
9243 CHECK_OBJECT(kw_names);
9244 assert(PyTuple_CheckExact(kw_names));
9245 CHECK_OBJECT(called);
9247 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
9249 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9251 if (Nuitka_Function_Check(called)) {
9252 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9258 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 2, kw_values, kw_names);
9260 Py_LeaveRecursiveCall();
9262 CHECK_OBJECT_X(result);
9265#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9266 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9267 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9269 if (likely(func != NULL)) {
9270 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 2 + kwargs_count);
9272 memcpy(vectorcall_args, args, 2 *
sizeof(PyObject *));
9273 memcpy(&vectorcall_args[2], kw_values, kwargs_count *
sizeof(PyObject *));
9275 PyObject *result = func(called, vectorcall_args, 2, kw_names);
9277 CHECK_OBJECT_X(result);
9279 return Nuitka_CheckFunctionResult(tstate, called, result);
9285 PRINT_STRING(
"FALLBACK");
9290 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9292 if (unlikely(call_slot == NULL)) {
9293 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9298 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9302 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
9304 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
9306 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
9307 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9309 PyObject *value = kw_values[i];
9312 CHECK_OBJECT(value);
9314 DICT_SET_ITEM(named_args, key, value);
9317 PyObject *result = (*call_slot)(called, pos_args, named_args);
9319 Py_DECREF(pos_args);
9320 Py_DECREF(named_args);
9322 Py_LeaveRecursiveCall();
9324 CHECK_OBJECT_X(result);
9326 return Nuitka_CheckFunctionResult(tstate, called, result);
9328PyObject *CALL_FUNCTION_WITH_POS_ARGS2_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9329 PyObject *
const *kw_values, PyObject *kw_names) {
9330 assert(PyTuple_CheckExact(pos_args));
9331 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
9332 CHECK_OBJECTS(args, 2);
9333 CHECK_OBJECT(kw_names);
9334 assert(PyTuple_CheckExact(kw_names));
9335 CHECK_OBJECT(called);
9337 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
9339 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9341 if (Nuitka_Function_Check(called)) {
9342 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9348 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 2, kw_values, kw_names);
9350 Py_LeaveRecursiveCall();
9352 CHECK_OBJECT_X(result);
9355#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9356 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9357 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9359 if (likely(func != NULL)) {
9360 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 2 + kwargs_count);
9362 memcpy(vectorcall_args, args, 2 *
sizeof(PyObject *));
9363 memcpy(&vectorcall_args[2], kw_values, kwargs_count *
sizeof(PyObject *));
9365 PyObject *result = func(called, vectorcall_args, 2, kw_names);
9367 CHECK_OBJECT_X(result);
9369 return Nuitka_CheckFunctionResult(tstate, called, result);
9375 PRINT_STRING(
"FALLBACK");
9380 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9382 if (unlikely(call_slot == NULL)) {
9383 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9388 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9392 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
9394 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
9395 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9397 PyObject *value = kw_values[i];
9400 CHECK_OBJECT(value);
9402 DICT_SET_ITEM(named_args, key, value);
9405 PyObject *result = (*call_slot)(called, pos_args, named_args);
9407 Py_DECREF(named_args);
9409 Py_LeaveRecursiveCall();
9411 CHECK_OBJECT_X(result);
9413 return Nuitka_CheckFunctionResult(tstate, called, result);
9415PyObject *CALL_FUNCTION_WITH_ARGS3_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9416 PyObject *kw_names) {
9417 CHECK_OBJECTS(args, 3);
9418 CHECK_OBJECT(kw_names);
9419 assert(PyTuple_CheckExact(kw_names));
9420 CHECK_OBJECT(called);
9422 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
9424 CHECK_OBJECTS(&args[3], kwargs_count);
9426 if (Nuitka_Function_Check(called)) {
9427 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9434 Nuitka_CallFunctionVectorcall(tstate, function, args, 3, &PyTuple_GET_ITEM(kw_names, 0), kwargs_count);
9436 Py_LeaveRecursiveCall();
9438 CHECK_OBJECT_X(result);
9441#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9442 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9443 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9445 if (likely(func != NULL)) {
9446 PyObject *result = func(called, args, 3, kw_names);
9448 CHECK_OBJECT_X(result);
9450 return Nuitka_CheckFunctionResult(tstate, called, result);
9456 PRINT_STRING(
"FALLBACK");
9461 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9463 if (unlikely(call_slot == NULL)) {
9464 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9469 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9473 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
9475 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
9477 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
9478 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9480 PyObject *value = args[3 + i];
9483 CHECK_OBJECT(value);
9485 DICT_SET_ITEM(named_args, key, value);
9488 PyObject *result = (*call_slot)(called, pos_args, named_args);
9490 Py_DECREF(pos_args);
9491 Py_DECREF(named_args);
9493 Py_LeaveRecursiveCall();
9495 CHECK_OBJECT_X(result);
9497 return Nuitka_CheckFunctionResult(tstate, called, result);
9499PyObject *CALL_FUNCTION_WITH_ARGS3_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9500 PyObject *
const *kw_values, PyObject *kw_names) {
9501 CHECK_OBJECTS(args, 3);
9502 CHECK_OBJECT(kw_names);
9503 assert(PyTuple_CheckExact(kw_names));
9504 CHECK_OBJECT(called);
9506 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
9508 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9510 if (Nuitka_Function_Check(called)) {
9511 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9517 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 3, kw_values, kw_names);
9519 Py_LeaveRecursiveCall();
9521 CHECK_OBJECT_X(result);
9524#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9525 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9526 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9528 if (likely(func != NULL)) {
9529 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 3 + kwargs_count);
9531 memcpy(vectorcall_args, args, 3 *
sizeof(PyObject *));
9532 memcpy(&vectorcall_args[3], kw_values, kwargs_count *
sizeof(PyObject *));
9534 PyObject *result = func(called, vectorcall_args, 3, kw_names);
9536 CHECK_OBJECT_X(result);
9538 return Nuitka_CheckFunctionResult(tstate, called, result);
9544 PRINT_STRING(
"FALLBACK");
9549 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9551 if (unlikely(call_slot == NULL)) {
9552 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9557 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9561 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
9563 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
9565 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
9566 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9568 PyObject *value = kw_values[i];
9571 CHECK_OBJECT(value);
9573 DICT_SET_ITEM(named_args, key, value);
9576 PyObject *result = (*call_slot)(called, pos_args, named_args);
9578 Py_DECREF(pos_args);
9579 Py_DECREF(named_args);
9581 Py_LeaveRecursiveCall();
9583 CHECK_OBJECT_X(result);
9585 return Nuitka_CheckFunctionResult(tstate, called, result);
9587PyObject *CALL_FUNCTION_WITH_POS_ARGS3_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9588 PyObject *
const *kw_values, PyObject *kw_names) {
9589 assert(PyTuple_CheckExact(pos_args));
9590 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
9591 CHECK_OBJECTS(args, 3);
9592 CHECK_OBJECT(kw_names);
9593 assert(PyTuple_CheckExact(kw_names));
9594 CHECK_OBJECT(called);
9596 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
9598 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9600 if (Nuitka_Function_Check(called)) {
9601 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9607 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 3, kw_values, kw_names);
9609 Py_LeaveRecursiveCall();
9611 CHECK_OBJECT_X(result);
9614#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9615 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9616 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9618 if (likely(func != NULL)) {
9619 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 3 + kwargs_count);
9621 memcpy(vectorcall_args, args, 3 *
sizeof(PyObject *));
9622 memcpy(&vectorcall_args[3], kw_values, kwargs_count *
sizeof(PyObject *));
9624 PyObject *result = func(called, vectorcall_args, 3, kw_names);
9626 CHECK_OBJECT_X(result);
9628 return Nuitka_CheckFunctionResult(tstate, called, result);
9634 PRINT_STRING(
"FALLBACK");
9639 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9641 if (unlikely(call_slot == NULL)) {
9642 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9647 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9651 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
9653 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
9654 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9656 PyObject *value = kw_values[i];
9659 CHECK_OBJECT(value);
9661 DICT_SET_ITEM(named_args, key, value);
9664 PyObject *result = (*call_slot)(called, pos_args, named_args);
9666 Py_DECREF(named_args);
9668 Py_LeaveRecursiveCall();
9670 CHECK_OBJECT_X(result);
9672 return Nuitka_CheckFunctionResult(tstate, called, result);
9674PyObject *CALL_FUNCTION_WITH_ARGS4_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9675 PyObject *kw_names) {
9676 CHECK_OBJECTS(args, 4);
9677 CHECK_OBJECT(kw_names);
9678 assert(PyTuple_CheckExact(kw_names));
9679 CHECK_OBJECT(called);
9681 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
9683 CHECK_OBJECTS(&args[4], kwargs_count);
9685 if (Nuitka_Function_Check(called)) {
9686 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9693 Nuitka_CallFunctionVectorcall(tstate, function, args, 4, &PyTuple_GET_ITEM(kw_names, 0), kwargs_count);
9695 Py_LeaveRecursiveCall();
9697 CHECK_OBJECT_X(result);
9700#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9701 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9702 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9704 if (likely(func != NULL)) {
9705 PyObject *result = func(called, args, 4, kw_names);
9707 CHECK_OBJECT_X(result);
9709 return Nuitka_CheckFunctionResult(tstate, called, result);
9715 PRINT_STRING(
"FALLBACK");
9720 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9722 if (unlikely(call_slot == NULL)) {
9723 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9728 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9732 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
9734 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
9736 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
9737 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9739 PyObject *value = args[4 + i];
9742 CHECK_OBJECT(value);
9744 DICT_SET_ITEM(named_args, key, value);
9747 PyObject *result = (*call_slot)(called, pos_args, named_args);
9749 Py_DECREF(pos_args);
9750 Py_DECREF(named_args);
9752 Py_LeaveRecursiveCall();
9754 CHECK_OBJECT_X(result);
9756 return Nuitka_CheckFunctionResult(tstate, called, result);
9758PyObject *CALL_FUNCTION_WITH_ARGS4_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9759 PyObject *
const *kw_values, PyObject *kw_names) {
9760 CHECK_OBJECTS(args, 4);
9761 CHECK_OBJECT(kw_names);
9762 assert(PyTuple_CheckExact(kw_names));
9763 CHECK_OBJECT(called);
9765 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
9767 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9769 if (Nuitka_Function_Check(called)) {
9770 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9776 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 4, kw_values, kw_names);
9778 Py_LeaveRecursiveCall();
9780 CHECK_OBJECT_X(result);
9783#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9784 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9785 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9787 if (likely(func != NULL)) {
9788 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 4 + kwargs_count);
9790 memcpy(vectorcall_args, args, 4 *
sizeof(PyObject *));
9791 memcpy(&vectorcall_args[4], kw_values, kwargs_count *
sizeof(PyObject *));
9793 PyObject *result = func(called, vectorcall_args, 4, kw_names);
9795 CHECK_OBJECT_X(result);
9797 return Nuitka_CheckFunctionResult(tstate, called, result);
9803 PRINT_STRING(
"FALLBACK");
9808 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9810 if (unlikely(call_slot == NULL)) {
9811 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9816 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9820 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
9822 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
9824 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
9825 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9827 PyObject *value = kw_values[i];
9830 CHECK_OBJECT(value);
9832 DICT_SET_ITEM(named_args, key, value);
9835 PyObject *result = (*call_slot)(called, pos_args, named_args);
9837 Py_DECREF(pos_args);
9838 Py_DECREF(named_args);
9840 Py_LeaveRecursiveCall();
9842 CHECK_OBJECT_X(result);
9844 return Nuitka_CheckFunctionResult(tstate, called, result);
9846PyObject *CALL_FUNCTION_WITH_POS_ARGS4_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9847 PyObject *
const *kw_values, PyObject *kw_names) {
9848 assert(PyTuple_CheckExact(pos_args));
9849 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
9850 CHECK_OBJECTS(args, 4);
9851 CHECK_OBJECT(kw_names);
9852 assert(PyTuple_CheckExact(kw_names));
9853 CHECK_OBJECT(called);
9855 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
9857 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9859 if (Nuitka_Function_Check(called)) {
9860 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9866 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 4, kw_values, kw_names);
9868 Py_LeaveRecursiveCall();
9870 CHECK_OBJECT_X(result);
9873#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9874 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9875 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9877 if (likely(func != NULL)) {
9878 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 4 + kwargs_count);
9880 memcpy(vectorcall_args, args, 4 *
sizeof(PyObject *));
9881 memcpy(&vectorcall_args[4], kw_values, kwargs_count *
sizeof(PyObject *));
9883 PyObject *result = func(called, vectorcall_args, 4, kw_names);
9885 CHECK_OBJECT_X(result);
9887 return Nuitka_CheckFunctionResult(tstate, called, result);
9893 PRINT_STRING(
"FALLBACK");
9898 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9900 if (unlikely(call_slot == NULL)) {
9901 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9906 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9910 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
9912 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
9913 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9915 PyObject *value = kw_values[i];
9918 CHECK_OBJECT(value);
9920 DICT_SET_ITEM(named_args, key, value);
9923 PyObject *result = (*call_slot)(called, pos_args, named_args);
9925 Py_DECREF(named_args);
9927 Py_LeaveRecursiveCall();
9929 CHECK_OBJECT_X(result);
9931 return Nuitka_CheckFunctionResult(tstate, called, result);
9933PyObject *CALL_FUNCTION_WITH_ARGS5_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
9934 PyObject *kw_names) {
9935 CHECK_OBJECTS(args, 5);
9936 CHECK_OBJECT(kw_names);
9937 assert(PyTuple_CheckExact(kw_names));
9938 CHECK_OBJECT(called);
9940 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
9942 CHECK_OBJECTS(&args[5], kwargs_count);
9944 if (Nuitka_Function_Check(called)) {
9945 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9952 Nuitka_CallFunctionVectorcall(tstate, function, args, 5, &PyTuple_GET_ITEM(kw_names, 0), kwargs_count);
9954 Py_LeaveRecursiveCall();
9956 CHECK_OBJECT_X(result);
9959#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9960 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9961 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9963 if (likely(func != NULL)) {
9964 PyObject *result = func(called, args, 5, kw_names);
9966 CHECK_OBJECT_X(result);
9968 return Nuitka_CheckFunctionResult(tstate, called, result);
9974 PRINT_STRING(
"FALLBACK");
9979 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9981 if (unlikely(call_slot == NULL)) {
9982 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
9987 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
9991 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
9993 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
9995 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
9996 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9998 PyObject *value = args[5 + i];
10001 CHECK_OBJECT(value);
10003 DICT_SET_ITEM(named_args, key, value);
10006 PyObject *result = (*call_slot)(called, pos_args, named_args);
10008 Py_DECREF(pos_args);
10009 Py_DECREF(named_args);
10011 Py_LeaveRecursiveCall();
10013 CHECK_OBJECT_X(result);
10015 return Nuitka_CheckFunctionResult(tstate, called, result);
10017PyObject *CALL_FUNCTION_WITH_ARGS5_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10018 PyObject *
const *kw_values, PyObject *kw_names) {
10019 CHECK_OBJECTS(args, 5);
10020 CHECK_OBJECT(kw_names);
10021 assert(PyTuple_CheckExact(kw_names));
10022 CHECK_OBJECT(called);
10024 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
10026 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10028 if (Nuitka_Function_Check(called)) {
10029 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10035 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 5, kw_values, kw_names);
10037 Py_LeaveRecursiveCall();
10039 CHECK_OBJECT_X(result);
10042#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10043 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10044 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10046 if (likely(func != NULL)) {
10047 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 5 + kwargs_count);
10049 memcpy(vectorcall_args, args, 5 *
sizeof(PyObject *));
10050 memcpy(&vectorcall_args[5], kw_values, kwargs_count *
sizeof(PyObject *));
10052 PyObject *result = func(called, vectorcall_args, 5, kw_names);
10054 CHECK_OBJECT_X(result);
10056 return Nuitka_CheckFunctionResult(tstate, called, result);
10062 PRINT_STRING(
"FALLBACK");
10063 PRINT_ITEM(called);
10067 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10069 if (unlikely(call_slot == NULL)) {
10070 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10075 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10079 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
10081 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
10083 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
10084 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10086 PyObject *value = kw_values[i];
10089 CHECK_OBJECT(value);
10091 DICT_SET_ITEM(named_args, key, value);
10094 PyObject *result = (*call_slot)(called, pos_args, named_args);
10096 Py_DECREF(pos_args);
10097 Py_DECREF(named_args);
10099 Py_LeaveRecursiveCall();
10101 CHECK_OBJECT_X(result);
10103 return Nuitka_CheckFunctionResult(tstate, called, result);
10105PyObject *CALL_FUNCTION_WITH_POS_ARGS5_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10106 PyObject *
const *kw_values, PyObject *kw_names) {
10107 assert(PyTuple_CheckExact(pos_args));
10108 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
10109 CHECK_OBJECTS(args, 5);
10110 CHECK_OBJECT(kw_names);
10111 assert(PyTuple_CheckExact(kw_names));
10112 CHECK_OBJECT(called);
10114 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
10116 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10118 if (Nuitka_Function_Check(called)) {
10119 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10125 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 5, kw_values, kw_names);
10127 Py_LeaveRecursiveCall();
10129 CHECK_OBJECT_X(result);
10132#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10133 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10134 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10136 if (likely(func != NULL)) {
10137 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 5 + kwargs_count);
10139 memcpy(vectorcall_args, args, 5 *
sizeof(PyObject *));
10140 memcpy(&vectorcall_args[5], kw_values, kwargs_count *
sizeof(PyObject *));
10142 PyObject *result = func(called, vectorcall_args, 5, kw_names);
10144 CHECK_OBJECT_X(result);
10146 return Nuitka_CheckFunctionResult(tstate, called, result);
10152 PRINT_STRING(
"FALLBACK");
10153 PRINT_ITEM(called);
10157 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10159 if (unlikely(call_slot == NULL)) {
10160 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10165 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10169 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
10171 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
10172 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10174 PyObject *value = kw_values[i];
10177 CHECK_OBJECT(value);
10179 DICT_SET_ITEM(named_args, key, value);
10182 PyObject *result = (*call_slot)(called, pos_args, named_args);
10184 Py_DECREF(named_args);
10186 Py_LeaveRecursiveCall();
10188 CHECK_OBJECT_X(result);
10190 return Nuitka_CheckFunctionResult(tstate, called, result);
10192PyObject *CALL_FUNCTION_WITH_ARGS6_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10193 PyObject *kw_names) {
10194 CHECK_OBJECTS(args, 6);
10195 CHECK_OBJECT(kw_names);
10196 assert(PyTuple_CheckExact(kw_names));
10197 CHECK_OBJECT(called);
10199 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
10201 CHECK_OBJECTS(&args[6], kwargs_count);
10203 if (Nuitka_Function_Check(called)) {
10204 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10211 Nuitka_CallFunctionVectorcall(tstate, function, args, 6, &PyTuple_GET_ITEM(kw_names, 0), kwargs_count);
10213 Py_LeaveRecursiveCall();
10215 CHECK_OBJECT_X(result);
10218#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10219 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10220 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10222 if (likely(func != NULL)) {
10223 PyObject *result = func(called, args, 6, kw_names);
10225 CHECK_OBJECT_X(result);
10227 return Nuitka_CheckFunctionResult(tstate, called, result);
10233 PRINT_STRING(
"FALLBACK");
10234 PRINT_ITEM(called);
10238 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10240 if (unlikely(call_slot == NULL)) {
10241 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10246 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10250 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
10252 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
10254 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
10255 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10257 PyObject *value = args[6 + i];
10260 CHECK_OBJECT(value);
10262 DICT_SET_ITEM(named_args, key, value);
10265 PyObject *result = (*call_slot)(called, pos_args, named_args);
10267 Py_DECREF(pos_args);
10268 Py_DECREF(named_args);
10270 Py_LeaveRecursiveCall();
10272 CHECK_OBJECT_X(result);
10274 return Nuitka_CheckFunctionResult(tstate, called, result);
10276PyObject *CALL_FUNCTION_WITH_ARGS6_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10277 PyObject *
const *kw_values, PyObject *kw_names) {
10278 CHECK_OBJECTS(args, 6);
10279 CHECK_OBJECT(kw_names);
10280 assert(PyTuple_CheckExact(kw_names));
10281 CHECK_OBJECT(called);
10283 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
10285 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10287 if (Nuitka_Function_Check(called)) {
10288 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10294 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 6, kw_values, kw_names);
10296 Py_LeaveRecursiveCall();
10298 CHECK_OBJECT_X(result);
10301#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10302 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10303 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10305 if (likely(func != NULL)) {
10306 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 6 + kwargs_count);
10308 memcpy(vectorcall_args, args, 6 *
sizeof(PyObject *));
10309 memcpy(&vectorcall_args[6], kw_values, kwargs_count *
sizeof(PyObject *));
10311 PyObject *result = func(called, vectorcall_args, 6, kw_names);
10313 CHECK_OBJECT_X(result);
10315 return Nuitka_CheckFunctionResult(tstate, called, result);
10321 PRINT_STRING(
"FALLBACK");
10322 PRINT_ITEM(called);
10326 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10328 if (unlikely(call_slot == NULL)) {
10329 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10334 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10338 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
10340 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
10342 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
10343 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10345 PyObject *value = kw_values[i];
10348 CHECK_OBJECT(value);
10350 DICT_SET_ITEM(named_args, key, value);
10353 PyObject *result = (*call_slot)(called, pos_args, named_args);
10355 Py_DECREF(pos_args);
10356 Py_DECREF(named_args);
10358 Py_LeaveRecursiveCall();
10360 CHECK_OBJECT_X(result);
10362 return Nuitka_CheckFunctionResult(tstate, called, result);
10364PyObject *CALL_FUNCTION_WITH_POS_ARGS6_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10365 PyObject *
const *kw_values, PyObject *kw_names) {
10366 assert(PyTuple_CheckExact(pos_args));
10367 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
10368 CHECK_OBJECTS(args, 6);
10369 CHECK_OBJECT(kw_names);
10370 assert(PyTuple_CheckExact(kw_names));
10371 CHECK_OBJECT(called);
10373 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
10375 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10377 if (Nuitka_Function_Check(called)) {
10378 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10384 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 6, kw_values, kw_names);
10386 Py_LeaveRecursiveCall();
10388 CHECK_OBJECT_X(result);
10391#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10392 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10393 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10395 if (likely(func != NULL)) {
10396 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 6 + kwargs_count);
10398 memcpy(vectorcall_args, args, 6 *
sizeof(PyObject *));
10399 memcpy(&vectorcall_args[6], kw_values, kwargs_count *
sizeof(PyObject *));
10401 PyObject *result = func(called, vectorcall_args, 6, kw_names);
10403 CHECK_OBJECT_X(result);
10405 return Nuitka_CheckFunctionResult(tstate, called, result);
10411 PRINT_STRING(
"FALLBACK");
10412 PRINT_ITEM(called);
10416 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10418 if (unlikely(call_slot == NULL)) {
10419 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10424 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10428 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
10430 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
10431 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10433 PyObject *value = kw_values[i];
10436 CHECK_OBJECT(value);
10438 DICT_SET_ITEM(named_args, key, value);
10441 PyObject *result = (*call_slot)(called, pos_args, named_args);
10443 Py_DECREF(named_args);
10445 Py_LeaveRecursiveCall();
10447 CHECK_OBJECT_X(result);
10449 return Nuitka_CheckFunctionResult(tstate, called, result);
10451PyObject *CALL_FUNCTION_WITH_ARGS7_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10452 PyObject *kw_names) {
10453 CHECK_OBJECTS(args, 7);
10454 CHECK_OBJECT(kw_names);
10455 assert(PyTuple_CheckExact(kw_names));
10456 CHECK_OBJECT(called);
10458 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
10460 CHECK_OBJECTS(&args[7], kwargs_count);
10462 if (Nuitka_Function_Check(called)) {
10463 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10470 Nuitka_CallFunctionVectorcall(tstate, function, args, 7, &PyTuple_GET_ITEM(kw_names, 0), kwargs_count);
10472 Py_LeaveRecursiveCall();
10474 CHECK_OBJECT_X(result);
10477#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10478 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10479 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10481 if (likely(func != NULL)) {
10482 PyObject *result = func(called, args, 7, kw_names);
10484 CHECK_OBJECT_X(result);
10486 return Nuitka_CheckFunctionResult(tstate, called, result);
10492 PRINT_STRING(
"FALLBACK");
10493 PRINT_ITEM(called);
10497 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10499 if (unlikely(call_slot == NULL)) {
10500 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10505 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10509 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
10511 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
10513 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
10514 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10516 PyObject *value = args[7 + i];
10519 CHECK_OBJECT(value);
10521 DICT_SET_ITEM(named_args, key, value);
10524 PyObject *result = (*call_slot)(called, pos_args, named_args);
10526 Py_DECREF(pos_args);
10527 Py_DECREF(named_args);
10529 Py_LeaveRecursiveCall();
10531 CHECK_OBJECT_X(result);
10533 return Nuitka_CheckFunctionResult(tstate, called, result);
10535PyObject *CALL_FUNCTION_WITH_ARGS7_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10536 PyObject *
const *kw_values, PyObject *kw_names) {
10537 CHECK_OBJECTS(args, 7);
10538 CHECK_OBJECT(kw_names);
10539 assert(PyTuple_CheckExact(kw_names));
10540 CHECK_OBJECT(called);
10542 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
10544 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10546 if (Nuitka_Function_Check(called)) {
10547 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10553 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 7, kw_values, kw_names);
10555 Py_LeaveRecursiveCall();
10557 CHECK_OBJECT_X(result);
10560#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10561 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10562 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10564 if (likely(func != NULL)) {
10565 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 7 + kwargs_count);
10567 memcpy(vectorcall_args, args, 7 *
sizeof(PyObject *));
10568 memcpy(&vectorcall_args[7], kw_values, kwargs_count *
sizeof(PyObject *));
10570 PyObject *result = func(called, vectorcall_args, 7, kw_names);
10572 CHECK_OBJECT_X(result);
10574 return Nuitka_CheckFunctionResult(tstate, called, result);
10580 PRINT_STRING(
"FALLBACK");
10581 PRINT_ITEM(called);
10585 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10587 if (unlikely(call_slot == NULL)) {
10588 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10593 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10597 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
10599 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
10601 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
10602 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10604 PyObject *value = kw_values[i];
10607 CHECK_OBJECT(value);
10609 DICT_SET_ITEM(named_args, key, value);
10612 PyObject *result = (*call_slot)(called, pos_args, named_args);
10614 Py_DECREF(pos_args);
10615 Py_DECREF(named_args);
10617 Py_LeaveRecursiveCall();
10619 CHECK_OBJECT_X(result);
10621 return Nuitka_CheckFunctionResult(tstate, called, result);
10623PyObject *CALL_FUNCTION_WITH_POS_ARGS7_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10624 PyObject *
const *kw_values, PyObject *kw_names) {
10625 assert(PyTuple_CheckExact(pos_args));
10626 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
10627 CHECK_OBJECTS(args, 7);
10628 CHECK_OBJECT(kw_names);
10629 assert(PyTuple_CheckExact(kw_names));
10630 CHECK_OBJECT(called);
10632 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
10634 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10636 if (Nuitka_Function_Check(called)) {
10637 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10643 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 7, kw_values, kw_names);
10645 Py_LeaveRecursiveCall();
10647 CHECK_OBJECT_X(result);
10650#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10651 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10652 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10654 if (likely(func != NULL)) {
10655 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 7 + kwargs_count);
10657 memcpy(vectorcall_args, args, 7 *
sizeof(PyObject *));
10658 memcpy(&vectorcall_args[7], kw_values, kwargs_count *
sizeof(PyObject *));
10660 PyObject *result = func(called, vectorcall_args, 7, kw_names);
10662 CHECK_OBJECT_X(result);
10664 return Nuitka_CheckFunctionResult(tstate, called, result);
10670 PRINT_STRING(
"FALLBACK");
10671 PRINT_ITEM(called);
10675 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10677 if (unlikely(call_slot == NULL)) {
10678 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10683 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10687 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
10689 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
10690 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10692 PyObject *value = kw_values[i];
10695 CHECK_OBJECT(value);
10697 DICT_SET_ITEM(named_args, key, value);
10700 PyObject *result = (*call_slot)(called, pos_args, named_args);
10702 Py_DECREF(named_args);
10704 Py_LeaveRecursiveCall();
10706 CHECK_OBJECT_X(result);
10708 return Nuitka_CheckFunctionResult(tstate, called, result);
10710PyObject *CALL_FUNCTION_WITH_ARGS8_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10711 PyObject *kw_names) {
10712 CHECK_OBJECTS(args, 8);
10713 CHECK_OBJECT(kw_names);
10714 assert(PyTuple_CheckExact(kw_names));
10715 CHECK_OBJECT(called);
10717 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
10719 CHECK_OBJECTS(&args[8], kwargs_count);
10721 if (Nuitka_Function_Check(called)) {
10722 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10729 Nuitka_CallFunctionVectorcall(tstate, function, args, 8, &PyTuple_GET_ITEM(kw_names, 0), kwargs_count);
10731 Py_LeaveRecursiveCall();
10733 CHECK_OBJECT_X(result);
10736#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10737 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10738 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10740 if (likely(func != NULL)) {
10741 PyObject *result = func(called, args, 8, kw_names);
10743 CHECK_OBJECT_X(result);
10745 return Nuitka_CheckFunctionResult(tstate, called, result);
10751 PRINT_STRING(
"FALLBACK");
10752 PRINT_ITEM(called);
10756 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10758 if (unlikely(call_slot == NULL)) {
10759 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10764 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10768 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
10770 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
10772 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
10773 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10775 PyObject *value = args[8 + i];
10778 CHECK_OBJECT(value);
10780 DICT_SET_ITEM(named_args, key, value);
10783 PyObject *result = (*call_slot)(called, pos_args, named_args);
10785 Py_DECREF(pos_args);
10786 Py_DECREF(named_args);
10788 Py_LeaveRecursiveCall();
10790 CHECK_OBJECT_X(result);
10792 return Nuitka_CheckFunctionResult(tstate, called, result);
10794PyObject *CALL_FUNCTION_WITH_ARGS8_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10795 PyObject *
const *kw_values, PyObject *kw_names) {
10796 CHECK_OBJECTS(args, 8);
10797 CHECK_OBJECT(kw_names);
10798 assert(PyTuple_CheckExact(kw_names));
10799 CHECK_OBJECT(called);
10801 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
10803 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10805 if (Nuitka_Function_Check(called)) {
10806 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10812 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 8, kw_values, kw_names);
10814 Py_LeaveRecursiveCall();
10816 CHECK_OBJECT_X(result);
10819#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10820 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10821 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10823 if (likely(func != NULL)) {
10824 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 8 + kwargs_count);
10826 memcpy(vectorcall_args, args, 8 *
sizeof(PyObject *));
10827 memcpy(&vectorcall_args[8], kw_values, kwargs_count *
sizeof(PyObject *));
10829 PyObject *result = func(called, vectorcall_args, 8, kw_names);
10831 CHECK_OBJECT_X(result);
10833 return Nuitka_CheckFunctionResult(tstate, called, result);
10839 PRINT_STRING(
"FALLBACK");
10840 PRINT_ITEM(called);
10844 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10846 if (unlikely(call_slot == NULL)) {
10847 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10852 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10856 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
10858 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
10860 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
10861 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10863 PyObject *value = kw_values[i];
10866 CHECK_OBJECT(value);
10868 DICT_SET_ITEM(named_args, key, value);
10871 PyObject *result = (*call_slot)(called, pos_args, named_args);
10873 Py_DECREF(pos_args);
10874 Py_DECREF(named_args);
10876 Py_LeaveRecursiveCall();
10878 CHECK_OBJECT_X(result);
10880 return Nuitka_CheckFunctionResult(tstate, called, result);
10882PyObject *CALL_FUNCTION_WITH_POS_ARGS8_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10883 PyObject *
const *kw_values, PyObject *kw_names) {
10884 assert(PyTuple_CheckExact(pos_args));
10885 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
10886 CHECK_OBJECTS(args, 8);
10887 CHECK_OBJECT(kw_names);
10888 assert(PyTuple_CheckExact(kw_names));
10889 CHECK_OBJECT(called);
10891 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
10893 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10895 if (Nuitka_Function_Check(called)) {
10896 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10902 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 8, kw_values, kw_names);
10904 Py_LeaveRecursiveCall();
10906 CHECK_OBJECT_X(result);
10909#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10910 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10911 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10913 if (likely(func != NULL)) {
10914 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 8 + kwargs_count);
10916 memcpy(vectorcall_args, args, 8 *
sizeof(PyObject *));
10917 memcpy(&vectorcall_args[8], kw_values, kwargs_count *
sizeof(PyObject *));
10919 PyObject *result = func(called, vectorcall_args, 8, kw_names);
10921 CHECK_OBJECT_X(result);
10923 return Nuitka_CheckFunctionResult(tstate, called, result);
10929 PRINT_STRING(
"FALLBACK");
10930 PRINT_ITEM(called);
10934 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10936 if (unlikely(call_slot == NULL)) {
10937 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
10942 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10946 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
10948 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
10949 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10951 PyObject *value = kw_values[i];
10954 CHECK_OBJECT(value);
10956 DICT_SET_ITEM(named_args, key, value);
10959 PyObject *result = (*call_slot)(called, pos_args, named_args);
10961 Py_DECREF(named_args);
10963 Py_LeaveRecursiveCall();
10965 CHECK_OBJECT_X(result);
10967 return Nuitka_CheckFunctionResult(tstate, called, result);
10969PyObject *CALL_FUNCTION_WITH_ARGS9_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
10970 PyObject *kw_names) {
10971 CHECK_OBJECTS(args, 9);
10972 CHECK_OBJECT(kw_names);
10973 assert(PyTuple_CheckExact(kw_names));
10974 CHECK_OBJECT(called);
10976 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
10978 CHECK_OBJECTS(&args[9], kwargs_count);
10980 if (Nuitka_Function_Check(called)) {
10981 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
10988 Nuitka_CallFunctionVectorcall(tstate, function, args, 9, &PyTuple_GET_ITEM(kw_names, 0), kwargs_count);
10990 Py_LeaveRecursiveCall();
10992 CHECK_OBJECT_X(result);
10995#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10996 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10997 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10999 if (likely(func != NULL)) {
11000 PyObject *result = func(called, args, 9, kw_names);
11002 CHECK_OBJECT_X(result);
11004 return Nuitka_CheckFunctionResult(tstate, called, result);
11010 PRINT_STRING(
"FALLBACK");
11011 PRINT_ITEM(called);
11015 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11017 if (unlikely(call_slot == NULL)) {
11018 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11023 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11027 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
11029 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
11031 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
11032 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11034 PyObject *value = args[9 + i];
11037 CHECK_OBJECT(value);
11039 DICT_SET_ITEM(named_args, key, value);
11042 PyObject *result = (*call_slot)(called, pos_args, named_args);
11044 Py_DECREF(pos_args);
11045 Py_DECREF(named_args);
11047 Py_LeaveRecursiveCall();
11049 CHECK_OBJECT_X(result);
11051 return Nuitka_CheckFunctionResult(tstate, called, result);
11053PyObject *CALL_FUNCTION_WITH_ARGS9_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
11054 PyObject *
const *kw_values, PyObject *kw_names) {
11055 CHECK_OBJECTS(args, 9);
11056 CHECK_OBJECT(kw_names);
11057 assert(PyTuple_CheckExact(kw_names));
11058 CHECK_OBJECT(called);
11060 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
11062 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11064 if (Nuitka_Function_Check(called)) {
11065 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11071 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 9, kw_values, kw_names);
11073 Py_LeaveRecursiveCall();
11075 CHECK_OBJECT_X(result);
11078#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11079 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11080 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11082 if (likely(func != NULL)) {
11083 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 9 + kwargs_count);
11085 memcpy(vectorcall_args, args, 9 *
sizeof(PyObject *));
11086 memcpy(&vectorcall_args[9], kw_values, kwargs_count *
sizeof(PyObject *));
11088 PyObject *result = func(called, vectorcall_args, 9, kw_names);
11090 CHECK_OBJECT_X(result);
11092 return Nuitka_CheckFunctionResult(tstate, called, result);
11098 PRINT_STRING(
"FALLBACK");
11099 PRINT_ITEM(called);
11103 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11105 if (unlikely(call_slot == NULL)) {
11106 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11111 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11115 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
11117 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
11119 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
11120 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11122 PyObject *value = kw_values[i];
11125 CHECK_OBJECT(value);
11127 DICT_SET_ITEM(named_args, key, value);
11130 PyObject *result = (*call_slot)(called, pos_args, named_args);
11132 Py_DECREF(pos_args);
11133 Py_DECREF(named_args);
11135 Py_LeaveRecursiveCall();
11137 CHECK_OBJECT_X(result);
11139 return Nuitka_CheckFunctionResult(tstate, called, result);
11141PyObject *CALL_FUNCTION_WITH_POS_ARGS9_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
11142 PyObject *
const *kw_values, PyObject *kw_names) {
11143 assert(PyTuple_CheckExact(pos_args));
11144 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
11145 CHECK_OBJECTS(args, 9);
11146 CHECK_OBJECT(kw_names);
11147 assert(PyTuple_CheckExact(kw_names));
11148 CHECK_OBJECT(called);
11150 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
11152 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11154 if (Nuitka_Function_Check(called)) {
11155 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11161 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 9, kw_values, kw_names);
11163 Py_LeaveRecursiveCall();
11165 CHECK_OBJECT_X(result);
11168#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11169 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11170 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11172 if (likely(func != NULL)) {
11173 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 9 + kwargs_count);
11175 memcpy(vectorcall_args, args, 9 *
sizeof(PyObject *));
11176 memcpy(&vectorcall_args[9], kw_values, kwargs_count *
sizeof(PyObject *));
11178 PyObject *result = func(called, vectorcall_args, 9, kw_names);
11180 CHECK_OBJECT_X(result);
11182 return Nuitka_CheckFunctionResult(tstate, called, result);
11188 PRINT_STRING(
"FALLBACK");
11189 PRINT_ITEM(called);
11193 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11195 if (unlikely(call_slot == NULL)) {
11196 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11201 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11205 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
11207 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
11208 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11210 PyObject *value = kw_values[i];
11213 CHECK_OBJECT(value);
11215 DICT_SET_ITEM(named_args, key, value);
11218 PyObject *result = (*call_slot)(called, pos_args, named_args);
11220 Py_DECREF(named_args);
11222 Py_LeaveRecursiveCall();
11224 CHECK_OBJECT_X(result);
11226 return Nuitka_CheckFunctionResult(tstate, called, result);
11228PyObject *CALL_FUNCTION_WITH_ARGS10_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
11229 PyObject *kw_names) {
11230 CHECK_OBJECTS(args, 10);
11231 CHECK_OBJECT(kw_names);
11232 assert(PyTuple_CheckExact(kw_names));
11233 CHECK_OBJECT(called);
11235 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
11237 CHECK_OBJECTS(&args[10], kwargs_count);
11239 if (Nuitka_Function_Check(called)) {
11240 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11247 Nuitka_CallFunctionVectorcall(tstate, function, args, 10, &PyTuple_GET_ITEM(kw_names, 0), kwargs_count);
11249 Py_LeaveRecursiveCall();
11251 CHECK_OBJECT_X(result);
11254#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11255 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11256 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11258 if (likely(func != NULL)) {
11259 PyObject *result = func(called, args, 10, kw_names);
11261 CHECK_OBJECT_X(result);
11263 return Nuitka_CheckFunctionResult(tstate, called, result);
11269 PRINT_STRING(
"FALLBACK");
11270 PRINT_ITEM(called);
11274 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11276 if (unlikely(call_slot == NULL)) {
11277 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11282 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11286 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
11288 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
11290 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
11291 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11293 PyObject *value = args[10 + i];
11296 CHECK_OBJECT(value);
11298 DICT_SET_ITEM(named_args, key, value);
11301 PyObject *result = (*call_slot)(called, pos_args, named_args);
11303 Py_DECREF(pos_args);
11304 Py_DECREF(named_args);
11306 Py_LeaveRecursiveCall();
11308 CHECK_OBJECT_X(result);
11310 return Nuitka_CheckFunctionResult(tstate, called, result);
11312PyObject *CALL_FUNCTION_WITH_ARGS10_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *
const *args,
11313 PyObject *
const *kw_values, PyObject *kw_names) {
11314 CHECK_OBJECTS(args, 10);
11315 CHECK_OBJECT(kw_names);
11316 assert(PyTuple_CheckExact(kw_names));
11317 CHECK_OBJECT(called);
11319 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
11321 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11323 if (Nuitka_Function_Check(called)) {
11324 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11330 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 10, kw_values, kw_names);
11332 Py_LeaveRecursiveCall();
11334 CHECK_OBJECT_X(result);
11337#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11338 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11339 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11341 if (likely(func != NULL)) {
11342 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 10 + kwargs_count);
11344 memcpy(vectorcall_args, args, 10 *
sizeof(PyObject *));
11345 memcpy(&vectorcall_args[10], kw_values, kwargs_count *
sizeof(PyObject *));
11347 PyObject *result = func(called, vectorcall_args, 10, kw_names);
11349 CHECK_OBJECT_X(result);
11351 return Nuitka_CheckFunctionResult(tstate, called, result);
11357 PRINT_STRING(
"FALLBACK");
11358 PRINT_ITEM(called);
11362 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11364 if (unlikely(call_slot == NULL)) {
11365 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11370 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11374 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
11376 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
11378 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
11379 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11381 PyObject *value = kw_values[i];
11384 CHECK_OBJECT(value);
11386 DICT_SET_ITEM(named_args, key, value);
11389 PyObject *result = (*call_slot)(called, pos_args, named_args);
11391 Py_DECREF(pos_args);
11392 Py_DECREF(named_args);
11394 Py_LeaveRecursiveCall();
11396 CHECK_OBJECT_X(result);
11398 return Nuitka_CheckFunctionResult(tstate, called, result);
11400PyObject *CALL_FUNCTION_WITH_POS_ARGS10_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
11401 PyObject *
const *kw_values, PyObject *kw_names) {
11402 assert(PyTuple_CheckExact(pos_args));
11403 PyObject *
const *args = &PyTuple_GET_ITEM(pos_args, 0);
11404 CHECK_OBJECTS(args, 10);
11405 CHECK_OBJECT(kw_names);
11406 assert(PyTuple_CheckExact(kw_names));
11407 CHECK_OBJECT(called);
11409 Py_ssize_t kwargs_count = PyTuple_GET_SIZE(kw_names);
11411 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11413 if (Nuitka_Function_Check(called)) {
11414 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11420 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 10, kw_values, kw_names);
11422 Py_LeaveRecursiveCall();
11424 CHECK_OBJECT_X(result);
11427#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11428 }
else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11429 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11431 if (likely(func != NULL)) {
11432 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 10 + kwargs_count);
11434 memcpy(vectorcall_args, args, 10 *
sizeof(PyObject *));
11435 memcpy(&vectorcall_args[10], kw_values, kwargs_count *
sizeof(PyObject *));
11437 PyObject *result = func(called, vectorcall_args, 10, kw_names);
11439 CHECK_OBJECT_X(result);
11441 return Nuitka_CheckFunctionResult(tstate, called, result);
11447 PRINT_STRING(
"FALLBACK");
11448 PRINT_ITEM(called);
11452 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11454 if (unlikely(call_slot == NULL)) {
11455 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT(
"'%s' object is not callable", called);
11460 if (unlikely(Py_EnterRecursiveCall((
char *)
" while calling a Python object"))) {
11464 PyObject *named_args = _PyDict_NewPresized(kwargs_count);
11466 for (Py_ssize_t i = 0; i < kwargs_count; i++) {
11467 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11469 PyObject *value = kw_values[i];
11472 CHECK_OBJECT(value);
11474 DICT_SET_ITEM(named_args, key, value);
11477 PyObject *result = (*call_slot)(called, pos_args, named_args);
11479 Py_DECREF(named_args);
11481 Py_LeaveRecursiveCall();
11483 CHECK_OBJECT_X(result);
11485 return Nuitka_CheckFunctionResult(tstate, called, result);
11487PyObject *CALL_METHODDESCR_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *called, PyObject *arg) {
11488 PyObject *
const *args = &arg;
11489 CHECK_OBJECT(called);
11490 CHECK_OBJECTS(args, 1);
11492#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11493 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11494 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11495 assert(func != NULL);
11496 PyObject *result = func(called, args, 1, NULL);
11498#ifndef __NUITKA_NO_ASSERT__
11499 return Nuitka_CheckFunctionResult(tstate, called, result);
11504 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11505 PyMethodDef *method_def = called_descr->d_method;
11508 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11510 if (likely(flags & METH_NOARGS)) {
11511 PyCFunction method = method_def->ml_meth;
11512 PyObject *self = args[0];
11514 PyObject *result = (*method)(self, NULL);
11516#ifndef __NUITKA_NO_ASSERT__
11517 return Nuitka_CheckFunctionResult(tstate, called, result);
11521 }
else if ((flags & METH_O)) {
11522 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (1 given)",
11523 method_def->ml_name);
11525 }
else if (flags & METH_VARARGS) {
11526 PyCFunction method = method_def->ml_meth;
11527 PyObject *self = args[0];
11531#if PYTHON_VERSION < 0x360
11532 if (flags & METH_KEYWORDS) {
11533 result = (*(PyCFunctionWithKeywords)method)(self, const_tuple_empty, NULL);
11535 result = (*method)(self, const_tuple_empty);
11538 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11539 result = (*(PyCFunctionWithKeywords)method)(self, const_tuple_empty, NULL);
11540 }
else if (flags == METH_FASTCALL) {
11541#if PYTHON_VERSION < 0x370
11542 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 0, NULL);
11544 result = (*(_PyCFunctionFast)method)(self, &const_tuple_empty, 1);
11547 result = (*method)(self, const_tuple_empty);
11550#ifndef __NUITKA_NO_ASSERT__
11551 return Nuitka_CheckFunctionResult(tstate, called, result);
11559 PRINT_STRING(
"FALLBACK");
11560 PRINT_ITEM(called);
11564 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
11566 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11568 Py_DECREF(pos_args);
11573PyObject *CALL_METHODDESCR_WITH_ARGS2(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
11574 CHECK_OBJECT(called);
11575 CHECK_OBJECTS(args, 2);
11577#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11578 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11579 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11580 assert(func != NULL);
11581 PyObject *result = func(called, args, 2, NULL);
11583#ifndef __NUITKA_NO_ASSERT__
11584 return Nuitka_CheckFunctionResult(tstate, called, result);
11589 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11590 PyMethodDef *method_def = called_descr->d_method;
11593 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11595 if (unlikely(flags & METH_NOARGS)) {
11596 PyCFunction method = method_def->ml_meth;
11597 PyObject *self = args[0];
11599 PyObject *result = (*method)(self, NULL);
11601#ifndef __NUITKA_NO_ASSERT__
11602 return Nuitka_CheckFunctionResult(tstate, called, result);
11606 }
else if (unlikely(flags & METH_O)) {
11607 PyCFunction method = method_def->ml_meth;
11608 PyObject *self = args[0];
11610 PyObject *result = (*method)(self, args[1]);
11612#ifndef __NUITKA_NO_ASSERT__
11613 return Nuitka_CheckFunctionResult(tstate, called, result);
11617 }
else if (flags & METH_VARARGS) {
11618 PyCFunction method = method_def->ml_meth;
11619 PyObject *self = args[0];
11623#if PYTHON_VERSION < 0x360
11624 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11626 if (flags & METH_KEYWORDS) {
11627 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11629 result = (*method)(self, pos_args);
11632 Py_DECREF(pos_args);
11634 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11635 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11636 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11637 Py_DECREF(pos_args);
11638 }
else if (flags == METH_FASTCALL) {
11639#if PYTHON_VERSION < 0x370
11640 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 1, NULL);
11642 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11643 result = (*(_PyCFunctionFast)method)(self, &pos_args, 2);
11644 Py_DECREF(pos_args);
11647 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11648 result = (*method)(self, pos_args);
11649 Py_DECREF(pos_args);
11652#ifndef __NUITKA_NO_ASSERT__
11653 return Nuitka_CheckFunctionResult(tstate, called, result);
11661 PRINT_STRING(
"FALLBACK");
11662 PRINT_ITEM(called);
11666 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
11668 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11670 Py_DECREF(pos_args);
11675PyObject *CALL_METHODDESCR_WITH_ARGS3(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
11676 CHECK_OBJECT(called);
11677 CHECK_OBJECTS(args, 3);
11679#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11680 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11681 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11682 assert(func != NULL);
11683 PyObject *result = func(called, args, 3, NULL);
11685#ifndef __NUITKA_NO_ASSERT__
11686 return Nuitka_CheckFunctionResult(tstate, called, result);
11691 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11692 PyMethodDef *method_def = called_descr->d_method;
11695 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11697 if (unlikely(flags & METH_NOARGS)) {
11698 PyCFunction method = method_def->ml_meth;
11699 PyObject *self = args[0];
11701 PyObject *result = (*method)(self, NULL);
11703#ifndef __NUITKA_NO_ASSERT__
11704 return Nuitka_CheckFunctionResult(tstate, called, result);
11708 }
else if (unlikely(flags & METH_O)) {
11709 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (3 given)",
11710 method_def->ml_name);
11712 }
else if (flags & METH_VARARGS) {
11713 PyCFunction method = method_def->ml_meth;
11714 PyObject *self = args[0];
11718#if PYTHON_VERSION < 0x360
11719 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11721 if (flags & METH_KEYWORDS) {
11722 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11724 result = (*method)(self, pos_args);
11727 Py_DECREF(pos_args);
11729 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11730 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11731 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11732 Py_DECREF(pos_args);
11733 }
else if (flags == METH_FASTCALL) {
11734#if PYTHON_VERSION < 0x370
11735 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 2, NULL);
11737 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11738 result = (*(_PyCFunctionFast)method)(self, &pos_args, 3);
11739 Py_DECREF(pos_args);
11742 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11743 result = (*method)(self, pos_args);
11744 Py_DECREF(pos_args);
11747#ifndef __NUITKA_NO_ASSERT__
11748 return Nuitka_CheckFunctionResult(tstate, called, result);
11756 PRINT_STRING(
"FALLBACK");
11757 PRINT_ITEM(called);
11761 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
11763 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11765 Py_DECREF(pos_args);
11770PyObject *CALL_METHODDESCR_WITH_ARGS4(PyThreadState *tstate, PyObject *called, PyObject *
const *args) {
11771 CHECK_OBJECT(called);
11772 CHECK_OBJECTS(args, 4);
11774#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11775 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11776 vectorcallfunc func = *((vectorcallfunc *)(((
char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11777 assert(func != NULL);
11778 PyObject *result = func(called, args, 4, NULL);
11780#ifndef __NUITKA_NO_ASSERT__
11781 return Nuitka_CheckFunctionResult(tstate, called, result);
11786 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11787 PyMethodDef *method_def = called_descr->d_method;
11790 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11792 if (unlikely(flags & METH_NOARGS)) {
11793 PyCFunction method = method_def->ml_meth;
11794 PyObject *self = args[0];
11796 PyObject *result = (*method)(self, NULL);
11798#ifndef __NUITKA_NO_ASSERT__
11799 return Nuitka_CheckFunctionResult(tstate, called, result);
11803 }
else if (unlikely(flags & METH_O)) {
11804 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError,
"%s() takes exactly one argument (4 given)",
11805 method_def->ml_name);
11807 }
else if (flags & METH_VARARGS) {
11808 PyCFunction method = method_def->ml_meth;
11809 PyObject *self = args[0];
11813#if PYTHON_VERSION < 0x360
11814 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11816 if (flags & METH_KEYWORDS) {
11817 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11819 result = (*method)(self, pos_args);
11822 Py_DECREF(pos_args);
11824 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11825 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11826 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11827 Py_DECREF(pos_args);
11828 }
else if (flags == METH_FASTCALL) {
11829#if PYTHON_VERSION < 0x370
11830 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 3, NULL);
11832 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11833 result = (*(_PyCFunctionFast)method)(self, &pos_args, 4);
11834 Py_DECREF(pos_args);
11837 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11838 result = (*method)(self, pos_args);
11839 Py_DECREF(pos_args);
11842#ifndef __NUITKA_NO_ASSERT__
11843 return Nuitka_CheckFunctionResult(tstate, called, result);
11851 PRINT_STRING(
"FALLBACK");
11852 PRINT_ITEM(called);
11856 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
11858 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11860 Py_DECREF(pos_args);
11865PyObject *CALL_METHOD_NO_ARGS(PyThreadState *tstate, PyObject *source, PyObject *attr_name) {
11866 CHECK_OBJECT(source);
11867 CHECK_OBJECT(attr_name);
11869 PyTypeObject *type = Py_TYPE(source);
11871 if (hasTypeGenericGetAttr(type)) {
11873 if (unlikely(type->tp_dict == NULL)) {
11874 if (unlikely(PyType_Ready(type) < 0)) {
11879 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
11880 descrgetfunc func = NULL;
11882 if (descr != NULL) {
11885 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
11886 func = Py_TYPE(descr)->tp_descr_get;
11888 if (func != NULL && Nuitka_Descr_IsData(descr)) {
11889 PyObject *called_object = func(descr, source, (PyObject *)type);
11892 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
11893 Py_DECREF(called_object);
11899 Py_ssize_t dictoffset = type->tp_dictoffset;
11900 PyObject *dict = NULL;
11902 if (dictoffset != 0) {
11904 if (dictoffset < 0) {
11908 tsize = ((PyVarObject *)source)->ob_size;
11912 size = _PyObject_VAR_SIZE(type, tsize);
11914 dictoffset += (long)size;
11917 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
11921 if (dict != NULL) {
11922 CHECK_OBJECT(dict);
11926 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
11928 if (called_object != NULL) {
11932 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
11933 Py_DECREF(called_object);
11940 if (func != NULL) {
11941 if (func == Nuitka_Function_Type.tp_descr_get) {
11948 PyObject *called_object = func(descr, source, (PyObject *)type);
11949 CHECK_OBJECT(called_object);
11953 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
11954 Py_DECREF(called_object);
11959 if (descr != NULL) {
11960 CHECK_OBJECT(descr);
11962 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, descr);
11967#if PYTHON_VERSION < 0x300
11968 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
11969 PyString_AS_STRING(attr_name));
11971 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
11975#if PYTHON_VERSION < 0x300
11976 else if (type == &PyInstance_Type) {
11977 PyInstanceObject *source_instance = (PyInstanceObject *)source;
11981 assert(attr_name != const_str_plain___dict__);
11982 assert(attr_name != const_str_plain___class__);
11985 PyObject *called_object =
11986 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
11990 if (called_object != NULL) {
11991 return CALL_FUNCTION_NO_ARGS(tstate, called_object);
11995 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
11999 if (called_object != NULL) {
12000 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12002 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12003 return Nuitka_CallMethodFunctionNoArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12005 }
else if (descr_get != NULL) {
12006 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12008 if (unlikely(method == NULL)) {
12012 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, method);
12016 return CALL_FUNCTION_NO_ARGS(tstate, called_object);
12019 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12020 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12021 PyString_AS_STRING(source_instance->in_class->cl_name),
12022 PyString_AS_STRING(attr_name));
12029 PyObject *args2[] = {source, attr_name};
12031 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12033 if (unlikely(called_object == NULL)) {
12037 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
12038 Py_DECREF(called_object);
12043 else if (type->tp_getattro != NULL) {
12044 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12046 if (unlikely(descr == NULL)) {
12050 descrgetfunc func = NULL;
12051 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12052 func = Py_TYPE(descr)->tp_descr_get;
12054 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12055 PyObject *called_object = func(descr, source, (PyObject *)type);
12058 if (unlikely(called_object == NULL)) {
12062 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
12063 Py_DECREF(called_object);
12068 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, descr);
12071 }
else if (type->tp_getattr != NULL) {
12072 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12074 if (unlikely(called_object == NULL)) {
12078 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
12079 Py_DECREF(called_object);
12082 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12083 Nuitka_String_AsString_Unchecked(attr_name));
12088PyObject *CALL_METHOD_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *arg) {
12089 PyObject *
const *args = &arg;
12090 CHECK_OBJECT(source);
12091 CHECK_OBJECT(attr_name);
12093 CHECK_OBJECTS(args, 1);
12095 PyTypeObject *type = Py_TYPE(source);
12097 if (hasTypeGenericGetAttr(type)) {
12099 if (unlikely(type->tp_dict == NULL)) {
12100 if (unlikely(PyType_Ready(type) < 0)) {
12105 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12106 descrgetfunc func = NULL;
12108 if (descr != NULL) {
12111 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12112 func = Py_TYPE(descr)->tp_descr_get;
12114 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12115 PyObject *called_object = func(descr, source, (PyObject *)type);
12118 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12119 Py_DECREF(called_object);
12125 Py_ssize_t dictoffset = type->tp_dictoffset;
12126 PyObject *dict = NULL;
12128 if (dictoffset != 0) {
12130 if (dictoffset < 0) {
12134 tsize = ((PyVarObject *)source)->ob_size;
12138 size = _PyObject_VAR_SIZE(type, tsize);
12140 dictoffset += (long)size;
12143 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
12147 if (dict != NULL) {
12148 CHECK_OBJECT(dict);
12152 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12154 if (called_object != NULL) {
12158 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12159 Py_DECREF(called_object);
12166 if (func != NULL) {
12167 if (func == Nuitka_Function_Type.tp_descr_get) {
12168 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
12174 PyObject *called_object = func(descr, source, (PyObject *)type);
12175 CHECK_OBJECT(called_object);
12179 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12180 Py_DECREF(called_object);
12185 if (descr != NULL) {
12186 CHECK_OBJECT(descr);
12188 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, descr, args[0]);
12193#if PYTHON_VERSION < 0x300
12194 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12195 PyString_AS_STRING(attr_name));
12197 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
12201#if PYTHON_VERSION < 0x300
12202 else if (type == &PyInstance_Type) {
12203 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12207 assert(attr_name != const_str_plain___dict__);
12208 assert(attr_name != const_str_plain___class__);
12211 PyObject *called_object =
12212 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12216 if (called_object != NULL) {
12217 return CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12221 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12225 if (called_object != NULL) {
12226 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12228 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12229 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12231 }
else if (descr_get != NULL) {
12232 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12234 if (unlikely(method == NULL)) {
12238 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, method, args[0]);
12242 return CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12245 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12246 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12247 PyString_AS_STRING(source_instance->in_class->cl_name),
12248 PyString_AS_STRING(attr_name));
12255 PyObject *args2[] = {source, attr_name};
12257 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12259 if (unlikely(called_object == NULL)) {
12263 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12264 Py_DECREF(called_object);
12269 else if (type->tp_getattro != NULL) {
12270 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12272 if (unlikely(descr == NULL)) {
12276 descrgetfunc func = NULL;
12277 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12278 func = Py_TYPE(descr)->tp_descr_get;
12280 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12281 PyObject *called_object = func(descr, source, (PyObject *)type);
12284 if (unlikely(called_object == NULL)) {
12288 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12289 Py_DECREF(called_object);
12294 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, descr, args[0]);
12297 }
else if (type->tp_getattr != NULL) {
12298 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12300 if (unlikely(called_object == NULL)) {
12304 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12305 Py_DECREF(called_object);
12308 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12309 Nuitka_String_AsString_Unchecked(attr_name));
12314PyObject *CALL_METHOD_WITH_ARGS2(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
12315 CHECK_OBJECT(source);
12316 CHECK_OBJECT(attr_name);
12318 CHECK_OBJECTS(args, 2);
12320 PyTypeObject *type = Py_TYPE(source);
12322 if (hasTypeGenericGetAttr(type)) {
12324 if (unlikely(type->tp_dict == NULL)) {
12325 if (unlikely(PyType_Ready(type) < 0)) {
12330 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12331 descrgetfunc func = NULL;
12333 if (descr != NULL) {
12336 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12337 func = Py_TYPE(descr)->tp_descr_get;
12339 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12340 PyObject *called_object = func(descr, source, (PyObject *)type);
12343 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12344 Py_DECREF(called_object);
12350 Py_ssize_t dictoffset = type->tp_dictoffset;
12351 PyObject *dict = NULL;
12353 if (dictoffset != 0) {
12355 if (dictoffset < 0) {
12359 tsize = ((PyVarObject *)source)->ob_size;
12363 size = _PyObject_VAR_SIZE(type, tsize);
12365 dictoffset += (long)size;
12368 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
12372 if (dict != NULL) {
12373 CHECK_OBJECT(dict);
12377 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12379 if (called_object != NULL) {
12383 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12384 Py_DECREF(called_object);
12391 if (func != NULL) {
12392 if (func == Nuitka_Function_Type.tp_descr_get) {
12393 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
12399 PyObject *called_object = func(descr, source, (PyObject *)type);
12400 CHECK_OBJECT(called_object);
12404 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12405 Py_DECREF(called_object);
12410 if (descr != NULL) {
12411 CHECK_OBJECT(descr);
12413 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, descr, args);
12418#if PYTHON_VERSION < 0x300
12419 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12420 PyString_AS_STRING(attr_name));
12422 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
12426#if PYTHON_VERSION < 0x300
12427 else if (type == &PyInstance_Type) {
12428 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12432 assert(attr_name != const_str_plain___dict__);
12433 assert(attr_name != const_str_plain___class__);
12436 PyObject *called_object =
12437 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12441 if (called_object != NULL) {
12442 return CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12446 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12450 if (called_object != NULL) {
12451 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12453 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12454 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12456 }
else if (descr_get != NULL) {
12457 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12459 if (unlikely(method == NULL)) {
12463 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, method, args);
12467 return CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12470 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12471 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12472 PyString_AS_STRING(source_instance->in_class->cl_name),
12473 PyString_AS_STRING(attr_name));
12480 PyObject *args2[] = {source, attr_name};
12482 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12484 if (unlikely(called_object == NULL)) {
12488 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12489 Py_DECREF(called_object);
12494 else if (type->tp_getattro != NULL) {
12495 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12497 if (unlikely(descr == NULL)) {
12501 descrgetfunc func = NULL;
12502 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12503 func = Py_TYPE(descr)->tp_descr_get;
12505 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12506 PyObject *called_object = func(descr, source, (PyObject *)type);
12509 if (unlikely(called_object == NULL)) {
12513 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12514 Py_DECREF(called_object);
12519 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, descr, args);
12522 }
else if (type->tp_getattr != NULL) {
12523 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12525 if (unlikely(called_object == NULL)) {
12529 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12530 Py_DECREF(called_object);
12533 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12534 Nuitka_String_AsString_Unchecked(attr_name));
12539PyObject *CALL_METHOD_WITH_ARGS3(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
12540 CHECK_OBJECT(source);
12541 CHECK_OBJECT(attr_name);
12543 CHECK_OBJECTS(args, 3);
12545 PyTypeObject *type = Py_TYPE(source);
12547 if (hasTypeGenericGetAttr(type)) {
12549 if (unlikely(type->tp_dict == NULL)) {
12550 if (unlikely(PyType_Ready(type) < 0)) {
12555 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12556 descrgetfunc func = NULL;
12558 if (descr != NULL) {
12561 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12562 func = Py_TYPE(descr)->tp_descr_get;
12564 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12565 PyObject *called_object = func(descr, source, (PyObject *)type);
12568 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12569 Py_DECREF(called_object);
12575 Py_ssize_t dictoffset = type->tp_dictoffset;
12576 PyObject *dict = NULL;
12578 if (dictoffset != 0) {
12580 if (dictoffset < 0) {
12584 tsize = ((PyVarObject *)source)->ob_size;
12588 size = _PyObject_VAR_SIZE(type, tsize);
12590 dictoffset += (long)size;
12593 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
12597 if (dict != NULL) {
12598 CHECK_OBJECT(dict);
12602 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12604 if (called_object != NULL) {
12608 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12609 Py_DECREF(called_object);
12616 if (func != NULL) {
12617 if (func == Nuitka_Function_Type.tp_descr_get) {
12618 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
12624 PyObject *called_object = func(descr, source, (PyObject *)type);
12625 CHECK_OBJECT(called_object);
12629 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12630 Py_DECREF(called_object);
12635 if (descr != NULL) {
12636 CHECK_OBJECT(descr);
12638 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, descr, args);
12643#if PYTHON_VERSION < 0x300
12644 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12645 PyString_AS_STRING(attr_name));
12647 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
12651#if PYTHON_VERSION < 0x300
12652 else if (type == &PyInstance_Type) {
12653 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12657 assert(attr_name != const_str_plain___dict__);
12658 assert(attr_name != const_str_plain___class__);
12661 PyObject *called_object =
12662 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12666 if (called_object != NULL) {
12667 return CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12671 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12675 if (called_object != NULL) {
12676 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12678 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12679 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12681 }
else if (descr_get != NULL) {
12682 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12684 if (unlikely(method == NULL)) {
12688 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, method, args);
12692 return CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12695 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12696 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12697 PyString_AS_STRING(source_instance->in_class->cl_name),
12698 PyString_AS_STRING(attr_name));
12705 PyObject *args2[] = {source, attr_name};
12707 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12709 if (unlikely(called_object == NULL)) {
12713 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12714 Py_DECREF(called_object);
12719 else if (type->tp_getattro != NULL) {
12720 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12722 if (unlikely(descr == NULL)) {
12726 descrgetfunc func = NULL;
12727 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12728 func = Py_TYPE(descr)->tp_descr_get;
12730 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12731 PyObject *called_object = func(descr, source, (PyObject *)type);
12734 if (unlikely(called_object == NULL)) {
12738 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12739 Py_DECREF(called_object);
12744 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, descr, args);
12747 }
else if (type->tp_getattr != NULL) {
12748 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12750 if (unlikely(called_object == NULL)) {
12754 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12755 Py_DECREF(called_object);
12758 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12759 Nuitka_String_AsString_Unchecked(attr_name));
12764PyObject *CALL_METHOD_WITH_ARGS4(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
12765 CHECK_OBJECT(source);
12766 CHECK_OBJECT(attr_name);
12768 CHECK_OBJECTS(args, 4);
12770 PyTypeObject *type = Py_TYPE(source);
12772 if (hasTypeGenericGetAttr(type)) {
12774 if (unlikely(type->tp_dict == NULL)) {
12775 if (unlikely(PyType_Ready(type) < 0)) {
12780 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12781 descrgetfunc func = NULL;
12783 if (descr != NULL) {
12786 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12787 func = Py_TYPE(descr)->tp_descr_get;
12789 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12790 PyObject *called_object = func(descr, source, (PyObject *)type);
12793 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12794 Py_DECREF(called_object);
12800 Py_ssize_t dictoffset = type->tp_dictoffset;
12801 PyObject *dict = NULL;
12803 if (dictoffset != 0) {
12805 if (dictoffset < 0) {
12809 tsize = ((PyVarObject *)source)->ob_size;
12813 size = _PyObject_VAR_SIZE(type, tsize);
12815 dictoffset += (long)size;
12818 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
12822 if (dict != NULL) {
12823 CHECK_OBJECT(dict);
12827 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12829 if (called_object != NULL) {
12833 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12834 Py_DECREF(called_object);
12841 if (func != NULL) {
12842 if (func == Nuitka_Function_Type.tp_descr_get) {
12843 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
12849 PyObject *called_object = func(descr, source, (PyObject *)type);
12850 CHECK_OBJECT(called_object);
12854 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12855 Py_DECREF(called_object);
12860 if (descr != NULL) {
12861 CHECK_OBJECT(descr);
12863 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, descr, args);
12868#if PYTHON_VERSION < 0x300
12869 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12870 PyString_AS_STRING(attr_name));
12872 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
12876#if PYTHON_VERSION < 0x300
12877 else if (type == &PyInstance_Type) {
12878 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12882 assert(attr_name != const_str_plain___dict__);
12883 assert(attr_name != const_str_plain___class__);
12886 PyObject *called_object =
12887 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12891 if (called_object != NULL) {
12892 return CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12896 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12900 if (called_object != NULL) {
12901 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12903 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12904 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
12906 }
else if (descr_get != NULL) {
12907 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12909 if (unlikely(method == NULL)) {
12913 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, method, args);
12917 return CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12920 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12921 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
12922 PyString_AS_STRING(source_instance->in_class->cl_name),
12923 PyString_AS_STRING(attr_name));
12930 PyObject *args2[] = {source, attr_name};
12932 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12934 if (unlikely(called_object == NULL)) {
12938 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12939 Py_DECREF(called_object);
12944 else if (type->tp_getattro != NULL) {
12945 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12947 if (unlikely(descr == NULL)) {
12951 descrgetfunc func = NULL;
12952 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12953 func = Py_TYPE(descr)->tp_descr_get;
12955 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12956 PyObject *called_object = func(descr, source, (PyObject *)type);
12959 if (unlikely(called_object == NULL)) {
12963 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12964 Py_DECREF(called_object);
12969 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, descr, args);
12972 }
else if (type->tp_getattr != NULL) {
12973 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
12975 if (unlikely(called_object == NULL)) {
12979 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12980 Py_DECREF(called_object);
12983 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
12984 Nuitka_String_AsString_Unchecked(attr_name));
12989PyObject *CALL_METHOD_WITH_ARGS5(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
12990 CHECK_OBJECT(source);
12991 CHECK_OBJECT(attr_name);
12993 CHECK_OBJECTS(args, 5);
12995 PyTypeObject *type = Py_TYPE(source);
12997 if (hasTypeGenericGetAttr(type)) {
12999 if (unlikely(type->tp_dict == NULL)) {
13000 if (unlikely(PyType_Ready(type) < 0)) {
13005 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13006 descrgetfunc func = NULL;
13008 if (descr != NULL) {
13011 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13012 func = Py_TYPE(descr)->tp_descr_get;
13014 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13015 PyObject *called_object = func(descr, source, (PyObject *)type);
13018 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13019 Py_DECREF(called_object);
13025 Py_ssize_t dictoffset = type->tp_dictoffset;
13026 PyObject *dict = NULL;
13028 if (dictoffset != 0) {
13030 if (dictoffset < 0) {
13034 tsize = ((PyVarObject *)source)->ob_size;
13038 size = _PyObject_VAR_SIZE(type, tsize);
13040 dictoffset += (long)size;
13043 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13047 if (dict != NULL) {
13048 CHECK_OBJECT(dict);
13052 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13054 if (called_object != NULL) {
13058 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13059 Py_DECREF(called_object);
13066 if (func != NULL) {
13067 if (func == Nuitka_Function_Type.tp_descr_get) {
13068 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13074 PyObject *called_object = func(descr, source, (PyObject *)type);
13075 CHECK_OBJECT(called_object);
13079 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13080 Py_DECREF(called_object);
13085 if (descr != NULL) {
13086 CHECK_OBJECT(descr);
13088 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, descr, args);
13093#if PYTHON_VERSION < 0x300
13094 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13095 PyString_AS_STRING(attr_name));
13097 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
13101#if PYTHON_VERSION < 0x300
13102 else if (type == &PyInstance_Type) {
13103 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13107 assert(attr_name != const_str_plain___dict__);
13108 assert(attr_name != const_str_plain___class__);
13111 PyObject *called_object =
13112 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13116 if (called_object != NULL) {
13117 return CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13121 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13125 if (called_object != NULL) {
13126 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13128 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13129 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
13131 }
else if (descr_get != NULL) {
13132 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13134 if (unlikely(method == NULL)) {
13138 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, method, args);
13142 return CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13145 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13146 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
13147 PyString_AS_STRING(source_instance->in_class->cl_name),
13148 PyString_AS_STRING(attr_name));
13155 PyObject *args2[] = {source, attr_name};
13157 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13159 if (unlikely(called_object == NULL)) {
13163 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13164 Py_DECREF(called_object);
13169 else if (type->tp_getattro != NULL) {
13170 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13172 if (unlikely(descr == NULL)) {
13176 descrgetfunc func = NULL;
13177 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13178 func = Py_TYPE(descr)->tp_descr_get;
13180 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13181 PyObject *called_object = func(descr, source, (PyObject *)type);
13184 if (unlikely(called_object == NULL)) {
13188 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13189 Py_DECREF(called_object);
13194 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, descr, args);
13197 }
else if (type->tp_getattr != NULL) {
13198 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
13200 if (unlikely(called_object == NULL)) {
13204 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13205 Py_DECREF(called_object);
13208 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13209 Nuitka_String_AsString_Unchecked(attr_name));
13214PyObject *CALL_METHOD_WITH_ARGS6(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13215 CHECK_OBJECT(source);
13216 CHECK_OBJECT(attr_name);
13218 CHECK_OBJECTS(args, 6);
13220 PyTypeObject *type = Py_TYPE(source);
13222 if (hasTypeGenericGetAttr(type)) {
13224 if (unlikely(type->tp_dict == NULL)) {
13225 if (unlikely(PyType_Ready(type) < 0)) {
13230 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13231 descrgetfunc func = NULL;
13233 if (descr != NULL) {
13236 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13237 func = Py_TYPE(descr)->tp_descr_get;
13239 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13240 PyObject *called_object = func(descr, source, (PyObject *)type);
13243 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13244 Py_DECREF(called_object);
13250 Py_ssize_t dictoffset = type->tp_dictoffset;
13251 PyObject *dict = NULL;
13253 if (dictoffset != 0) {
13255 if (dictoffset < 0) {
13259 tsize = ((PyVarObject *)source)->ob_size;
13263 size = _PyObject_VAR_SIZE(type, tsize);
13265 dictoffset += (long)size;
13268 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13272 if (dict != NULL) {
13273 CHECK_OBJECT(dict);
13277 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13279 if (called_object != NULL) {
13283 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13284 Py_DECREF(called_object);
13291 if (func != NULL) {
13292 if (func == Nuitka_Function_Type.tp_descr_get) {
13293 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13299 PyObject *called_object = func(descr, source, (PyObject *)type);
13300 CHECK_OBJECT(called_object);
13304 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13305 Py_DECREF(called_object);
13310 if (descr != NULL) {
13311 CHECK_OBJECT(descr);
13313 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, descr, args);
13318#if PYTHON_VERSION < 0x300
13319 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13320 PyString_AS_STRING(attr_name));
13322 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
13326#if PYTHON_VERSION < 0x300
13327 else if (type == &PyInstance_Type) {
13328 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13332 assert(attr_name != const_str_plain___dict__);
13333 assert(attr_name != const_str_plain___class__);
13336 PyObject *called_object =
13337 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13341 if (called_object != NULL) {
13342 return CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13346 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13350 if (called_object != NULL) {
13351 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13353 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13354 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
13356 }
else if (descr_get != NULL) {
13357 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13359 if (unlikely(method == NULL)) {
13363 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, method, args);
13367 return CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13370 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13371 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
13372 PyString_AS_STRING(source_instance->in_class->cl_name),
13373 PyString_AS_STRING(attr_name));
13380 PyObject *args2[] = {source, attr_name};
13382 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13384 if (unlikely(called_object == NULL)) {
13388 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13389 Py_DECREF(called_object);
13394 else if (type->tp_getattro != NULL) {
13395 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13397 if (unlikely(descr == NULL)) {
13401 descrgetfunc func = NULL;
13402 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13403 func = Py_TYPE(descr)->tp_descr_get;
13405 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13406 PyObject *called_object = func(descr, source, (PyObject *)type);
13409 if (unlikely(called_object == NULL)) {
13413 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13414 Py_DECREF(called_object);
13419 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, descr, args);
13422 }
else if (type->tp_getattr != NULL) {
13423 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
13425 if (unlikely(called_object == NULL)) {
13429 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13430 Py_DECREF(called_object);
13433 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13434 Nuitka_String_AsString_Unchecked(attr_name));
13439PyObject *CALL_METHOD_WITH_ARGS7(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13440 CHECK_OBJECT(source);
13441 CHECK_OBJECT(attr_name);
13443 CHECK_OBJECTS(args, 7);
13445 PyTypeObject *type = Py_TYPE(source);
13447 if (hasTypeGenericGetAttr(type)) {
13449 if (unlikely(type->tp_dict == NULL)) {
13450 if (unlikely(PyType_Ready(type) < 0)) {
13455 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13456 descrgetfunc func = NULL;
13458 if (descr != NULL) {
13461 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13462 func = Py_TYPE(descr)->tp_descr_get;
13464 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13465 PyObject *called_object = func(descr, source, (PyObject *)type);
13468 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13469 Py_DECREF(called_object);
13475 Py_ssize_t dictoffset = type->tp_dictoffset;
13476 PyObject *dict = NULL;
13478 if (dictoffset != 0) {
13480 if (dictoffset < 0) {
13484 tsize = ((PyVarObject *)source)->ob_size;
13488 size = _PyObject_VAR_SIZE(type, tsize);
13490 dictoffset += (long)size;
13493 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13497 if (dict != NULL) {
13498 CHECK_OBJECT(dict);
13502 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13504 if (called_object != NULL) {
13508 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13509 Py_DECREF(called_object);
13516 if (func != NULL) {
13517 if (func == Nuitka_Function_Type.tp_descr_get) {
13518 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13524 PyObject *called_object = func(descr, source, (PyObject *)type);
13525 CHECK_OBJECT(called_object);
13529 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13530 Py_DECREF(called_object);
13535 if (descr != NULL) {
13536 CHECK_OBJECT(descr);
13538 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, descr, args);
13543#if PYTHON_VERSION < 0x300
13544 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13545 PyString_AS_STRING(attr_name));
13547 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
13551#if PYTHON_VERSION < 0x300
13552 else if (type == &PyInstance_Type) {
13553 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13557 assert(attr_name != const_str_plain___dict__);
13558 assert(attr_name != const_str_plain___class__);
13561 PyObject *called_object =
13562 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13566 if (called_object != NULL) {
13567 return CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13571 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13575 if (called_object != NULL) {
13576 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13578 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13579 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
13581 }
else if (descr_get != NULL) {
13582 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13584 if (unlikely(method == NULL)) {
13588 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, method, args);
13592 return CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13595 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13596 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
13597 PyString_AS_STRING(source_instance->in_class->cl_name),
13598 PyString_AS_STRING(attr_name));
13605 PyObject *args2[] = {source, attr_name};
13607 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13609 if (unlikely(called_object == NULL)) {
13613 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13614 Py_DECREF(called_object);
13619 else if (type->tp_getattro != NULL) {
13620 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13622 if (unlikely(descr == NULL)) {
13626 descrgetfunc func = NULL;
13627 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13628 func = Py_TYPE(descr)->tp_descr_get;
13630 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13631 PyObject *called_object = func(descr, source, (PyObject *)type);
13634 if (unlikely(called_object == NULL)) {
13638 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13639 Py_DECREF(called_object);
13644 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, descr, args);
13647 }
else if (type->tp_getattr != NULL) {
13648 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
13650 if (unlikely(called_object == NULL)) {
13654 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13655 Py_DECREF(called_object);
13658 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13659 Nuitka_String_AsString_Unchecked(attr_name));
13664PyObject *CALL_METHOD_WITH_ARGS8(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13665 CHECK_OBJECT(source);
13666 CHECK_OBJECT(attr_name);
13668 CHECK_OBJECTS(args, 8);
13670 PyTypeObject *type = Py_TYPE(source);
13672 if (hasTypeGenericGetAttr(type)) {
13674 if (unlikely(type->tp_dict == NULL)) {
13675 if (unlikely(PyType_Ready(type) < 0)) {
13680 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13681 descrgetfunc func = NULL;
13683 if (descr != NULL) {
13686 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13687 func = Py_TYPE(descr)->tp_descr_get;
13689 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13690 PyObject *called_object = func(descr, source, (PyObject *)type);
13693 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13694 Py_DECREF(called_object);
13700 Py_ssize_t dictoffset = type->tp_dictoffset;
13701 PyObject *dict = NULL;
13703 if (dictoffset != 0) {
13705 if (dictoffset < 0) {
13709 tsize = ((PyVarObject *)source)->ob_size;
13713 size = _PyObject_VAR_SIZE(type, tsize);
13715 dictoffset += (long)size;
13718 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13722 if (dict != NULL) {
13723 CHECK_OBJECT(dict);
13727 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13729 if (called_object != NULL) {
13733 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13734 Py_DECREF(called_object);
13741 if (func != NULL) {
13742 if (func == Nuitka_Function_Type.tp_descr_get) {
13743 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13749 PyObject *called_object = func(descr, source, (PyObject *)type);
13750 CHECK_OBJECT(called_object);
13754 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13755 Py_DECREF(called_object);
13760 if (descr != NULL) {
13761 CHECK_OBJECT(descr);
13763 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, descr, args);
13768#if PYTHON_VERSION < 0x300
13769 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13770 PyString_AS_STRING(attr_name));
13772 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
13776#if PYTHON_VERSION < 0x300
13777 else if (type == &PyInstance_Type) {
13778 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13782 assert(attr_name != const_str_plain___dict__);
13783 assert(attr_name != const_str_plain___class__);
13786 PyObject *called_object =
13787 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13791 if (called_object != NULL) {
13792 return CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13796 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13800 if (called_object != NULL) {
13801 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13803 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13804 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
13806 }
else if (descr_get != NULL) {
13807 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13809 if (unlikely(method == NULL)) {
13813 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, method, args);
13817 return CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13820 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13821 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
13822 PyString_AS_STRING(source_instance->in_class->cl_name),
13823 PyString_AS_STRING(attr_name));
13830 PyObject *args2[] = {source, attr_name};
13832 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13834 if (unlikely(called_object == NULL)) {
13838 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13839 Py_DECREF(called_object);
13844 else if (type->tp_getattro != NULL) {
13845 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13847 if (unlikely(descr == NULL)) {
13851 descrgetfunc func = NULL;
13852 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13853 func = Py_TYPE(descr)->tp_descr_get;
13855 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13856 PyObject *called_object = func(descr, source, (PyObject *)type);
13859 if (unlikely(called_object == NULL)) {
13863 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13864 Py_DECREF(called_object);
13869 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, descr, args);
13872 }
else if (type->tp_getattr != NULL) {
13873 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
13875 if (unlikely(called_object == NULL)) {
13879 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13880 Py_DECREF(called_object);
13883 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13884 Nuitka_String_AsString_Unchecked(attr_name));
13889PyObject *CALL_METHOD_WITH_ARGS9(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
13890 CHECK_OBJECT(source);
13891 CHECK_OBJECT(attr_name);
13893 CHECK_OBJECTS(args, 9);
13895 PyTypeObject *type = Py_TYPE(source);
13897 if (hasTypeGenericGetAttr(type)) {
13899 if (unlikely(type->tp_dict == NULL)) {
13900 if (unlikely(PyType_Ready(type) < 0)) {
13905 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13906 descrgetfunc func = NULL;
13908 if (descr != NULL) {
13911 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13912 func = Py_TYPE(descr)->tp_descr_get;
13914 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13915 PyObject *called_object = func(descr, source, (PyObject *)type);
13918 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
13919 Py_DECREF(called_object);
13925 Py_ssize_t dictoffset = type->tp_dictoffset;
13926 PyObject *dict = NULL;
13928 if (dictoffset != 0) {
13930 if (dictoffset < 0) {
13934 tsize = ((PyVarObject *)source)->ob_size;
13938 size = _PyObject_VAR_SIZE(type, tsize);
13940 dictoffset += (long)size;
13943 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
13947 if (dict != NULL) {
13948 CHECK_OBJECT(dict);
13952 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13954 if (called_object != NULL) {
13958 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
13959 Py_DECREF(called_object);
13966 if (func != NULL) {
13967 if (func == Nuitka_Function_Type.tp_descr_get) {
13968 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
13974 PyObject *called_object = func(descr, source, (PyObject *)type);
13975 CHECK_OBJECT(called_object);
13979 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
13980 Py_DECREF(called_object);
13985 if (descr != NULL) {
13986 CHECK_OBJECT(descr);
13988 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, descr, args);
13993#if PYTHON_VERSION < 0x300
13994 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
13995 PyString_AS_STRING(attr_name));
13997 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
14001#if PYTHON_VERSION < 0x300
14002 else if (type == &PyInstance_Type) {
14003 PyInstanceObject *source_instance = (PyInstanceObject *)source;
14007 assert(attr_name != const_str_plain___dict__);
14008 assert(attr_name != const_str_plain___class__);
14011 PyObject *called_object =
14012 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
14016 if (called_object != NULL) {
14017 return CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14021 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
14025 if (called_object != NULL) {
14026 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
14028 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
14029 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
14031 }
else if (descr_get != NULL) {
14032 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
14034 if (unlikely(method == NULL)) {
14038 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, method, args);
14042 return CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14045 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
14046 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
14047 PyString_AS_STRING(source_instance->in_class->cl_name),
14048 PyString_AS_STRING(attr_name));
14055 PyObject *args2[] = {source, attr_name};
14057 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
14059 if (unlikely(called_object == NULL)) {
14063 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14064 Py_DECREF(called_object);
14069 else if (type->tp_getattro != NULL) {
14070 PyObject *descr = (*type->tp_getattro)(source, attr_name);
14072 if (unlikely(descr == NULL)) {
14076 descrgetfunc func = NULL;
14077 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
14078 func = Py_TYPE(descr)->tp_descr_get;
14080 if (func != NULL && Nuitka_Descr_IsData(descr)) {
14081 PyObject *called_object = func(descr, source, (PyObject *)type);
14084 if (unlikely(called_object == NULL)) {
14088 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14089 Py_DECREF(called_object);
14094 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, descr, args);
14097 }
else if (type->tp_getattr != NULL) {
14098 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
14100 if (unlikely(called_object == NULL)) {
14104 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14105 Py_DECREF(called_object);
14108 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
14109 Nuitka_String_AsString_Unchecked(attr_name));
14114PyObject *CALL_METHOD_WITH_ARGS10(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *
const *args) {
14115 CHECK_OBJECT(source);
14116 CHECK_OBJECT(attr_name);
14118 CHECK_OBJECTS(args, 10);
14120 PyTypeObject *type = Py_TYPE(source);
14122 if (hasTypeGenericGetAttr(type)) {
14124 if (unlikely(type->tp_dict == NULL)) {
14125 if (unlikely(PyType_Ready(type) < 0)) {
14130 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
14131 descrgetfunc func = NULL;
14133 if (descr != NULL) {
14136 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
14137 func = Py_TYPE(descr)->tp_descr_get;
14139 if (func != NULL && Nuitka_Descr_IsData(descr)) {
14140 PyObject *called_object = func(descr, source, (PyObject *)type);
14143 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14144 Py_DECREF(called_object);
14150 Py_ssize_t dictoffset = type->tp_dictoffset;
14151 PyObject *dict = NULL;
14153 if (dictoffset != 0) {
14155 if (dictoffset < 0) {
14159 tsize = ((PyVarObject *)source)->ob_size;
14163 size = _PyObject_VAR_SIZE(type, tsize);
14165 dictoffset += (long)size;
14168 PyObject **dictptr = (PyObject **)((
char *)source + dictoffset);
14172 if (dict != NULL) {
14173 CHECK_OBJECT(dict);
14177 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
14179 if (called_object != NULL) {
14183 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14184 Py_DECREF(called_object);
14191 if (func != NULL) {
14192 if (func == Nuitka_Function_Type.tp_descr_get) {
14193 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)descr,
14199 PyObject *called_object = func(descr, source, (PyObject *)type);
14200 CHECK_OBJECT(called_object);
14204 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14205 Py_DECREF(called_object);
14210 if (descr != NULL) {
14211 CHECK_OBJECT(descr);
14213 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, descr, args);
14218#if PYTHON_VERSION < 0x300
14219 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
14220 PyString_AS_STRING(attr_name));
14222 PyErr_Format(PyExc_AttributeError,
"'%s' object has no attribute '%U'", type->tp_name, attr_name);
14226#if PYTHON_VERSION < 0x300
14227 else if (type == &PyInstance_Type) {
14228 PyInstanceObject *source_instance = (PyInstanceObject *)source;
14232 assert(attr_name != const_str_plain___dict__);
14233 assert(attr_name != const_str_plain___class__);
14236 PyObject *called_object =
14237 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
14241 if (called_object != NULL) {
14242 return CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14246 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
14250 if (called_object != NULL) {
14251 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
14253 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
14254 return Nuitka_CallMethodFunctionPosArgs(tstate, (
struct Nuitka_FunctionObject const *)called_object,
14256 }
else if (descr_get != NULL) {
14257 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
14259 if (unlikely(method == NULL)) {
14263 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, method, args);
14267 return CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14270 }
else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
14271 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"%s instance has no attribute '%s'",
14272 PyString_AS_STRING(source_instance->in_class->cl_name),
14273 PyString_AS_STRING(attr_name));
14280 PyObject *args2[] = {source, attr_name};
14282 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
14284 if (unlikely(called_object == NULL)) {
14288 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14289 Py_DECREF(called_object);
14294 else if (type->tp_getattro != NULL) {
14295 PyObject *descr = (*type->tp_getattro)(source, attr_name);
14297 if (unlikely(descr == NULL)) {
14301 descrgetfunc func = NULL;
14302 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
14303 func = Py_TYPE(descr)->tp_descr_get;
14305 if (func != NULL && Nuitka_Descr_IsData(descr)) {
14306 PyObject *called_object = func(descr, source, (PyObject *)type);
14309 if (unlikely(called_object == NULL)) {
14313 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14314 Py_DECREF(called_object);
14319 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, descr, args);
14322 }
else if (type->tp_getattr != NULL) {
14323 PyObject *called_object = (*type->tp_getattr)(source, (
char *)Nuitka_String_AsString_Unchecked(attr_name));
14325 if (unlikely(called_object == NULL)) {
14329 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14330 Py_DECREF(called_object);
14333 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError,
"'%s' object has no attribute '%s'", type->tp_name,
14334 Nuitka_String_AsString_Unchecked(attr_name));
14339#if defined(__clang__)
14340#pragma clang diagnostic pop
14341#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
14342#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
14343#pragma GCC diagnostic pop
Definition compiled_function.h:22
Definition compiled_method.h:16