Nuitka
The Python compiler
Loading...
Searching...
No Matches
HelpersCallingGenerated.c
1// Copyright 2025, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
2
3/* WARNING, this code is GENERATED. Modify the template CodeTemplateCallsPositional.c.j2 instead! */
4
5/* This file is included from another C file, help IDEs to still parse it on its own. */
6#ifdef __IDE_ONLY__
7#include "nuitka/prelude.h"
8#endif
9
10PyObject *CALL_FUNCTION_NO_ARGS(PyThreadState *tstate, PyObject *called) {
11 CHECK_OBJECT(called);
12
13 if (Nuitka_Function_Check(called)) {
14 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
15 return NULL;
16 }
17
18 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
19 PyObject *result;
20
21 if (function->m_args_simple && 0 == function->m_args_positional_count) {
22 result = function->m_c_code(tstate, function, NULL);
23 } else if (function->m_args_simple && 0 + function->m_defaults_given == function->m_args_positional_count) {
24 PyObject **python_pars = &PyTuple_GET_ITEM(function->m_defaults, 0);
25
26 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
27 Py_INCREF(python_pars[i]);
28 }
29
30 result = function->m_c_code(tstate, function, python_pars);
31 } else {
32 result = Nuitka_CallFunctionNoArgs(tstate, function);
33 }
34
35 Py_LeaveRecursiveCall();
36
37 CHECK_OBJECT_X(result);
38
39 return result;
40 } else if (Nuitka_Method_Check(called)) {
41 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
42
43 if (method->m_object == NULL) {
44 PyErr_Format(
45 PyExc_TypeError,
46 "unbound compiled_method %s%s must be called with %s instance as first argument (got nothing instead)",
47 GET_CALLABLE_NAME((PyObject *)method->m_function), GET_CALLABLE_DESC((PyObject *)method->m_function),
48 GET_CLASS_NAME(method->m_class));
49 return NULL;
50 } else {
51 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
52 return NULL;
53 }
54
55 struct Nuitka_FunctionObject *function = method->m_function;
56
57 PyObject *result;
58
59 if (function->m_args_simple && 0 + 1 == function->m_args_positional_count) {
60 PyObject *python_pars[0 + 1];
61
62 python_pars[0] = method->m_object;
63 Py_INCREF(method->m_object);
64
65 result = function->m_c_code(tstate, function, python_pars);
66 } else if (function->m_args_simple &&
67 0 + 1 + function->m_defaults_given == function->m_args_positional_count) {
68 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
69
70 python_pars[0] = method->m_object;
71 Py_INCREF(method->m_object);
72
73 memcpy(python_pars + 1 + 0, &PyTuple_GET_ITEM(function->m_defaults, 0),
74 function->m_defaults_given * sizeof(PyObject *));
75
76 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
77 Py_INCREF(python_pars[i]);
78 }
79
80 result = function->m_c_code(tstate, function, python_pars);
81 } else {
82 result = Nuitka_CallMethodFunctionNoArgs(tstate, function, method->m_object);
83 }
84
85 Py_LeaveRecursiveCall();
86
87 CHECK_OBJECT_X(result);
88
89 return result;
90 }
91#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
92 } else if (PyCFunction_CheckExact(called)) {
93#if PYTHON_VERSION >= 0x380
94#ifdef _NUITKA_FULL_COMPAT
95 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
96 return NULL;
97 }
98#endif
99
100 int flags = PyCFunction_GET_FLAGS(called);
101
102 PyObject *result;
103
104 if (!(flags & METH_VARARGS)) {
105 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
106
107 assert(func != NULL);
108 result = func(called, NULL, 0, NULL);
109
110 CHECK_OBJECT_X(result);
111 } else {
112 PyCFunction method = PyCFunction_GET_FUNCTION(called);
113 PyObject *self = PyCFunction_GET_SELF(called);
114
115 PyObject *pos_args = const_tuple_empty;
116
117 if (flags & METH_KEYWORDS) {
118 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
119 } else {
120 result = (*method)(self, pos_args);
121 }
122 }
123
124#ifdef _NUITKA_FULL_COMPAT
125 Py_LeaveRecursiveCall();
126#endif
127 CHECK_OBJECT_X(result);
128
129 return Nuitka_CheckFunctionResult(tstate, called, result);
130#else
131 // Try to be fast about wrapping the arguments.
132 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
133
134 if (likely(flags & METH_NOARGS)) {
135 // Recursion guard is not strictly necessary, as we already have
136 // one on our way to here.
137#ifdef _NUITKA_FULL_COMPAT
138 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
139 return NULL;
140 }
141#endif
142 PyCFunction method = PyCFunction_GET_FUNCTION(called);
143 PyObject *self = PyCFunction_GET_SELF(called);
144
145 PyObject *result = (*method)(self, NULL);
146
147#ifdef _NUITKA_FULL_COMPAT
148 Py_LeaveRecursiveCall();
149#endif
150 CHECK_OBJECT_X(result);
151
152 return Nuitka_CheckFunctionResult(tstate, called, result);
153 } else if (unlikely(flags & METH_O)) {
154 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (0 given)",
155 ((PyCFunctionObject *)called)->m_ml->ml_name);
156 return NULL;
157 } else if (flags & METH_VARARGS) {
158 // Recursion guard is not strictly necessary, as we already have
159 // one on our way to here.
160#ifdef _NUITKA_FULL_COMPAT
161 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
162 return NULL;
163 }
164#endif
165 PyCFunction method = PyCFunction_GET_FUNCTION(called);
166 PyObject *self = PyCFunction_GET_SELF(called);
167
168 PyObject *result;
169
170#if PYTHON_VERSION < 0x360
171 PyObject *pos_args = const_tuple_empty;
172 if (flags & METH_KEYWORDS) {
173 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
174 } else {
175 result = (*method)(self, pos_args);
176 }
177
178#else
179 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
180 PyObject *pos_args = const_tuple_empty;
181 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
182 } else if (flags == METH_FASTCALL) {
183#if PYTHON_VERSION < 0x370
184 result = (*(_PyCFunctionFast)method)(self, NULL, 0, NULL);
185#else
186 PyObject *pos_args = const_tuple_empty;
187 result = (*(_PyCFunctionFast)method)(self, &pos_args, 0);
188#endif
189 } else {
190 PyObject *pos_args = const_tuple_empty;
191 result = (*method)(self, pos_args);
192 }
193#endif
194
195#ifdef _NUITKA_FULL_COMPAT
196 Py_LeaveRecursiveCall();
197#endif
198
199 CHECK_OBJECT_X(result);
200
201 return Nuitka_CheckFunctionResult(tstate, called, result);
202 }
203#endif
204#endif
205#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
206 } else if (PyFunction_Check(called)) {
207#if PYTHON_VERSION < 0x3b0
208 PyObject *result = callPythonFunctionNoArgs(called);
209#else
210 PyObject *result = _PyFunction_Vectorcall(called, NULL, 0, NULL);
211#endif
212 CHECK_OBJECT_X(result);
213
214 return result;
215#endif
216#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
217 } else if (PyType_Check(called)) {
218 PyTypeObject *type = Py_TYPE(called);
219
220 if (type->tp_call == PyType_Type.tp_call) {
221 PyTypeObject *called_type = (PyTypeObject *)(called);
222
223 if (unlikely(called_type->tp_new == NULL)) {
224 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
225 return NULL;
226 }
227
228 PyObject *pos_args = const_tuple_empty;
229 PyObject *obj;
230
231 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
232 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
233 formatCannotInstantiateAbstractClass(tstate, called_type);
234 return NULL;
235 }
236
237 obj = called_type->tp_alloc(called_type, 0);
238 CHECK_OBJECT(obj);
239 } else {
240 obj = called_type->tp_new(called_type, pos_args, NULL);
241 }
242
243 if (likely(obj != NULL)) {
244 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
245 return obj;
246 }
247
248 // Work on produced type.
249 type = Py_TYPE(obj);
250
251 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
252 if (type->tp_init == default_tp_init_wrapper) {
253
254 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
255
256 // Not really allowed, since we wouldn't have the default wrapper set.
257 assert(init_method != NULL);
258
259 bool is_compiled_function = false;
260 bool init_method_needs_release = false;
261
262 if (likely(init_method != NULL)) {
263 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
264
265 if (func == Nuitka_Function_Type.tp_descr_get) {
266 is_compiled_function = true;
267 } else if (func != NULL) {
268 init_method = func(init_method, obj, (PyObject *)(type));
269 init_method_needs_release = true;
270 }
271 }
272
273 if (unlikely(init_method == NULL)) {
274 if (!HAS_ERROR_OCCURRED(tstate)) {
275 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
276 const_str_plain___init__);
277 }
278
279 return NULL;
280 }
281
282 PyObject *result;
283 if (is_compiled_function) {
284 result = Nuitka_CallMethodFunctionNoArgs(
285 tstate, (struct Nuitka_FunctionObject const *)init_method, obj);
286 } else {
287 result = CALL_FUNCTION_NO_ARGS(tstate, init_method);
288
289 if (init_method_needs_release) {
290 Py_DECREF(init_method);
291 }
292 }
293
294 if (unlikely(result == NULL)) {
295 Py_DECREF(obj);
296 return NULL;
297 }
298
299 Py_DECREF(result);
300
301 if (unlikely(result != Py_None)) {
302 Py_DECREF(obj);
303
304 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
305 return NULL;
306 }
307 } else {
308
309 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
310 Py_DECREF(obj);
311 return NULL;
312 }
313 }
314 }
315 }
316
317 CHECK_OBJECT_X(obj);
318
319 return obj;
320 }
321#endif
322#if PYTHON_VERSION < 0x300
323 } else if (PyClass_Check(called)) {
324 PyObject *obj = PyInstance_NewRaw(called, NULL);
325
326 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
327
328 if ((init_method == NULL)) {
329 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
330 Py_DECREF(obj);
331 return NULL;
332 }
333
334 return obj;
335 }
336
337 bool is_compiled_function = false;
338
339 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
340
341 if (descr_get == NULL) {
342 Py_INCREF(init_method);
343 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
344 is_compiled_function = true;
345 } else if (descr_get != NULL) {
346 PyObject *descr_method = descr_get(init_method, obj, called);
347
348 if (unlikely(descr_method == NULL)) {
349 return NULL;
350 }
351
352 init_method = descr_method;
353 }
354
355 PyObject *result;
356 if (is_compiled_function) {
357 result = Nuitka_CallMethodFunctionNoArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj);
358 } else {
359 result = CALL_FUNCTION_NO_ARGS(tstate, init_method);
360 Py_DECREF(init_method);
361 }
362 if (unlikely(result == NULL)) {
363 return NULL;
364 }
365
366 Py_DECREF(result);
367
368 if (unlikely(result != Py_None)) {
369 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
370 return NULL;
371 }
372
373 CHECK_OBJECT_X(obj);
374
375 return obj;
376#endif
377#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
378 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
379 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
380
381 if (likely(func != NULL)) {
382 PyObject *result = func(called, NULL, 0, NULL);
383
384 CHECK_OBJECT_X(result);
385
386 return Nuitka_CheckFunctionResult(tstate, called, result);
387 }
388#endif
389 }
390
391#if 0
392 PRINT_NEW_LINE();
393 PRINT_STRING("FALLBACK");
394 PRINT_ITEM(called);
395 PRINT_NEW_LINE();
396#endif
397
398 PyObject *result = CALL_FUNCTION(tstate, called, const_tuple_empty, NULL);
399
400 CHECK_OBJECT_X(result);
401
402 return result;
403}
404PyObject *CALL_FUNCTION_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *called, PyObject *arg) {
405 PyObject *const *args = &arg; // For easier code compatibility.
406 CHECK_OBJECT(called);
407 CHECK_OBJECTS(args, 1);
408
409 if (Nuitka_Function_Check(called)) {
410 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
411 return NULL;
412 }
413
414 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
415 PyObject *result;
416
417 if (function->m_args_simple && 1 == function->m_args_positional_count) {
418 Py_INCREF(args[0]);
419 result = function->m_c_code(tstate, function, (PyObject **)args);
420 } else if (function->m_args_simple && 1 + function->m_defaults_given == function->m_args_positional_count) {
421 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
422
423 memcpy(python_pars, args, 1 * sizeof(PyObject *));
424 memcpy(python_pars + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
425 function->m_defaults_given * sizeof(PyObject *));
426
427 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
428 Py_INCREF(python_pars[i]);
429 }
430
431 result = function->m_c_code(tstate, function, python_pars);
432 } else {
433 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 1);
434 }
435
436 Py_LeaveRecursiveCall();
437
438 CHECK_OBJECT_X(result);
439
440 return result;
441 } else if (Nuitka_Method_Check(called)) {
442 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
443
444 if (method->m_object == NULL) {
445 PyObject *self = args[0];
446
447 int res = PyObject_IsInstance(self, method->m_class);
448
449 if (unlikely(res < 0)) {
450 return NULL;
451 } else if (unlikely(res == 0)) {
452 PyErr_Format(PyExc_TypeError,
453 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
454 "instance instead)",
455 GET_CALLABLE_NAME((PyObject *)method->m_function),
456 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
457 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
458
459 return NULL;
460 }
461
462 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 1);
463
464 CHECK_OBJECT_X(result);
465
466 return result;
467 } else {
468 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
469 return NULL;
470 }
471
472 struct Nuitka_FunctionObject *function = method->m_function;
473
474 PyObject *result;
475
476 if (function->m_args_simple && 1 + 1 == function->m_args_positional_count) {
477 PyObject *python_pars[1 + 1];
478
479 python_pars[0] = method->m_object;
480 Py_INCREF(method->m_object);
481
482 python_pars[1] = args[0];
483 Py_INCREF(args[0]);
484 result = function->m_c_code(tstate, function, python_pars);
485 } else if (function->m_args_simple &&
486 1 + 1 + function->m_defaults_given == function->m_args_positional_count) {
487 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
488
489 python_pars[0] = method->m_object;
490 Py_INCREF(method->m_object);
491
492 memcpy(python_pars + 1, args, 1 * sizeof(PyObject *));
493 memcpy(python_pars + 1 + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
494 function->m_defaults_given * sizeof(PyObject *));
495
496 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
497 Py_INCREF(python_pars[i]);
498 }
499
500 result = function->m_c_code(tstate, function, python_pars);
501 } else {
502 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 1);
503 }
504
505 Py_LeaveRecursiveCall();
506
507 CHECK_OBJECT_X(result);
508
509 return result;
510 }
511#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
512 } else if (PyCFunction_CheckExact(called)) {
513#if PYTHON_VERSION >= 0x380
514#ifdef _NUITKA_FULL_COMPAT
515 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
516 return NULL;
517 }
518#endif
519
520 int flags = PyCFunction_GET_FLAGS(called);
521
522 PyObject *result;
523
524 if (!(flags & METH_VARARGS)) {
525 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
526
527 assert(func != NULL);
528 result = func(called, args, 1, NULL);
529
530 CHECK_OBJECT_X(result);
531 } else {
532 PyCFunction method = PyCFunction_GET_FUNCTION(called);
533 PyObject *self = PyCFunction_GET_SELF(called);
534
535 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
536
537 if (flags & METH_KEYWORDS) {
538 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
539 } else {
540 result = (*method)(self, pos_args);
541 }
542
543 Py_DECREF(pos_args);
544 }
545
546#ifdef _NUITKA_FULL_COMPAT
547 Py_LeaveRecursiveCall();
548#endif
549 CHECK_OBJECT_X(result);
550
551 return Nuitka_CheckFunctionResult(tstate, called, result);
552#else
553 // Try to be fast about wrapping the arguments.
554 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
555
556 if (unlikely(flags & METH_NOARGS)) {
557 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (1 given)",
558 ((PyCFunctionObject *)called)->m_ml->ml_name);
559 return NULL;
560 } else if ((flags & METH_O)) {
561 // Recursion guard is not strictly necessary, as we already have
562 // one on our way to here.
563#ifdef _NUITKA_FULL_COMPAT
564 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
565 return NULL;
566 }
567#endif
568 PyCFunction method = PyCFunction_GET_FUNCTION(called);
569 PyObject *self = PyCFunction_GET_SELF(called);
570
571 PyObject *result = (*method)(self, args[0]);
572
573#ifdef _NUITKA_FULL_COMPAT
574 Py_LeaveRecursiveCall();
575#endif
576
577 CHECK_OBJECT_X(result);
578
579 return Nuitka_CheckFunctionResult(tstate, called, result);
580 } else if (flags & METH_VARARGS) {
581 // Recursion guard is not strictly necessary, as we already have
582 // one on our way to here.
583#ifdef _NUITKA_FULL_COMPAT
584 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
585 return NULL;
586 }
587#endif
588 PyCFunction method = PyCFunction_GET_FUNCTION(called);
589 PyObject *self = PyCFunction_GET_SELF(called);
590
591 PyObject *result;
592
593#if PYTHON_VERSION < 0x360
594 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
595 if (flags & METH_KEYWORDS) {
596 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
597 } else {
598 result = (*method)(self, pos_args);
599 }
600
601 Py_DECREF(pos_args);
602#else
603 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
604 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
605 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
606 Py_DECREF(pos_args);
607 } else if (flags == METH_FASTCALL) {
608#if PYTHON_VERSION < 0x370
609 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 1, NULL);
610#else
611 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
612 result = (*(_PyCFunctionFast)method)(self, &pos_args, 1);
613 Py_DECREF(pos_args);
614#endif
615 } else {
616 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
617 result = (*method)(self, pos_args);
618 Py_DECREF(pos_args);
619 }
620#endif
621
622#ifdef _NUITKA_FULL_COMPAT
623 Py_LeaveRecursiveCall();
624#endif
625
626 CHECK_OBJECT_X(result);
627
628 return Nuitka_CheckFunctionResult(tstate, called, result);
629 }
630#endif
631#endif
632#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
633 } else if (PyFunction_Check(called)) {
634#if PYTHON_VERSION < 0x3b0
635 PyObject *result = callPythonFunction(called, args, 1);
636#else
637 PyObject *result = _PyFunction_Vectorcall(called, args, 1, NULL);
638#endif
639 CHECK_OBJECT_X(result);
640
641 return result;
642#endif
643#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
644 } else if (PyType_Check(called)) {
645 PyTypeObject *type = Py_TYPE(called);
646
647 if (type->tp_call == PyType_Type.tp_call) {
648 PyTypeObject *called_type = (PyTypeObject *)(called);
649
650 if (unlikely(called == (PyObject *)&PyType_Type)) {
651 PyObject *result = (PyObject *)Py_TYPE(args[0]);
652 Py_INCREF(result);
653 return result;
654 }
655
656 if (unlikely(called_type->tp_new == NULL)) {
657 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
658 return NULL;
659 }
660
661 PyObject *pos_args = NULL;
662 PyObject *obj;
663
664 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
665 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
666 formatCannotInstantiateAbstractClass(tstate, called_type);
667 return NULL;
668 }
669
670 obj = called_type->tp_alloc(called_type, 0);
671 CHECK_OBJECT(obj);
672 } else {
673 pos_args = MAKE_TUPLE(tstate, args, 1);
674 obj = called_type->tp_new(called_type, pos_args, NULL);
675 }
676
677 if (likely(obj != NULL)) {
678 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
679 Py_DECREF(pos_args);
680 return obj;
681 }
682
683 // Work on produced type.
684 type = Py_TYPE(obj);
685
686 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
687 if (type->tp_init == default_tp_init_wrapper) {
688 Py_XDECREF(pos_args);
689 pos_args = NULL;
690
691 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
692
693 // Not really allowed, since we wouldn't have the default wrapper set.
694 assert(init_method != NULL);
695
696 bool is_compiled_function = false;
697 bool init_method_needs_release = false;
698
699 if (likely(init_method != NULL)) {
700 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
701
702 if (func == Nuitka_Function_Type.tp_descr_get) {
703 is_compiled_function = true;
704 } else if (func != NULL) {
705 init_method = func(init_method, obj, (PyObject *)(type));
706 init_method_needs_release = true;
707 }
708 }
709
710 if (unlikely(init_method == NULL)) {
711 if (!HAS_ERROR_OCCURRED(tstate)) {
712 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
713 const_str_plain___init__);
714 }
715
716 return NULL;
717 }
718
719 PyObject *result;
720 if (is_compiled_function) {
721 result = Nuitka_CallMethodFunctionPosArgs(
722 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 1);
723 } else {
724 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
725
726 if (init_method_needs_release) {
727 Py_DECREF(init_method);
728 }
729 }
730
731 if (unlikely(result == NULL)) {
732 Py_DECREF(obj);
733 return NULL;
734 }
735
736 Py_DECREF(result);
737
738 if (unlikely(result != Py_None)) {
739 Py_DECREF(obj);
740
741 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
742 return NULL;
743 }
744 } else {
745 if (pos_args == NULL) {
746 pos_args = MAKE_TUPLE(tstate, args, 1);
747 }
748
749 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
750 Py_DECREF(obj);
751 Py_XDECREF(pos_args);
752 return NULL;
753 }
754 }
755 }
756 }
757
758 Py_XDECREF(pos_args);
759
760 CHECK_OBJECT_X(obj);
761
762 return obj;
763 }
764#endif
765#if PYTHON_VERSION < 0x300
766 } else if (PyClass_Check(called)) {
767 PyObject *obj = PyInstance_NewRaw(called, NULL);
768
769 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
770
771 if (unlikely(init_method == NULL)) {
772 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
773 Py_DECREF(obj);
774 return NULL;
775 }
776
777 Py_DECREF(obj);
778
779 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
780 return NULL;
781 }
782
783 bool is_compiled_function = false;
784
785 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
786
787 if (descr_get == NULL) {
788 Py_INCREF(init_method);
789 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
790 is_compiled_function = true;
791 } else if (descr_get != NULL) {
792 PyObject *descr_method = descr_get(init_method, obj, called);
793
794 if (unlikely(descr_method == NULL)) {
795 return NULL;
796 }
797
798 init_method = descr_method;
799 }
800
801 PyObject *result;
802 if (is_compiled_function) {
803 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
804 args, 1);
805 } else {
806 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
807 Py_DECREF(init_method);
808 }
809 if (unlikely(result == NULL)) {
810 return NULL;
811 }
812
813 Py_DECREF(result);
814
815 if (unlikely(result != Py_None)) {
816 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
817 return NULL;
818 }
819
820 CHECK_OBJECT_X(obj);
821
822 return obj;
823#endif
824#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
825 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
826 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
827
828 if (likely(func != NULL)) {
829 PyObject *result = func(called, args, 1, NULL);
830
831 CHECK_OBJECT_X(result);
832
833 return Nuitka_CheckFunctionResult(tstate, called, result);
834 }
835#endif
836 }
837
838#if 0
839 PRINT_NEW_LINE();
840 PRINT_STRING("FALLBACK");
841 PRINT_ITEM(called);
842 PRINT_NEW_LINE();
843#endif
844
845 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
846
847 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
848
849 Py_DECREF(pos_args);
850
851 CHECK_OBJECT_X(result);
852
853 return result;
854}
855PyObject *CALL_FUNCTION_WITH_POS_ARGS1(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
856 assert(PyTuple_CheckExact(pos_args));
857 assert(PyTuple_GET_SIZE(pos_args) == 1);
858 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
859 CHECK_OBJECT(called);
860 CHECK_OBJECTS(args, 1);
861
862 if (Nuitka_Function_Check(called)) {
863 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
864 return NULL;
865 }
866
867 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
868 PyObject *result;
869
870 if (function->m_args_simple && 1 == function->m_args_positional_count) {
871 Py_INCREF(args[0]);
872 result = function->m_c_code(tstate, function, (PyObject **)args);
873 } else if (function->m_args_simple && 1 + function->m_defaults_given == function->m_args_positional_count) {
874 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
875
876 memcpy(python_pars, args, 1 * sizeof(PyObject *));
877 memcpy(python_pars + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
878 function->m_defaults_given * sizeof(PyObject *));
879
880 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
881 Py_INCREF(python_pars[i]);
882 }
883
884 result = function->m_c_code(tstate, function, python_pars);
885 } else {
886 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 1);
887 }
888
889 Py_LeaveRecursiveCall();
890
891 CHECK_OBJECT_X(result);
892
893 return result;
894 } else if (Nuitka_Method_Check(called)) {
895 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
896
897 if (method->m_object == NULL) {
898 PyObject *self = args[0];
899
900 int res = PyObject_IsInstance(self, method->m_class);
901
902 if (unlikely(res < 0)) {
903 return NULL;
904 } else if (unlikely(res == 0)) {
905 PyErr_Format(PyExc_TypeError,
906 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
907 "instance instead)",
908 GET_CALLABLE_NAME((PyObject *)method->m_function),
909 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
910 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
911
912 return NULL;
913 }
914
915 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 1);
916
917 CHECK_OBJECT_X(result);
918
919 return result;
920 } else {
921 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
922 return NULL;
923 }
924
925 struct Nuitka_FunctionObject *function = method->m_function;
926
927 PyObject *result;
928
929 if (function->m_args_simple && 1 + 1 == function->m_args_positional_count) {
930 PyObject *python_pars[1 + 1];
931
932 python_pars[0] = method->m_object;
933 Py_INCREF(method->m_object);
934
935 python_pars[1] = args[0];
936 Py_INCREF(args[0]);
937 result = function->m_c_code(tstate, function, python_pars);
938 } else if (function->m_args_simple &&
939 1 + 1 + function->m_defaults_given == function->m_args_positional_count) {
940 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
941
942 python_pars[0] = method->m_object;
943 Py_INCREF(method->m_object);
944
945 memcpy(python_pars + 1, args, 1 * sizeof(PyObject *));
946 memcpy(python_pars + 1 + 1, &PyTuple_GET_ITEM(function->m_defaults, 0),
947 function->m_defaults_given * sizeof(PyObject *));
948
949 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
950 Py_INCREF(python_pars[i]);
951 }
952
953 result = function->m_c_code(tstate, function, python_pars);
954 } else {
955 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 1);
956 }
957
958 Py_LeaveRecursiveCall();
959
960 CHECK_OBJECT_X(result);
961
962 return result;
963 }
964#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
965 } else if (PyCFunction_CheckExact(called)) {
966#if PYTHON_VERSION >= 0x380
967#ifdef _NUITKA_FULL_COMPAT
968 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
969 return NULL;
970 }
971#endif
972
973 int flags = PyCFunction_GET_FLAGS(called);
974
975 PyObject *result;
976
977 if (!(flags & METH_VARARGS)) {
978 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
979
980 assert(func != NULL);
981 result = func(called, args, 1, NULL);
982
983 CHECK_OBJECT_X(result);
984 } else {
985 PyCFunction method = PyCFunction_GET_FUNCTION(called);
986 PyObject *self = PyCFunction_GET_SELF(called);
987
988 if (flags & METH_KEYWORDS) {
989 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
990 } else {
991 result = (*method)(self, pos_args);
992 }
993 }
994
995#ifdef _NUITKA_FULL_COMPAT
996 Py_LeaveRecursiveCall();
997#endif
998 CHECK_OBJECT_X(result);
999
1000 return Nuitka_CheckFunctionResult(tstate, called, result);
1001#else
1002 // Try to be fast about wrapping the arguments.
1003 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
1004
1005 if (unlikely(flags & METH_NOARGS)) {
1006 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (1 given)",
1007 ((PyCFunctionObject *)called)->m_ml->ml_name);
1008 return NULL;
1009 } else if ((flags & METH_O)) {
1010 // Recursion guard is not strictly necessary, as we already have
1011 // one on our way to here.
1012#ifdef _NUITKA_FULL_COMPAT
1013 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
1014 return NULL;
1015 }
1016#endif
1017 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1018 PyObject *self = PyCFunction_GET_SELF(called);
1019
1020 PyObject *result = (*method)(self, args[0]);
1021
1022#ifdef _NUITKA_FULL_COMPAT
1023 Py_LeaveRecursiveCall();
1024#endif
1025
1026 CHECK_OBJECT_X(result);
1027
1028 return Nuitka_CheckFunctionResult(tstate, called, result);
1029 } else if (flags & METH_VARARGS) {
1030 // Recursion guard is not strictly necessary, as we already have
1031 // one on our way to here.
1032#ifdef _NUITKA_FULL_COMPAT
1033 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
1034 return NULL;
1035 }
1036#endif
1037 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1038 PyObject *self = PyCFunction_GET_SELF(called);
1039
1040 PyObject *result;
1041
1042#if PYTHON_VERSION < 0x360
1043 if (flags & METH_KEYWORDS) {
1044 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1045 } else {
1046 result = (*method)(self, pos_args);
1047 }
1048
1049#else
1050 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
1051 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1052 } else if (flags == METH_FASTCALL) {
1053#if PYTHON_VERSION < 0x370
1054 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 1, NULL);
1055#else
1056 result = (*(_PyCFunctionFast)method)(self, &pos_args, 1);
1057#endif
1058 } else {
1059 result = (*method)(self, pos_args);
1060 }
1061#endif
1062
1063#ifdef _NUITKA_FULL_COMPAT
1064 Py_LeaveRecursiveCall();
1065#endif
1066
1067 CHECK_OBJECT_X(result);
1068
1069 return Nuitka_CheckFunctionResult(tstate, called, result);
1070 }
1071#endif
1072#endif
1073#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
1074 } else if (PyFunction_Check(called)) {
1075#if PYTHON_VERSION < 0x3b0
1076 PyObject *result = callPythonFunction(called, args, 1);
1077#else
1078 PyObject *result = _PyFunction_Vectorcall(called, args, 1, NULL);
1079#endif
1080 CHECK_OBJECT_X(result);
1081
1082 return result;
1083#endif
1084#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
1085 } else if (PyType_Check(called)) {
1086 PyTypeObject *type = Py_TYPE(called);
1087
1088 if (type->tp_call == PyType_Type.tp_call) {
1089 PyTypeObject *called_type = (PyTypeObject *)(called);
1090
1091 if (unlikely(called == (PyObject *)&PyType_Type)) {
1092 PyObject *result = (PyObject *)Py_TYPE(args[0]);
1093 Py_INCREF(result);
1094 return result;
1095 }
1096
1097 if (unlikely(called_type->tp_new == NULL)) {
1098 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
1099 return NULL;
1100 }
1101
1102 PyObject *obj;
1103
1104 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
1105 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
1106 formatCannotInstantiateAbstractClass(tstate, called_type);
1107 return NULL;
1108 }
1109
1110 obj = called_type->tp_alloc(called_type, 0);
1111 CHECK_OBJECT(obj);
1112 } else {
1113 obj = called_type->tp_new(called_type, pos_args, NULL);
1114 }
1115
1116 if (likely(obj != NULL)) {
1117 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
1118 return obj;
1119 }
1120
1121 // Work on produced type.
1122 type = Py_TYPE(obj);
1123
1124 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
1125 if (type->tp_init == default_tp_init_wrapper) {
1126
1127 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
1128
1129 // Not really allowed, since we wouldn't have the default wrapper set.
1130 assert(init_method != NULL);
1131
1132 bool is_compiled_function = false;
1133 bool init_method_needs_release = false;
1134
1135 if (likely(init_method != NULL)) {
1136 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
1137
1138 if (func == Nuitka_Function_Type.tp_descr_get) {
1139 is_compiled_function = true;
1140 } else if (func != NULL) {
1141 init_method = func(init_method, obj, (PyObject *)(type));
1142 init_method_needs_release = true;
1143 }
1144 }
1145
1146 if (unlikely(init_method == NULL)) {
1147 if (!HAS_ERROR_OCCURRED(tstate)) {
1148 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
1149 const_str_plain___init__);
1150 }
1151
1152 return NULL;
1153 }
1154
1155 PyObject *result;
1156 if (is_compiled_function) {
1157 result = Nuitka_CallMethodFunctionPosArgs(
1158 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 1);
1159 } else {
1160 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
1161
1162 if (init_method_needs_release) {
1163 Py_DECREF(init_method);
1164 }
1165 }
1166
1167 if (unlikely(result == NULL)) {
1168 Py_DECREF(obj);
1169 return NULL;
1170 }
1171
1172 Py_DECREF(result);
1173
1174 if (unlikely(result != Py_None)) {
1175 Py_DECREF(obj);
1176
1177 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
1178 return NULL;
1179 }
1180 } else {
1181
1182 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
1183 Py_DECREF(obj);
1184 return NULL;
1185 }
1186 }
1187 }
1188 }
1189
1190 CHECK_OBJECT_X(obj);
1191
1192 return obj;
1193 }
1194#endif
1195#if PYTHON_VERSION < 0x300
1196 } else if (PyClass_Check(called)) {
1197 PyObject *obj = PyInstance_NewRaw(called, NULL);
1198
1199 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
1200
1201 if (unlikely(init_method == NULL)) {
1202 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
1203 Py_DECREF(obj);
1204 return NULL;
1205 }
1206
1207 Py_DECREF(obj);
1208
1209 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
1210 return NULL;
1211 }
1212
1213 bool is_compiled_function = false;
1214
1215 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
1216
1217 if (descr_get == NULL) {
1218 Py_INCREF(init_method);
1219 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
1220 is_compiled_function = true;
1221 } else if (descr_get != NULL) {
1222 PyObject *descr_method = descr_get(init_method, obj, called);
1223
1224 if (unlikely(descr_method == NULL)) {
1225 return NULL;
1226 }
1227
1228 init_method = descr_method;
1229 }
1230
1231 PyObject *result;
1232 if (is_compiled_function) {
1233 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
1234 args, 1);
1235 } else {
1236 result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, init_method, args[0]);
1237 Py_DECREF(init_method);
1238 }
1239 if (unlikely(result == NULL)) {
1240 return NULL;
1241 }
1242
1243 Py_DECREF(result);
1244
1245 if (unlikely(result != Py_None)) {
1246 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
1247 return NULL;
1248 }
1249
1250 CHECK_OBJECT_X(obj);
1251
1252 return obj;
1253#endif
1254#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
1255 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
1256 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1257
1258 if (likely(func != NULL)) {
1259 PyObject *result = func(called, args, 1, NULL);
1260
1261 CHECK_OBJECT_X(result);
1262
1263 return Nuitka_CheckFunctionResult(tstate, called, result);
1264 }
1265#endif
1266 }
1267
1268#if 0
1269 PRINT_NEW_LINE();
1270 PRINT_STRING("FALLBACK");
1271 PRINT_ITEM(called);
1272 PRINT_NEW_LINE();
1273#endif
1274
1275 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
1276
1277 CHECK_OBJECT_X(result);
1278
1279 return result;
1280}
1281PyObject *CALL_FUNCTION_WITH_ARGS2(PyThreadState *tstate, PyObject *called, PyObject *const *args) {
1282 CHECK_OBJECT(called);
1283 CHECK_OBJECTS(args, 2);
1284
1285 if (Nuitka_Function_Check(called)) {
1286 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
1287 return NULL;
1288 }
1289
1290 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
1291 PyObject *result;
1292
1293 if (function->m_args_simple && 2 == function->m_args_positional_count) {
1294 for (Py_ssize_t i = 0; i < 2; i++) {
1295 Py_INCREF(args[i]);
1296 }
1297 result = function->m_c_code(tstate, function, (PyObject **)args);
1298 } else if (function->m_args_simple && 2 + function->m_defaults_given == function->m_args_positional_count) {
1299 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1300
1301 memcpy(python_pars, args, 2 * sizeof(PyObject *));
1302 memcpy(python_pars + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1303 function->m_defaults_given * sizeof(PyObject *));
1304
1305 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
1306 Py_INCREF(python_pars[i]);
1307 }
1308
1309 result = function->m_c_code(tstate, function, python_pars);
1310 } else {
1311 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 2);
1312 }
1313
1314 Py_LeaveRecursiveCall();
1315
1316 CHECK_OBJECT_X(result);
1317
1318 return result;
1319 } else if (Nuitka_Method_Check(called)) {
1320 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
1321
1322 if (method->m_object == NULL) {
1323 PyObject *self = args[0];
1324
1325 int res = PyObject_IsInstance(self, method->m_class);
1326
1327 if (unlikely(res < 0)) {
1328 return NULL;
1329 } else if (unlikely(res == 0)) {
1330 PyErr_Format(PyExc_TypeError,
1331 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
1332 "instance instead)",
1333 GET_CALLABLE_NAME((PyObject *)method->m_function),
1334 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
1335 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
1336
1337 return NULL;
1338 }
1339
1340 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 2);
1341
1342 CHECK_OBJECT_X(result);
1343
1344 return result;
1345 } else {
1346 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
1347 return NULL;
1348 }
1349
1350 struct Nuitka_FunctionObject *function = method->m_function;
1351
1352 PyObject *result;
1353
1354 if (function->m_args_simple && 2 + 1 == function->m_args_positional_count) {
1355 PyObject *python_pars[2 + 1];
1356
1357 python_pars[0] = method->m_object;
1358 Py_INCREF(method->m_object);
1359
1360 for (Py_ssize_t i = 0; i < 2; i++) {
1361 python_pars[i + 1] = args[i];
1362 Py_INCREF(args[i]);
1363 }
1364 result = function->m_c_code(tstate, function, python_pars);
1365 } else if (function->m_args_simple &&
1366 2 + 1 + function->m_defaults_given == function->m_args_positional_count) {
1367 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1368
1369 python_pars[0] = method->m_object;
1370 Py_INCREF(method->m_object);
1371
1372 memcpy(python_pars + 1, args, 2 * sizeof(PyObject *));
1373 memcpy(python_pars + 1 + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1374 function->m_defaults_given * sizeof(PyObject *));
1375
1376 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
1377 Py_INCREF(python_pars[i]);
1378 }
1379
1380 result = function->m_c_code(tstate, function, python_pars);
1381 } else {
1382 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 2);
1383 }
1384
1385 Py_LeaveRecursiveCall();
1386
1387 CHECK_OBJECT_X(result);
1388
1389 return result;
1390 }
1391#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
1392 } else if (PyCFunction_CheckExact(called)) {
1393#if PYTHON_VERSION >= 0x380
1394#ifdef _NUITKA_FULL_COMPAT
1395 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
1396 return NULL;
1397 }
1398#endif
1399
1400 int flags = PyCFunction_GET_FLAGS(called);
1401
1402 PyObject *result;
1403
1404 if (!(flags & METH_VARARGS)) {
1405 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1406
1407 assert(func != NULL);
1408 result = func(called, args, 2, NULL);
1409
1410 CHECK_OBJECT_X(result);
1411 } else {
1412 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1413 PyObject *self = PyCFunction_GET_SELF(called);
1414
1415 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1416
1417 if (flags & METH_KEYWORDS) {
1418 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
1419 } else {
1420 result = (*method)(self, pos_args);
1421 }
1422
1423 Py_DECREF(pos_args);
1424 }
1425
1426#ifdef _NUITKA_FULL_COMPAT
1427 Py_LeaveRecursiveCall();
1428#endif
1429 CHECK_OBJECT_X(result);
1430
1431 return Nuitka_CheckFunctionResult(tstate, called, result);
1432#else
1433 // Try to be fast about wrapping the arguments.
1434 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
1435
1436 if (unlikely(flags & METH_NOARGS)) {
1437 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (2 given)",
1438 ((PyCFunctionObject *)called)->m_ml->ml_name);
1439 return NULL;
1440 } else if (unlikely(flags & METH_O)) {
1441 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (2 given)",
1442 ((PyCFunctionObject *)called)->m_ml->ml_name);
1443 return NULL;
1444 } else if (flags & METH_VARARGS) {
1445 // Recursion guard is not strictly necessary, as we already have
1446 // one on our way to here.
1447#ifdef _NUITKA_FULL_COMPAT
1448 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
1449 return NULL;
1450 }
1451#endif
1452 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1453 PyObject *self = PyCFunction_GET_SELF(called);
1454
1455 PyObject *result;
1456
1457#if PYTHON_VERSION < 0x360
1458 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1459 if (flags & METH_KEYWORDS) {
1460 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1461 } else {
1462 result = (*method)(self, pos_args);
1463 }
1464
1465 Py_DECREF(pos_args);
1466#else
1467 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
1468 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1469 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1470 Py_DECREF(pos_args);
1471 } else if (flags == METH_FASTCALL) {
1472#if PYTHON_VERSION < 0x370
1473 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 2, NULL);
1474#else
1475 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1476 result = (*(_PyCFunctionFast)method)(self, &pos_args, 2);
1477 Py_DECREF(pos_args);
1478#endif
1479 } else {
1480 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1481 result = (*method)(self, pos_args);
1482 Py_DECREF(pos_args);
1483 }
1484#endif
1485
1486#ifdef _NUITKA_FULL_COMPAT
1487 Py_LeaveRecursiveCall();
1488#endif
1489
1490 CHECK_OBJECT_X(result);
1491
1492 return Nuitka_CheckFunctionResult(tstate, called, result);
1493 }
1494#endif
1495#endif
1496#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
1497 } else if (PyFunction_Check(called)) {
1498#if PYTHON_VERSION < 0x3b0
1499 PyObject *result = callPythonFunction(called, args, 2);
1500#else
1501 PyObject *result = _PyFunction_Vectorcall(called, args, 2, NULL);
1502#endif
1503 CHECK_OBJECT_X(result);
1504
1505 return result;
1506#endif
1507#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
1508 } else if (PyType_Check(called)) {
1509 PyTypeObject *type = Py_TYPE(called);
1510
1511 if (type->tp_call == PyType_Type.tp_call) {
1512 PyTypeObject *called_type = (PyTypeObject *)(called);
1513
1514 if (unlikely(called_type->tp_new == NULL)) {
1515 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
1516 return NULL;
1517 }
1518
1519 PyObject *pos_args = NULL;
1520 PyObject *obj;
1521
1522 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
1523 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
1524 formatCannotInstantiateAbstractClass(tstate, called_type);
1525 return NULL;
1526 }
1527
1528 obj = called_type->tp_alloc(called_type, 0);
1529 CHECK_OBJECT(obj);
1530 } else {
1531 pos_args = MAKE_TUPLE(tstate, args, 2);
1532 obj = called_type->tp_new(called_type, pos_args, NULL);
1533 }
1534
1535 if (likely(obj != NULL)) {
1536 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
1537 Py_DECREF(pos_args);
1538 return obj;
1539 }
1540
1541 // Work on produced type.
1542 type = Py_TYPE(obj);
1543
1544 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
1545 if (type->tp_init == default_tp_init_wrapper) {
1546 Py_XDECREF(pos_args);
1547 pos_args = NULL;
1548
1549 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
1550
1551 // Not really allowed, since we wouldn't have the default wrapper set.
1552 assert(init_method != NULL);
1553
1554 bool is_compiled_function = false;
1555 bool init_method_needs_release = false;
1556
1557 if (likely(init_method != NULL)) {
1558 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
1559
1560 if (func == Nuitka_Function_Type.tp_descr_get) {
1561 is_compiled_function = true;
1562 } else if (func != NULL) {
1563 init_method = func(init_method, obj, (PyObject *)(type));
1564 init_method_needs_release = true;
1565 }
1566 }
1567
1568 if (unlikely(init_method == NULL)) {
1569 if (!HAS_ERROR_OCCURRED(tstate)) {
1570 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
1571 const_str_plain___init__);
1572 }
1573
1574 return NULL;
1575 }
1576
1577 PyObject *result;
1578 if (is_compiled_function) {
1579 result = Nuitka_CallMethodFunctionPosArgs(
1580 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 2);
1581 } else {
1582 result = CALL_FUNCTION_WITH_ARGS2(tstate, init_method, args);
1583 if (init_method_needs_release) {
1584 Py_DECREF(init_method);
1585 }
1586 }
1587
1588 if (unlikely(result == NULL)) {
1589 Py_DECREF(obj);
1590 return NULL;
1591 }
1592
1593 Py_DECREF(result);
1594
1595 if (unlikely(result != Py_None)) {
1596 Py_DECREF(obj);
1597
1598 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
1599 return NULL;
1600 }
1601 } else {
1602 if (pos_args == NULL) {
1603 pos_args = MAKE_TUPLE(tstate, args, 2);
1604 }
1605
1606 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
1607 Py_DECREF(obj);
1608 Py_XDECREF(pos_args);
1609 return NULL;
1610 }
1611 }
1612 }
1613 }
1614
1615 Py_XDECREF(pos_args);
1616
1617 CHECK_OBJECT_X(obj);
1618
1619 return obj;
1620 }
1621#endif
1622#if PYTHON_VERSION < 0x300
1623 } else if (PyClass_Check(called)) {
1624 PyObject *obj = PyInstance_NewRaw(called, NULL);
1625
1626 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
1627
1628 if (unlikely(init_method == NULL)) {
1629 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
1630 Py_DECREF(obj);
1631 return NULL;
1632 }
1633
1634 Py_DECREF(obj);
1635
1636 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
1637 return NULL;
1638 }
1639
1640 bool is_compiled_function = false;
1641
1642 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
1643
1644 if (descr_get == NULL) {
1645 Py_INCREF(init_method);
1646 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
1647 is_compiled_function = true;
1648 } else if (descr_get != NULL) {
1649 PyObject *descr_method = descr_get(init_method, obj, called);
1650
1651 if (unlikely(descr_method == NULL)) {
1652 return NULL;
1653 }
1654
1655 init_method = descr_method;
1656 }
1657
1658 PyObject *result;
1659 if (is_compiled_function) {
1660 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
1661 args, 2);
1662 } else {
1663 result = CALL_FUNCTION_WITH_ARGS2(tstate, init_method, args);
1664 Py_DECREF(init_method);
1665 }
1666 if (unlikely(result == NULL)) {
1667 return NULL;
1668 }
1669
1670 Py_DECREF(result);
1671
1672 if (unlikely(result != Py_None)) {
1673 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
1674 return NULL;
1675 }
1676
1677 CHECK_OBJECT_X(obj);
1678
1679 return obj;
1680#endif
1681#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
1682 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
1683 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1684
1685 if (likely(func != NULL)) {
1686 PyObject *result = func(called, args, 2, NULL);
1687
1688 CHECK_OBJECT_X(result);
1689
1690 return Nuitka_CheckFunctionResult(tstate, called, result);
1691 }
1692#endif
1693 }
1694
1695#if 0
1696 PRINT_NEW_LINE();
1697 PRINT_STRING("FALLBACK");
1698 PRINT_ITEM(called);
1699 PRINT_NEW_LINE();
1700#endif
1701
1702 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
1703
1704 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
1705
1706 Py_DECREF(pos_args);
1707
1708 CHECK_OBJECT_X(result);
1709
1710 return result;
1711}
1712PyObject *CALL_FUNCTION_WITH_POS_ARGS2(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
1713 assert(PyTuple_CheckExact(pos_args));
1714 assert(PyTuple_GET_SIZE(pos_args) == 2);
1715 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
1716 CHECK_OBJECT(called);
1717 CHECK_OBJECTS(args, 2);
1718
1719 if (Nuitka_Function_Check(called)) {
1720 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
1721 return NULL;
1722 }
1723
1724 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
1725 PyObject *result;
1726
1727 if (function->m_args_simple && 2 == function->m_args_positional_count) {
1728 for (Py_ssize_t i = 0; i < 2; i++) {
1729 Py_INCREF(args[i]);
1730 }
1731 result = function->m_c_code(tstate, function, (PyObject **)args);
1732 } else if (function->m_args_simple && 2 + function->m_defaults_given == function->m_args_positional_count) {
1733 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1734
1735 memcpy(python_pars, args, 2 * sizeof(PyObject *));
1736 memcpy(python_pars + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1737 function->m_defaults_given * sizeof(PyObject *));
1738
1739 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
1740 Py_INCREF(python_pars[i]);
1741 }
1742
1743 result = function->m_c_code(tstate, function, python_pars);
1744 } else {
1745 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 2);
1746 }
1747
1748 Py_LeaveRecursiveCall();
1749
1750 CHECK_OBJECT_X(result);
1751
1752 return result;
1753 } else if (Nuitka_Method_Check(called)) {
1754 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
1755
1756 if (method->m_object == NULL) {
1757 PyObject *self = args[0];
1758
1759 int res = PyObject_IsInstance(self, method->m_class);
1760
1761 if (unlikely(res < 0)) {
1762 return NULL;
1763 } else if (unlikely(res == 0)) {
1764 PyErr_Format(PyExc_TypeError,
1765 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
1766 "instance instead)",
1767 GET_CALLABLE_NAME((PyObject *)method->m_function),
1768 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
1769 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
1770
1771 return NULL;
1772 }
1773
1774 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 2);
1775
1776 CHECK_OBJECT_X(result);
1777
1778 return result;
1779 } else {
1780 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
1781 return NULL;
1782 }
1783
1784 struct Nuitka_FunctionObject *function = method->m_function;
1785
1786 PyObject *result;
1787
1788 if (function->m_args_simple && 2 + 1 == function->m_args_positional_count) {
1789 PyObject *python_pars[2 + 1];
1790
1791 python_pars[0] = method->m_object;
1792 Py_INCREF(method->m_object);
1793
1794 for (Py_ssize_t i = 0; i < 2; i++) {
1795 python_pars[i + 1] = args[i];
1796 Py_INCREF(args[i]);
1797 }
1798 result = function->m_c_code(tstate, function, python_pars);
1799 } else if (function->m_args_simple &&
1800 2 + 1 + function->m_defaults_given == function->m_args_positional_count) {
1801 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
1802
1803 python_pars[0] = method->m_object;
1804 Py_INCREF(method->m_object);
1805
1806 memcpy(python_pars + 1, args, 2 * sizeof(PyObject *));
1807 memcpy(python_pars + 1 + 2, &PyTuple_GET_ITEM(function->m_defaults, 0),
1808 function->m_defaults_given * sizeof(PyObject *));
1809
1810 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
1811 Py_INCREF(python_pars[i]);
1812 }
1813
1814 result = function->m_c_code(tstate, function, python_pars);
1815 } else {
1816 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 2);
1817 }
1818
1819 Py_LeaveRecursiveCall();
1820
1821 CHECK_OBJECT_X(result);
1822
1823 return result;
1824 }
1825#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
1826 } else if (PyCFunction_CheckExact(called)) {
1827#if PYTHON_VERSION >= 0x380
1828#ifdef _NUITKA_FULL_COMPAT
1829 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
1830 return NULL;
1831 }
1832#endif
1833
1834 int flags = PyCFunction_GET_FLAGS(called);
1835
1836 PyObject *result;
1837
1838 if (!(flags & METH_VARARGS)) {
1839 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
1840
1841 assert(func != NULL);
1842 result = func(called, args, 2, NULL);
1843
1844 CHECK_OBJECT_X(result);
1845 } else {
1846 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1847 PyObject *self = PyCFunction_GET_SELF(called);
1848
1849 if (flags & METH_KEYWORDS) {
1850 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
1851 } else {
1852 result = (*method)(self, pos_args);
1853 }
1854 }
1855
1856#ifdef _NUITKA_FULL_COMPAT
1857 Py_LeaveRecursiveCall();
1858#endif
1859 CHECK_OBJECT_X(result);
1860
1861 return Nuitka_CheckFunctionResult(tstate, called, result);
1862#else
1863 // Try to be fast about wrapping the arguments.
1864 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
1865
1866 if (unlikely(flags & METH_NOARGS)) {
1867 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (2 given)",
1868 ((PyCFunctionObject *)called)->m_ml->ml_name);
1869 return NULL;
1870 } else if (unlikely(flags & METH_O)) {
1871 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (2 given)",
1872 ((PyCFunctionObject *)called)->m_ml->ml_name);
1873 return NULL;
1874 } else if (flags & METH_VARARGS) {
1875 // Recursion guard is not strictly necessary, as we already have
1876 // one on our way to here.
1877#ifdef _NUITKA_FULL_COMPAT
1878 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
1879 return NULL;
1880 }
1881#endif
1882 PyCFunction method = PyCFunction_GET_FUNCTION(called);
1883 PyObject *self = PyCFunction_GET_SELF(called);
1884
1885 PyObject *result;
1886
1887#if PYTHON_VERSION < 0x360
1888 if (flags & METH_KEYWORDS) {
1889 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1890 } else {
1891 result = (*method)(self, pos_args);
1892 }
1893
1894#else
1895 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
1896 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
1897 } else if (flags == METH_FASTCALL) {
1898#if PYTHON_VERSION < 0x370
1899 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 2, NULL);
1900#else
1901 result = (*(_PyCFunctionFast)method)(self, &pos_args, 2);
1902#endif
1903 } else {
1904 result = (*method)(self, pos_args);
1905 }
1906#endif
1907
1908#ifdef _NUITKA_FULL_COMPAT
1909 Py_LeaveRecursiveCall();
1910#endif
1911
1912 CHECK_OBJECT_X(result);
1913
1914 return Nuitka_CheckFunctionResult(tstate, called, result);
1915 }
1916#endif
1917#endif
1918#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
1919 } else if (PyFunction_Check(called)) {
1920#if PYTHON_VERSION < 0x3b0
1921 PyObject *result = callPythonFunction(called, args, 2);
1922#else
1923 PyObject *result = _PyFunction_Vectorcall(called, args, 2, NULL);
1924#endif
1925 CHECK_OBJECT_X(result);
1926
1927 return result;
1928#endif
1929#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
1930 } else if (PyType_Check(called)) {
1931 PyTypeObject *type = Py_TYPE(called);
1932
1933 if (type->tp_call == PyType_Type.tp_call) {
1934 PyTypeObject *called_type = (PyTypeObject *)(called);
1935
1936 if (unlikely(called_type->tp_new == NULL)) {
1937 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
1938 return NULL;
1939 }
1940
1941 PyObject *obj;
1942
1943 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
1944 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
1945 formatCannotInstantiateAbstractClass(tstate, called_type);
1946 return NULL;
1947 }
1948
1949 obj = called_type->tp_alloc(called_type, 0);
1950 CHECK_OBJECT(obj);
1951 } else {
1952 obj = called_type->tp_new(called_type, pos_args, NULL);
1953 }
1954
1955 if (likely(obj != NULL)) {
1956 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
1957 return obj;
1958 }
1959
1960 // Work on produced type.
1961 type = Py_TYPE(obj);
1962
1963 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
1964 if (type->tp_init == default_tp_init_wrapper) {
1965
1966 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
1967
1968 // Not really allowed, since we wouldn't have the default wrapper set.
1969 assert(init_method != NULL);
1970
1971 bool is_compiled_function = false;
1972 bool init_method_needs_release = false;
1973
1974 if (likely(init_method != NULL)) {
1975 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
1976
1977 if (func == Nuitka_Function_Type.tp_descr_get) {
1978 is_compiled_function = true;
1979 } else if (func != NULL) {
1980 init_method = func(init_method, obj, (PyObject *)(type));
1981 init_method_needs_release = true;
1982 }
1983 }
1984
1985 if (unlikely(init_method == NULL)) {
1986 if (!HAS_ERROR_OCCURRED(tstate)) {
1987 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
1988 const_str_plain___init__);
1989 }
1990
1991 return NULL;
1992 }
1993
1994 PyObject *result;
1995 if (is_compiled_function) {
1996 result = Nuitka_CallMethodFunctionPosArgs(
1997 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 2);
1998 } else {
1999 result = CALL_FUNCTION_WITH_POS_ARGS2(tstate, init_method, pos_args);
2000 if (init_method_needs_release) {
2001 Py_DECREF(init_method);
2002 }
2003 }
2004
2005 if (unlikely(result == NULL)) {
2006 Py_DECREF(obj);
2007 return NULL;
2008 }
2009
2010 Py_DECREF(result);
2011
2012 if (unlikely(result != Py_None)) {
2013 Py_DECREF(obj);
2014
2015 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
2016 return NULL;
2017 }
2018 } else {
2019
2020 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
2021 Py_DECREF(obj);
2022 return NULL;
2023 }
2024 }
2025 }
2026 }
2027
2028 CHECK_OBJECT_X(obj);
2029
2030 return obj;
2031 }
2032#endif
2033#if PYTHON_VERSION < 0x300
2034 } else if (PyClass_Check(called)) {
2035 PyObject *obj = PyInstance_NewRaw(called, NULL);
2036
2037 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
2038
2039 if (unlikely(init_method == NULL)) {
2040 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
2041 Py_DECREF(obj);
2042 return NULL;
2043 }
2044
2045 Py_DECREF(obj);
2046
2047 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
2048 return NULL;
2049 }
2050
2051 bool is_compiled_function = false;
2052
2053 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
2054
2055 if (descr_get == NULL) {
2056 Py_INCREF(init_method);
2057 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
2058 is_compiled_function = true;
2059 } else if (descr_get != NULL) {
2060 PyObject *descr_method = descr_get(init_method, obj, called);
2061
2062 if (unlikely(descr_method == NULL)) {
2063 return NULL;
2064 }
2065
2066 init_method = descr_method;
2067 }
2068
2069 PyObject *result;
2070 if (is_compiled_function) {
2071 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
2072 args, 2);
2073 } else {
2074 result = CALL_FUNCTION_WITH_POS_ARGS2(tstate, init_method, pos_args);
2075 Py_DECREF(init_method);
2076 }
2077 if (unlikely(result == NULL)) {
2078 return NULL;
2079 }
2080
2081 Py_DECREF(result);
2082
2083 if (unlikely(result != Py_None)) {
2084 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
2085 return NULL;
2086 }
2087
2088 CHECK_OBJECT_X(obj);
2089
2090 return obj;
2091#endif
2092#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
2093 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
2094 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2095
2096 if (likely(func != NULL)) {
2097 PyObject *result = func(called, args, 2, NULL);
2098
2099 CHECK_OBJECT_X(result);
2100
2101 return Nuitka_CheckFunctionResult(tstate, called, result);
2102 }
2103#endif
2104 }
2105
2106#if 0
2107 PRINT_NEW_LINE();
2108 PRINT_STRING("FALLBACK");
2109 PRINT_ITEM(called);
2110 PRINT_NEW_LINE();
2111#endif
2112
2113 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
2114
2115 CHECK_OBJECT_X(result);
2116
2117 return result;
2118}
2119PyObject *CALL_FUNCTION_WITH_ARGS3(PyThreadState *tstate, PyObject *called, PyObject *const *args) {
2120 CHECK_OBJECT(called);
2121 CHECK_OBJECTS(args, 3);
2122
2123 if (Nuitka_Function_Check(called)) {
2124 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
2125 return NULL;
2126 }
2127
2128 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
2129 PyObject *result;
2130
2131 if (function->m_args_simple && 3 == function->m_args_positional_count) {
2132 for (Py_ssize_t i = 0; i < 3; i++) {
2133 Py_INCREF(args[i]);
2134 }
2135 result = function->m_c_code(tstate, function, (PyObject **)args);
2136 } else if (function->m_args_simple && 3 + function->m_defaults_given == function->m_args_positional_count) {
2137 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2138
2139 memcpy(python_pars, args, 3 * sizeof(PyObject *));
2140 memcpy(python_pars + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2141 function->m_defaults_given * sizeof(PyObject *));
2142
2143 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
2144 Py_INCREF(python_pars[i]);
2145 }
2146
2147 result = function->m_c_code(tstate, function, python_pars);
2148 } else {
2149 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 3);
2150 }
2151
2152 Py_LeaveRecursiveCall();
2153
2154 CHECK_OBJECT_X(result);
2155
2156 return result;
2157 } else if (Nuitka_Method_Check(called)) {
2158 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
2159
2160 if (method->m_object == NULL) {
2161 PyObject *self = args[0];
2162
2163 int res = PyObject_IsInstance(self, method->m_class);
2164
2165 if (unlikely(res < 0)) {
2166 return NULL;
2167 } else if (unlikely(res == 0)) {
2168 PyErr_Format(PyExc_TypeError,
2169 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
2170 "instance instead)",
2171 GET_CALLABLE_NAME((PyObject *)method->m_function),
2172 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
2173 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
2174
2175 return NULL;
2176 }
2177
2178 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 3);
2179
2180 CHECK_OBJECT_X(result);
2181
2182 return result;
2183 } else {
2184 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
2185 return NULL;
2186 }
2187
2188 struct Nuitka_FunctionObject *function = method->m_function;
2189
2190 PyObject *result;
2191
2192 if (function->m_args_simple && 3 + 1 == function->m_args_positional_count) {
2193 PyObject *python_pars[3 + 1];
2194
2195 python_pars[0] = method->m_object;
2196 Py_INCREF(method->m_object);
2197
2198 for (Py_ssize_t i = 0; i < 3; i++) {
2199 python_pars[i + 1] = args[i];
2200 Py_INCREF(args[i]);
2201 }
2202 result = function->m_c_code(tstate, function, python_pars);
2203 } else if (function->m_args_simple &&
2204 3 + 1 + function->m_defaults_given == function->m_args_positional_count) {
2205 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2206
2207 python_pars[0] = method->m_object;
2208 Py_INCREF(method->m_object);
2209
2210 memcpy(python_pars + 1, args, 3 * sizeof(PyObject *));
2211 memcpy(python_pars + 1 + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2212 function->m_defaults_given * sizeof(PyObject *));
2213
2214 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
2215 Py_INCREF(python_pars[i]);
2216 }
2217
2218 result = function->m_c_code(tstate, function, python_pars);
2219 } else {
2220 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 3);
2221 }
2222
2223 Py_LeaveRecursiveCall();
2224
2225 CHECK_OBJECT_X(result);
2226
2227 return result;
2228 }
2229#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
2230 } else if (PyCFunction_CheckExact(called)) {
2231#if PYTHON_VERSION >= 0x380
2232#ifdef _NUITKA_FULL_COMPAT
2233 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
2234 return NULL;
2235 }
2236#endif
2237
2238 int flags = PyCFunction_GET_FLAGS(called);
2239
2240 PyObject *result;
2241
2242 if (!(flags & METH_VARARGS)) {
2243 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2244
2245 assert(func != NULL);
2246 result = func(called, args, 3, NULL);
2247
2248 CHECK_OBJECT_X(result);
2249 } else {
2250 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2251 PyObject *self = PyCFunction_GET_SELF(called);
2252
2253 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2254
2255 if (flags & METH_KEYWORDS) {
2256 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
2257 } else {
2258 result = (*method)(self, pos_args);
2259 }
2260
2261 Py_DECREF(pos_args);
2262 }
2263
2264#ifdef _NUITKA_FULL_COMPAT
2265 Py_LeaveRecursiveCall();
2266#endif
2267 CHECK_OBJECT_X(result);
2268
2269 return Nuitka_CheckFunctionResult(tstate, called, result);
2270#else
2271 // Try to be fast about wrapping the arguments.
2272 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
2273
2274 if (unlikely(flags & METH_NOARGS)) {
2275 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (3 given)",
2276 ((PyCFunctionObject *)called)->m_ml->ml_name);
2277 return NULL;
2278 } else if (unlikely(flags & METH_O)) {
2279 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (3 given)",
2280 ((PyCFunctionObject *)called)->m_ml->ml_name);
2281 return NULL;
2282 } else if (flags & METH_VARARGS) {
2283 // Recursion guard is not strictly necessary, as we already have
2284 // one on our way to here.
2285#ifdef _NUITKA_FULL_COMPAT
2286 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
2287 return NULL;
2288 }
2289#endif
2290 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2291 PyObject *self = PyCFunction_GET_SELF(called);
2292
2293 PyObject *result;
2294
2295#if PYTHON_VERSION < 0x360
2296 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2297 if (flags & METH_KEYWORDS) {
2298 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2299 } else {
2300 result = (*method)(self, pos_args);
2301 }
2302
2303 Py_DECREF(pos_args);
2304#else
2305 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
2306 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2307 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2308 Py_DECREF(pos_args);
2309 } else if (flags == METH_FASTCALL) {
2310#if PYTHON_VERSION < 0x370
2311 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 3, NULL);
2312#else
2313 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2314 result = (*(_PyCFunctionFast)method)(self, &pos_args, 3);
2315 Py_DECREF(pos_args);
2316#endif
2317 } else {
2318 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2319 result = (*method)(self, pos_args);
2320 Py_DECREF(pos_args);
2321 }
2322#endif
2323
2324#ifdef _NUITKA_FULL_COMPAT
2325 Py_LeaveRecursiveCall();
2326#endif
2327
2328 CHECK_OBJECT_X(result);
2329
2330 return Nuitka_CheckFunctionResult(tstate, called, result);
2331 }
2332#endif
2333#endif
2334#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
2335 } else if (PyFunction_Check(called)) {
2336#if PYTHON_VERSION < 0x3b0
2337 PyObject *result = callPythonFunction(called, args, 3);
2338#else
2339 PyObject *result = _PyFunction_Vectorcall(called, args, 3, NULL);
2340#endif
2341 CHECK_OBJECT_X(result);
2342
2343 return result;
2344#endif
2345#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
2346 } else if (PyType_Check(called)) {
2347 PyTypeObject *type = Py_TYPE(called);
2348
2349 if (type->tp_call == PyType_Type.tp_call) {
2350 PyTypeObject *called_type = (PyTypeObject *)(called);
2351
2352 if (unlikely(called_type->tp_new == NULL)) {
2353 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
2354 return NULL;
2355 }
2356
2357 PyObject *pos_args = NULL;
2358 PyObject *obj;
2359
2360 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
2361 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
2362 formatCannotInstantiateAbstractClass(tstate, called_type);
2363 return NULL;
2364 }
2365
2366 obj = called_type->tp_alloc(called_type, 0);
2367 CHECK_OBJECT(obj);
2368 } else {
2369 pos_args = MAKE_TUPLE(tstate, args, 3);
2370 obj = called_type->tp_new(called_type, pos_args, NULL);
2371 }
2372
2373 if (likely(obj != NULL)) {
2374 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
2375 Py_DECREF(pos_args);
2376 return obj;
2377 }
2378
2379 // Work on produced type.
2380 type = Py_TYPE(obj);
2381
2382 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
2383 if (type->tp_init == default_tp_init_wrapper) {
2384 Py_XDECREF(pos_args);
2385 pos_args = NULL;
2386
2387 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
2388
2389 // Not really allowed, since we wouldn't have the default wrapper set.
2390 assert(init_method != NULL);
2391
2392 bool is_compiled_function = false;
2393 bool init_method_needs_release = false;
2394
2395 if (likely(init_method != NULL)) {
2396 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
2397
2398 if (func == Nuitka_Function_Type.tp_descr_get) {
2399 is_compiled_function = true;
2400 } else if (func != NULL) {
2401 init_method = func(init_method, obj, (PyObject *)(type));
2402 init_method_needs_release = true;
2403 }
2404 }
2405
2406 if (unlikely(init_method == NULL)) {
2407 if (!HAS_ERROR_OCCURRED(tstate)) {
2408 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
2409 const_str_plain___init__);
2410 }
2411
2412 return NULL;
2413 }
2414
2415 PyObject *result;
2416 if (is_compiled_function) {
2417 result = Nuitka_CallMethodFunctionPosArgs(
2418 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 3);
2419 } else {
2420 result = CALL_FUNCTION_WITH_ARGS3(tstate, init_method, args);
2421 if (init_method_needs_release) {
2422 Py_DECREF(init_method);
2423 }
2424 }
2425
2426 if (unlikely(result == NULL)) {
2427 Py_DECREF(obj);
2428 return NULL;
2429 }
2430
2431 Py_DECREF(result);
2432
2433 if (unlikely(result != Py_None)) {
2434 Py_DECREF(obj);
2435
2436 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
2437 return NULL;
2438 }
2439 } else {
2440 if (pos_args == NULL) {
2441 pos_args = MAKE_TUPLE(tstate, args, 3);
2442 }
2443
2444 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
2445 Py_DECREF(obj);
2446 Py_XDECREF(pos_args);
2447 return NULL;
2448 }
2449 }
2450 }
2451 }
2452
2453 Py_XDECREF(pos_args);
2454
2455 CHECK_OBJECT_X(obj);
2456
2457 return obj;
2458 }
2459#endif
2460#if PYTHON_VERSION < 0x300
2461 } else if (PyClass_Check(called)) {
2462 PyObject *obj = PyInstance_NewRaw(called, NULL);
2463
2464 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
2465
2466 if (unlikely(init_method == NULL)) {
2467 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
2468 Py_DECREF(obj);
2469 return NULL;
2470 }
2471
2472 Py_DECREF(obj);
2473
2474 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
2475 return NULL;
2476 }
2477
2478 bool is_compiled_function = false;
2479
2480 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
2481
2482 if (descr_get == NULL) {
2483 Py_INCREF(init_method);
2484 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
2485 is_compiled_function = true;
2486 } else if (descr_get != NULL) {
2487 PyObject *descr_method = descr_get(init_method, obj, called);
2488
2489 if (unlikely(descr_method == NULL)) {
2490 return NULL;
2491 }
2492
2493 init_method = descr_method;
2494 }
2495
2496 PyObject *result;
2497 if (is_compiled_function) {
2498 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
2499 args, 3);
2500 } else {
2501 result = CALL_FUNCTION_WITH_ARGS3(tstate, init_method, args);
2502 Py_DECREF(init_method);
2503 }
2504 if (unlikely(result == NULL)) {
2505 return NULL;
2506 }
2507
2508 Py_DECREF(result);
2509
2510 if (unlikely(result != Py_None)) {
2511 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
2512 return NULL;
2513 }
2514
2515 CHECK_OBJECT_X(obj);
2516
2517 return obj;
2518#endif
2519#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
2520 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
2521 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2522
2523 if (likely(func != NULL)) {
2524 PyObject *result = func(called, args, 3, NULL);
2525
2526 CHECK_OBJECT_X(result);
2527
2528 return Nuitka_CheckFunctionResult(tstate, called, result);
2529 }
2530#endif
2531 }
2532
2533#if 0
2534 PRINT_NEW_LINE();
2535 PRINT_STRING("FALLBACK");
2536 PRINT_ITEM(called);
2537 PRINT_NEW_LINE();
2538#endif
2539
2540 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
2541
2542 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
2543
2544 Py_DECREF(pos_args);
2545
2546 CHECK_OBJECT_X(result);
2547
2548 return result;
2549}
2550PyObject *CALL_FUNCTION_WITH_POS_ARGS3(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
2551 assert(PyTuple_CheckExact(pos_args));
2552 assert(PyTuple_GET_SIZE(pos_args) == 3);
2553 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
2554 CHECK_OBJECT(called);
2555 CHECK_OBJECTS(args, 3);
2556
2557 if (Nuitka_Function_Check(called)) {
2558 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
2559 return NULL;
2560 }
2561
2562 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
2563 PyObject *result;
2564
2565 if (function->m_args_simple && 3 == function->m_args_positional_count) {
2566 for (Py_ssize_t i = 0; i < 3; i++) {
2567 Py_INCREF(args[i]);
2568 }
2569 result = function->m_c_code(tstate, function, (PyObject **)args);
2570 } else if (function->m_args_simple && 3 + function->m_defaults_given == function->m_args_positional_count) {
2571 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2572
2573 memcpy(python_pars, args, 3 * sizeof(PyObject *));
2574 memcpy(python_pars + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2575 function->m_defaults_given * sizeof(PyObject *));
2576
2577 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
2578 Py_INCREF(python_pars[i]);
2579 }
2580
2581 result = function->m_c_code(tstate, function, python_pars);
2582 } else {
2583 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 3);
2584 }
2585
2586 Py_LeaveRecursiveCall();
2587
2588 CHECK_OBJECT_X(result);
2589
2590 return result;
2591 } else if (Nuitka_Method_Check(called)) {
2592 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
2593
2594 if (method->m_object == NULL) {
2595 PyObject *self = args[0];
2596
2597 int res = PyObject_IsInstance(self, method->m_class);
2598
2599 if (unlikely(res < 0)) {
2600 return NULL;
2601 } else if (unlikely(res == 0)) {
2602 PyErr_Format(PyExc_TypeError,
2603 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
2604 "instance instead)",
2605 GET_CALLABLE_NAME((PyObject *)method->m_function),
2606 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
2607 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
2608
2609 return NULL;
2610 }
2611
2612 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 3);
2613
2614 CHECK_OBJECT_X(result);
2615
2616 return result;
2617 } else {
2618 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
2619 return NULL;
2620 }
2621
2622 struct Nuitka_FunctionObject *function = method->m_function;
2623
2624 PyObject *result;
2625
2626 if (function->m_args_simple && 3 + 1 == function->m_args_positional_count) {
2627 PyObject *python_pars[3 + 1];
2628
2629 python_pars[0] = method->m_object;
2630 Py_INCREF(method->m_object);
2631
2632 for (Py_ssize_t i = 0; i < 3; i++) {
2633 python_pars[i + 1] = args[i];
2634 Py_INCREF(args[i]);
2635 }
2636 result = function->m_c_code(tstate, function, python_pars);
2637 } else if (function->m_args_simple &&
2638 3 + 1 + function->m_defaults_given == function->m_args_positional_count) {
2639 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2640
2641 python_pars[0] = method->m_object;
2642 Py_INCREF(method->m_object);
2643
2644 memcpy(python_pars + 1, args, 3 * sizeof(PyObject *));
2645 memcpy(python_pars + 1 + 3, &PyTuple_GET_ITEM(function->m_defaults, 0),
2646 function->m_defaults_given * sizeof(PyObject *));
2647
2648 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
2649 Py_INCREF(python_pars[i]);
2650 }
2651
2652 result = function->m_c_code(tstate, function, python_pars);
2653 } else {
2654 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 3);
2655 }
2656
2657 Py_LeaveRecursiveCall();
2658
2659 CHECK_OBJECT_X(result);
2660
2661 return result;
2662 }
2663#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
2664 } else if (PyCFunction_CheckExact(called)) {
2665#if PYTHON_VERSION >= 0x380
2666#ifdef _NUITKA_FULL_COMPAT
2667 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
2668 return NULL;
2669 }
2670#endif
2671
2672 int flags = PyCFunction_GET_FLAGS(called);
2673
2674 PyObject *result;
2675
2676 if (!(flags & METH_VARARGS)) {
2677 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2678
2679 assert(func != NULL);
2680 result = func(called, args, 3, NULL);
2681
2682 CHECK_OBJECT_X(result);
2683 } else {
2684 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2685 PyObject *self = PyCFunction_GET_SELF(called);
2686
2687 if (flags & METH_KEYWORDS) {
2688 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
2689 } else {
2690 result = (*method)(self, pos_args);
2691 }
2692 }
2693
2694#ifdef _NUITKA_FULL_COMPAT
2695 Py_LeaveRecursiveCall();
2696#endif
2697 CHECK_OBJECT_X(result);
2698
2699 return Nuitka_CheckFunctionResult(tstate, called, result);
2700#else
2701 // Try to be fast about wrapping the arguments.
2702 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
2703
2704 if (unlikely(flags & METH_NOARGS)) {
2705 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (3 given)",
2706 ((PyCFunctionObject *)called)->m_ml->ml_name);
2707 return NULL;
2708 } else if (unlikely(flags & METH_O)) {
2709 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (3 given)",
2710 ((PyCFunctionObject *)called)->m_ml->ml_name);
2711 return NULL;
2712 } else if (flags & METH_VARARGS) {
2713 // Recursion guard is not strictly necessary, as we already have
2714 // one on our way to here.
2715#ifdef _NUITKA_FULL_COMPAT
2716 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
2717 return NULL;
2718 }
2719#endif
2720 PyCFunction method = PyCFunction_GET_FUNCTION(called);
2721 PyObject *self = PyCFunction_GET_SELF(called);
2722
2723 PyObject *result;
2724
2725#if PYTHON_VERSION < 0x360
2726 if (flags & METH_KEYWORDS) {
2727 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2728 } else {
2729 result = (*method)(self, pos_args);
2730 }
2731
2732#else
2733 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
2734 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
2735 } else if (flags == METH_FASTCALL) {
2736#if PYTHON_VERSION < 0x370
2737 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 3, NULL);
2738#else
2739 result = (*(_PyCFunctionFast)method)(self, &pos_args, 3);
2740#endif
2741 } else {
2742 result = (*method)(self, pos_args);
2743 }
2744#endif
2745
2746#ifdef _NUITKA_FULL_COMPAT
2747 Py_LeaveRecursiveCall();
2748#endif
2749
2750 CHECK_OBJECT_X(result);
2751
2752 return Nuitka_CheckFunctionResult(tstate, called, result);
2753 }
2754#endif
2755#endif
2756#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
2757 } else if (PyFunction_Check(called)) {
2758#if PYTHON_VERSION < 0x3b0
2759 PyObject *result = callPythonFunction(called, args, 3);
2760#else
2761 PyObject *result = _PyFunction_Vectorcall(called, args, 3, NULL);
2762#endif
2763 CHECK_OBJECT_X(result);
2764
2765 return result;
2766#endif
2767#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
2768 } else if (PyType_Check(called)) {
2769 PyTypeObject *type = Py_TYPE(called);
2770
2771 if (type->tp_call == PyType_Type.tp_call) {
2772 PyTypeObject *called_type = (PyTypeObject *)(called);
2773
2774 if (unlikely(called_type->tp_new == NULL)) {
2775 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
2776 return NULL;
2777 }
2778
2779 PyObject *obj;
2780
2781 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
2782 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
2783 formatCannotInstantiateAbstractClass(tstate, called_type);
2784 return NULL;
2785 }
2786
2787 obj = called_type->tp_alloc(called_type, 0);
2788 CHECK_OBJECT(obj);
2789 } else {
2790 obj = called_type->tp_new(called_type, pos_args, NULL);
2791 }
2792
2793 if (likely(obj != NULL)) {
2794 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
2795 return obj;
2796 }
2797
2798 // Work on produced type.
2799 type = Py_TYPE(obj);
2800
2801 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
2802 if (type->tp_init == default_tp_init_wrapper) {
2803
2804 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
2805
2806 // Not really allowed, since we wouldn't have the default wrapper set.
2807 assert(init_method != NULL);
2808
2809 bool is_compiled_function = false;
2810 bool init_method_needs_release = false;
2811
2812 if (likely(init_method != NULL)) {
2813 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
2814
2815 if (func == Nuitka_Function_Type.tp_descr_get) {
2816 is_compiled_function = true;
2817 } else if (func != NULL) {
2818 init_method = func(init_method, obj, (PyObject *)(type));
2819 init_method_needs_release = true;
2820 }
2821 }
2822
2823 if (unlikely(init_method == NULL)) {
2824 if (!HAS_ERROR_OCCURRED(tstate)) {
2825 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
2826 const_str_plain___init__);
2827 }
2828
2829 return NULL;
2830 }
2831
2832 PyObject *result;
2833 if (is_compiled_function) {
2834 result = Nuitka_CallMethodFunctionPosArgs(
2835 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 3);
2836 } else {
2837 result = CALL_FUNCTION_WITH_POS_ARGS3(tstate, init_method, pos_args);
2838 if (init_method_needs_release) {
2839 Py_DECREF(init_method);
2840 }
2841 }
2842
2843 if (unlikely(result == NULL)) {
2844 Py_DECREF(obj);
2845 return NULL;
2846 }
2847
2848 Py_DECREF(result);
2849
2850 if (unlikely(result != Py_None)) {
2851 Py_DECREF(obj);
2852
2853 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
2854 return NULL;
2855 }
2856 } else {
2857
2858 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
2859 Py_DECREF(obj);
2860 return NULL;
2861 }
2862 }
2863 }
2864 }
2865
2866 CHECK_OBJECT_X(obj);
2867
2868 return obj;
2869 }
2870#endif
2871#if PYTHON_VERSION < 0x300
2872 } else if (PyClass_Check(called)) {
2873 PyObject *obj = PyInstance_NewRaw(called, NULL);
2874
2875 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
2876
2877 if (unlikely(init_method == NULL)) {
2878 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
2879 Py_DECREF(obj);
2880 return NULL;
2881 }
2882
2883 Py_DECREF(obj);
2884
2885 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
2886 return NULL;
2887 }
2888
2889 bool is_compiled_function = false;
2890
2891 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
2892
2893 if (descr_get == NULL) {
2894 Py_INCREF(init_method);
2895 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
2896 is_compiled_function = true;
2897 } else if (descr_get != NULL) {
2898 PyObject *descr_method = descr_get(init_method, obj, called);
2899
2900 if (unlikely(descr_method == NULL)) {
2901 return NULL;
2902 }
2903
2904 init_method = descr_method;
2905 }
2906
2907 PyObject *result;
2908 if (is_compiled_function) {
2909 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
2910 args, 3);
2911 } else {
2912 result = CALL_FUNCTION_WITH_POS_ARGS3(tstate, init_method, pos_args);
2913 Py_DECREF(init_method);
2914 }
2915 if (unlikely(result == NULL)) {
2916 return NULL;
2917 }
2918
2919 Py_DECREF(result);
2920
2921 if (unlikely(result != Py_None)) {
2922 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
2923 return NULL;
2924 }
2925
2926 CHECK_OBJECT_X(obj);
2927
2928 return obj;
2929#endif
2930#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
2931 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
2932 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
2933
2934 if (likely(func != NULL)) {
2935 PyObject *result = func(called, args, 3, NULL);
2936
2937 CHECK_OBJECT_X(result);
2938
2939 return Nuitka_CheckFunctionResult(tstate, called, result);
2940 }
2941#endif
2942 }
2943
2944#if 0
2945 PRINT_NEW_LINE();
2946 PRINT_STRING("FALLBACK");
2947 PRINT_ITEM(called);
2948 PRINT_NEW_LINE();
2949#endif
2950
2951 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
2952
2953 CHECK_OBJECT_X(result);
2954
2955 return result;
2956}
2957PyObject *CALL_FUNCTION_WITH_ARGS4(PyThreadState *tstate, PyObject *called, PyObject *const *args) {
2958 CHECK_OBJECT(called);
2959 CHECK_OBJECTS(args, 4);
2960
2961 if (Nuitka_Function_Check(called)) {
2962 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
2963 return NULL;
2964 }
2965
2966 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
2967 PyObject *result;
2968
2969 if (function->m_args_simple && 4 == function->m_args_positional_count) {
2970 for (Py_ssize_t i = 0; i < 4; i++) {
2971 Py_INCREF(args[i]);
2972 }
2973 result = function->m_c_code(tstate, function, (PyObject **)args);
2974 } else if (function->m_args_simple && 4 + function->m_defaults_given == function->m_args_positional_count) {
2975 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
2976
2977 memcpy(python_pars, args, 4 * sizeof(PyObject *));
2978 memcpy(python_pars + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
2979 function->m_defaults_given * sizeof(PyObject *));
2980
2981 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
2982 Py_INCREF(python_pars[i]);
2983 }
2984
2985 result = function->m_c_code(tstate, function, python_pars);
2986 } else {
2987 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 4);
2988 }
2989
2990 Py_LeaveRecursiveCall();
2991
2992 CHECK_OBJECT_X(result);
2993
2994 return result;
2995 } else if (Nuitka_Method_Check(called)) {
2996 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
2997
2998 if (method->m_object == NULL) {
2999 PyObject *self = args[0];
3000
3001 int res = PyObject_IsInstance(self, method->m_class);
3002
3003 if (unlikely(res < 0)) {
3004 return NULL;
3005 } else if (unlikely(res == 0)) {
3006 PyErr_Format(PyExc_TypeError,
3007 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
3008 "instance instead)",
3009 GET_CALLABLE_NAME((PyObject *)method->m_function),
3010 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
3011 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
3012
3013 return NULL;
3014 }
3015
3016 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 4);
3017
3018 CHECK_OBJECT_X(result);
3019
3020 return result;
3021 } else {
3022 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
3023 return NULL;
3024 }
3025
3026 struct Nuitka_FunctionObject *function = method->m_function;
3027
3028 PyObject *result;
3029
3030 if (function->m_args_simple && 4 + 1 == function->m_args_positional_count) {
3031 PyObject *python_pars[4 + 1];
3032
3033 python_pars[0] = method->m_object;
3034 Py_INCREF(method->m_object);
3035
3036 for (Py_ssize_t i = 0; i < 4; i++) {
3037 python_pars[i + 1] = args[i];
3038 Py_INCREF(args[i]);
3039 }
3040 result = function->m_c_code(tstate, function, python_pars);
3041 } else if (function->m_args_simple &&
3042 4 + 1 + function->m_defaults_given == function->m_args_positional_count) {
3043 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3044
3045 python_pars[0] = method->m_object;
3046 Py_INCREF(method->m_object);
3047
3048 memcpy(python_pars + 1, args, 4 * sizeof(PyObject *));
3049 memcpy(python_pars + 1 + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
3050 function->m_defaults_given * sizeof(PyObject *));
3051
3052 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
3053 Py_INCREF(python_pars[i]);
3054 }
3055
3056 result = function->m_c_code(tstate, function, python_pars);
3057 } else {
3058 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 4);
3059 }
3060
3061 Py_LeaveRecursiveCall();
3062
3063 CHECK_OBJECT_X(result);
3064
3065 return result;
3066 }
3067#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
3068 } else if (PyCFunction_CheckExact(called)) {
3069#if PYTHON_VERSION >= 0x380
3070#ifdef _NUITKA_FULL_COMPAT
3071 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
3072 return NULL;
3073 }
3074#endif
3075
3076 int flags = PyCFunction_GET_FLAGS(called);
3077
3078 PyObject *result;
3079
3080 if (!(flags & METH_VARARGS)) {
3081 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3082
3083 assert(func != NULL);
3084 result = func(called, args, 4, NULL);
3085
3086 CHECK_OBJECT_X(result);
3087 } else {
3088 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3089 PyObject *self = PyCFunction_GET_SELF(called);
3090
3091 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3092
3093 if (flags & METH_KEYWORDS) {
3094 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
3095 } else {
3096 result = (*method)(self, pos_args);
3097 }
3098
3099 Py_DECREF(pos_args);
3100 }
3101
3102#ifdef _NUITKA_FULL_COMPAT
3103 Py_LeaveRecursiveCall();
3104#endif
3105 CHECK_OBJECT_X(result);
3106
3107 return Nuitka_CheckFunctionResult(tstate, called, result);
3108#else
3109 // Try to be fast about wrapping the arguments.
3110 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
3111
3112 if (unlikely(flags & METH_NOARGS)) {
3113 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (4 given)",
3114 ((PyCFunctionObject *)called)->m_ml->ml_name);
3115 return NULL;
3116 } else if (unlikely(flags & METH_O)) {
3117 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (4 given)",
3118 ((PyCFunctionObject *)called)->m_ml->ml_name);
3119 return NULL;
3120 } else if (flags & METH_VARARGS) {
3121 // Recursion guard is not strictly necessary, as we already have
3122 // one on our way to here.
3123#ifdef _NUITKA_FULL_COMPAT
3124 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
3125 return NULL;
3126 }
3127#endif
3128 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3129 PyObject *self = PyCFunction_GET_SELF(called);
3130
3131 PyObject *result;
3132
3133#if PYTHON_VERSION < 0x360
3134 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3135 if (flags & METH_KEYWORDS) {
3136 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3137 } else {
3138 result = (*method)(self, pos_args);
3139 }
3140
3141 Py_DECREF(pos_args);
3142#else
3143 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
3144 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3145 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3146 Py_DECREF(pos_args);
3147 } else if (flags == METH_FASTCALL) {
3148#if PYTHON_VERSION < 0x370
3149 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 4, NULL);
3150#else
3151 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3152 result = (*(_PyCFunctionFast)method)(self, &pos_args, 4);
3153 Py_DECREF(pos_args);
3154#endif
3155 } else {
3156 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3157 result = (*method)(self, pos_args);
3158 Py_DECREF(pos_args);
3159 }
3160#endif
3161
3162#ifdef _NUITKA_FULL_COMPAT
3163 Py_LeaveRecursiveCall();
3164#endif
3165
3166 CHECK_OBJECT_X(result);
3167
3168 return Nuitka_CheckFunctionResult(tstate, called, result);
3169 }
3170#endif
3171#endif
3172#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
3173 } else if (PyFunction_Check(called)) {
3174#if PYTHON_VERSION < 0x3b0
3175 PyObject *result = callPythonFunction(called, args, 4);
3176#else
3177 PyObject *result = _PyFunction_Vectorcall(called, args, 4, NULL);
3178#endif
3179 CHECK_OBJECT_X(result);
3180
3181 return result;
3182#endif
3183#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
3184 } else if (PyType_Check(called)) {
3185 PyTypeObject *type = Py_TYPE(called);
3186
3187 if (type->tp_call == PyType_Type.tp_call) {
3188 PyTypeObject *called_type = (PyTypeObject *)(called);
3189
3190 if (unlikely(called_type->tp_new == NULL)) {
3191 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
3192 return NULL;
3193 }
3194
3195 PyObject *pos_args = NULL;
3196 PyObject *obj;
3197
3198 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
3199 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
3200 formatCannotInstantiateAbstractClass(tstate, called_type);
3201 return NULL;
3202 }
3203
3204 obj = called_type->tp_alloc(called_type, 0);
3205 CHECK_OBJECT(obj);
3206 } else {
3207 pos_args = MAKE_TUPLE(tstate, args, 4);
3208 obj = called_type->tp_new(called_type, pos_args, NULL);
3209 }
3210
3211 if (likely(obj != NULL)) {
3212 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
3213 Py_DECREF(pos_args);
3214 return obj;
3215 }
3216
3217 // Work on produced type.
3218 type = Py_TYPE(obj);
3219
3220 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
3221 if (type->tp_init == default_tp_init_wrapper) {
3222 Py_XDECREF(pos_args);
3223 pos_args = NULL;
3224
3225 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
3226
3227 // Not really allowed, since we wouldn't have the default wrapper set.
3228 assert(init_method != NULL);
3229
3230 bool is_compiled_function = false;
3231 bool init_method_needs_release = false;
3232
3233 if (likely(init_method != NULL)) {
3234 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
3235
3236 if (func == Nuitka_Function_Type.tp_descr_get) {
3237 is_compiled_function = true;
3238 } else if (func != NULL) {
3239 init_method = func(init_method, obj, (PyObject *)(type));
3240 init_method_needs_release = true;
3241 }
3242 }
3243
3244 if (unlikely(init_method == NULL)) {
3245 if (!HAS_ERROR_OCCURRED(tstate)) {
3246 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
3247 const_str_plain___init__);
3248 }
3249
3250 return NULL;
3251 }
3252
3253 PyObject *result;
3254 if (is_compiled_function) {
3255 result = Nuitka_CallMethodFunctionPosArgs(
3256 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 4);
3257 } else {
3258 result = CALL_FUNCTION_WITH_ARGS4(tstate, init_method, args);
3259 if (init_method_needs_release) {
3260 Py_DECREF(init_method);
3261 }
3262 }
3263
3264 if (unlikely(result == NULL)) {
3265 Py_DECREF(obj);
3266 return NULL;
3267 }
3268
3269 Py_DECREF(result);
3270
3271 if (unlikely(result != Py_None)) {
3272 Py_DECREF(obj);
3273
3274 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
3275 return NULL;
3276 }
3277 } else {
3278 if (pos_args == NULL) {
3279 pos_args = MAKE_TUPLE(tstate, args, 4);
3280 }
3281
3282 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
3283 Py_DECREF(obj);
3284 Py_XDECREF(pos_args);
3285 return NULL;
3286 }
3287 }
3288 }
3289 }
3290
3291 Py_XDECREF(pos_args);
3292
3293 CHECK_OBJECT_X(obj);
3294
3295 return obj;
3296 }
3297#endif
3298#if PYTHON_VERSION < 0x300
3299 } else if (PyClass_Check(called)) {
3300 PyObject *obj = PyInstance_NewRaw(called, NULL);
3301
3302 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
3303
3304 if (unlikely(init_method == NULL)) {
3305 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
3306 Py_DECREF(obj);
3307 return NULL;
3308 }
3309
3310 Py_DECREF(obj);
3311
3312 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
3313 return NULL;
3314 }
3315
3316 bool is_compiled_function = false;
3317
3318 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
3319
3320 if (descr_get == NULL) {
3321 Py_INCREF(init_method);
3322 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
3323 is_compiled_function = true;
3324 } else if (descr_get != NULL) {
3325 PyObject *descr_method = descr_get(init_method, obj, called);
3326
3327 if (unlikely(descr_method == NULL)) {
3328 return NULL;
3329 }
3330
3331 init_method = descr_method;
3332 }
3333
3334 PyObject *result;
3335 if (is_compiled_function) {
3336 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
3337 args, 4);
3338 } else {
3339 result = CALL_FUNCTION_WITH_ARGS4(tstate, init_method, args);
3340 Py_DECREF(init_method);
3341 }
3342 if (unlikely(result == NULL)) {
3343 return NULL;
3344 }
3345
3346 Py_DECREF(result);
3347
3348 if (unlikely(result != Py_None)) {
3349 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
3350 return NULL;
3351 }
3352
3353 CHECK_OBJECT_X(obj);
3354
3355 return obj;
3356#endif
3357#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
3358 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
3359 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3360
3361 if (likely(func != NULL)) {
3362 PyObject *result = func(called, args, 4, NULL);
3363
3364 CHECK_OBJECT_X(result);
3365
3366 return Nuitka_CheckFunctionResult(tstate, called, result);
3367 }
3368#endif
3369 }
3370
3371#if 0
3372 PRINT_NEW_LINE();
3373 PRINT_STRING("FALLBACK");
3374 PRINT_ITEM(called);
3375 PRINT_NEW_LINE();
3376#endif
3377
3378 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
3379
3380 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
3381
3382 Py_DECREF(pos_args);
3383
3384 CHECK_OBJECT_X(result);
3385
3386 return result;
3387}
3388PyObject *CALL_FUNCTION_WITH_POS_ARGS4(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
3389 assert(PyTuple_CheckExact(pos_args));
3390 assert(PyTuple_GET_SIZE(pos_args) == 4);
3391 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
3392 CHECK_OBJECT(called);
3393 CHECK_OBJECTS(args, 4);
3394
3395 if (Nuitka_Function_Check(called)) {
3396 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
3397 return NULL;
3398 }
3399
3400 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
3401 PyObject *result;
3402
3403 if (function->m_args_simple && 4 == function->m_args_positional_count) {
3404 for (Py_ssize_t i = 0; i < 4; i++) {
3405 Py_INCREF(args[i]);
3406 }
3407 result = function->m_c_code(tstate, function, (PyObject **)args);
3408 } else if (function->m_args_simple && 4 + function->m_defaults_given == function->m_args_positional_count) {
3409 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3410
3411 memcpy(python_pars, args, 4 * sizeof(PyObject *));
3412 memcpy(python_pars + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
3413 function->m_defaults_given * sizeof(PyObject *));
3414
3415 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
3416 Py_INCREF(python_pars[i]);
3417 }
3418
3419 result = function->m_c_code(tstate, function, python_pars);
3420 } else {
3421 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 4);
3422 }
3423
3424 Py_LeaveRecursiveCall();
3425
3426 CHECK_OBJECT_X(result);
3427
3428 return result;
3429 } else if (Nuitka_Method_Check(called)) {
3430 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
3431
3432 if (method->m_object == NULL) {
3433 PyObject *self = args[0];
3434
3435 int res = PyObject_IsInstance(self, method->m_class);
3436
3437 if (unlikely(res < 0)) {
3438 return NULL;
3439 } else if (unlikely(res == 0)) {
3440 PyErr_Format(PyExc_TypeError,
3441 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
3442 "instance instead)",
3443 GET_CALLABLE_NAME((PyObject *)method->m_function),
3444 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
3445 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
3446
3447 return NULL;
3448 }
3449
3450 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 4);
3451
3452 CHECK_OBJECT_X(result);
3453
3454 return result;
3455 } else {
3456 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
3457 return NULL;
3458 }
3459
3460 struct Nuitka_FunctionObject *function = method->m_function;
3461
3462 PyObject *result;
3463
3464 if (function->m_args_simple && 4 + 1 == function->m_args_positional_count) {
3465 PyObject *python_pars[4 + 1];
3466
3467 python_pars[0] = method->m_object;
3468 Py_INCREF(method->m_object);
3469
3470 for (Py_ssize_t i = 0; i < 4; i++) {
3471 python_pars[i + 1] = args[i];
3472 Py_INCREF(args[i]);
3473 }
3474 result = function->m_c_code(tstate, function, python_pars);
3475 } else if (function->m_args_simple &&
3476 4 + 1 + function->m_defaults_given == function->m_args_positional_count) {
3477 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3478
3479 python_pars[0] = method->m_object;
3480 Py_INCREF(method->m_object);
3481
3482 memcpy(python_pars + 1, args, 4 * sizeof(PyObject *));
3483 memcpy(python_pars + 1 + 4, &PyTuple_GET_ITEM(function->m_defaults, 0),
3484 function->m_defaults_given * sizeof(PyObject *));
3485
3486 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
3487 Py_INCREF(python_pars[i]);
3488 }
3489
3490 result = function->m_c_code(tstate, function, python_pars);
3491 } else {
3492 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 4);
3493 }
3494
3495 Py_LeaveRecursiveCall();
3496
3497 CHECK_OBJECT_X(result);
3498
3499 return result;
3500 }
3501#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
3502 } else if (PyCFunction_CheckExact(called)) {
3503#if PYTHON_VERSION >= 0x380
3504#ifdef _NUITKA_FULL_COMPAT
3505 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
3506 return NULL;
3507 }
3508#endif
3509
3510 int flags = PyCFunction_GET_FLAGS(called);
3511
3512 PyObject *result;
3513
3514 if (!(flags & METH_VARARGS)) {
3515 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3516
3517 assert(func != NULL);
3518 result = func(called, args, 4, NULL);
3519
3520 CHECK_OBJECT_X(result);
3521 } else {
3522 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3523 PyObject *self = PyCFunction_GET_SELF(called);
3524
3525 if (flags & METH_KEYWORDS) {
3526 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
3527 } else {
3528 result = (*method)(self, pos_args);
3529 }
3530 }
3531
3532#ifdef _NUITKA_FULL_COMPAT
3533 Py_LeaveRecursiveCall();
3534#endif
3535 CHECK_OBJECT_X(result);
3536
3537 return Nuitka_CheckFunctionResult(tstate, called, result);
3538#else
3539 // Try to be fast about wrapping the arguments.
3540 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
3541
3542 if (unlikely(flags & METH_NOARGS)) {
3543 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (4 given)",
3544 ((PyCFunctionObject *)called)->m_ml->ml_name);
3545 return NULL;
3546 } else if (unlikely(flags & METH_O)) {
3547 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (4 given)",
3548 ((PyCFunctionObject *)called)->m_ml->ml_name);
3549 return NULL;
3550 } else if (flags & METH_VARARGS) {
3551 // Recursion guard is not strictly necessary, as we already have
3552 // one on our way to here.
3553#ifdef _NUITKA_FULL_COMPAT
3554 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
3555 return NULL;
3556 }
3557#endif
3558 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3559 PyObject *self = PyCFunction_GET_SELF(called);
3560
3561 PyObject *result;
3562
3563#if PYTHON_VERSION < 0x360
3564 if (flags & METH_KEYWORDS) {
3565 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3566 } else {
3567 result = (*method)(self, pos_args);
3568 }
3569
3570#else
3571 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
3572 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3573 } else if (flags == METH_FASTCALL) {
3574#if PYTHON_VERSION < 0x370
3575 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 4, NULL);
3576#else
3577 result = (*(_PyCFunctionFast)method)(self, &pos_args, 4);
3578#endif
3579 } else {
3580 result = (*method)(self, pos_args);
3581 }
3582#endif
3583
3584#ifdef _NUITKA_FULL_COMPAT
3585 Py_LeaveRecursiveCall();
3586#endif
3587
3588 CHECK_OBJECT_X(result);
3589
3590 return Nuitka_CheckFunctionResult(tstate, called, result);
3591 }
3592#endif
3593#endif
3594#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
3595 } else if (PyFunction_Check(called)) {
3596#if PYTHON_VERSION < 0x3b0
3597 PyObject *result = callPythonFunction(called, args, 4);
3598#else
3599 PyObject *result = _PyFunction_Vectorcall(called, args, 4, NULL);
3600#endif
3601 CHECK_OBJECT_X(result);
3602
3603 return result;
3604#endif
3605#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
3606 } else if (PyType_Check(called)) {
3607 PyTypeObject *type = Py_TYPE(called);
3608
3609 if (type->tp_call == PyType_Type.tp_call) {
3610 PyTypeObject *called_type = (PyTypeObject *)(called);
3611
3612 if (unlikely(called_type->tp_new == NULL)) {
3613 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
3614 return NULL;
3615 }
3616
3617 PyObject *obj;
3618
3619 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
3620 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
3621 formatCannotInstantiateAbstractClass(tstate, called_type);
3622 return NULL;
3623 }
3624
3625 obj = called_type->tp_alloc(called_type, 0);
3626 CHECK_OBJECT(obj);
3627 } else {
3628 obj = called_type->tp_new(called_type, pos_args, NULL);
3629 }
3630
3631 if (likely(obj != NULL)) {
3632 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
3633 return obj;
3634 }
3635
3636 // Work on produced type.
3637 type = Py_TYPE(obj);
3638
3639 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
3640 if (type->tp_init == default_tp_init_wrapper) {
3641
3642 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
3643
3644 // Not really allowed, since we wouldn't have the default wrapper set.
3645 assert(init_method != NULL);
3646
3647 bool is_compiled_function = false;
3648 bool init_method_needs_release = false;
3649
3650 if (likely(init_method != NULL)) {
3651 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
3652
3653 if (func == Nuitka_Function_Type.tp_descr_get) {
3654 is_compiled_function = true;
3655 } else if (func != NULL) {
3656 init_method = func(init_method, obj, (PyObject *)(type));
3657 init_method_needs_release = true;
3658 }
3659 }
3660
3661 if (unlikely(init_method == NULL)) {
3662 if (!HAS_ERROR_OCCURRED(tstate)) {
3663 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
3664 const_str_plain___init__);
3665 }
3666
3667 return NULL;
3668 }
3669
3670 PyObject *result;
3671 if (is_compiled_function) {
3672 result = Nuitka_CallMethodFunctionPosArgs(
3673 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 4);
3674 } else {
3675 result = CALL_FUNCTION_WITH_POS_ARGS4(tstate, init_method, pos_args);
3676 if (init_method_needs_release) {
3677 Py_DECREF(init_method);
3678 }
3679 }
3680
3681 if (unlikely(result == NULL)) {
3682 Py_DECREF(obj);
3683 return NULL;
3684 }
3685
3686 Py_DECREF(result);
3687
3688 if (unlikely(result != Py_None)) {
3689 Py_DECREF(obj);
3690
3691 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
3692 return NULL;
3693 }
3694 } else {
3695
3696 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
3697 Py_DECREF(obj);
3698 return NULL;
3699 }
3700 }
3701 }
3702 }
3703
3704 CHECK_OBJECT_X(obj);
3705
3706 return obj;
3707 }
3708#endif
3709#if PYTHON_VERSION < 0x300
3710 } else if (PyClass_Check(called)) {
3711 PyObject *obj = PyInstance_NewRaw(called, NULL);
3712
3713 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
3714
3715 if (unlikely(init_method == NULL)) {
3716 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
3717 Py_DECREF(obj);
3718 return NULL;
3719 }
3720
3721 Py_DECREF(obj);
3722
3723 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
3724 return NULL;
3725 }
3726
3727 bool is_compiled_function = false;
3728
3729 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
3730
3731 if (descr_get == NULL) {
3732 Py_INCREF(init_method);
3733 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
3734 is_compiled_function = true;
3735 } else if (descr_get != NULL) {
3736 PyObject *descr_method = descr_get(init_method, obj, called);
3737
3738 if (unlikely(descr_method == NULL)) {
3739 return NULL;
3740 }
3741
3742 init_method = descr_method;
3743 }
3744
3745 PyObject *result;
3746 if (is_compiled_function) {
3747 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
3748 args, 4);
3749 } else {
3750 result = CALL_FUNCTION_WITH_POS_ARGS4(tstate, init_method, pos_args);
3751 Py_DECREF(init_method);
3752 }
3753 if (unlikely(result == NULL)) {
3754 return NULL;
3755 }
3756
3757 Py_DECREF(result);
3758
3759 if (unlikely(result != Py_None)) {
3760 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
3761 return NULL;
3762 }
3763
3764 CHECK_OBJECT_X(obj);
3765
3766 return obj;
3767#endif
3768#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
3769 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
3770 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3771
3772 if (likely(func != NULL)) {
3773 PyObject *result = func(called, args, 4, NULL);
3774
3775 CHECK_OBJECT_X(result);
3776
3777 return Nuitka_CheckFunctionResult(tstate, called, result);
3778 }
3779#endif
3780 }
3781
3782#if 0
3783 PRINT_NEW_LINE();
3784 PRINT_STRING("FALLBACK");
3785 PRINT_ITEM(called);
3786 PRINT_NEW_LINE();
3787#endif
3788
3789 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
3790
3791 CHECK_OBJECT_X(result);
3792
3793 return result;
3794}
3795PyObject *CALL_FUNCTION_WITH_ARGS5(PyThreadState *tstate, PyObject *called, PyObject *const *args) {
3796 CHECK_OBJECT(called);
3797 CHECK_OBJECTS(args, 5);
3798
3799 if (Nuitka_Function_Check(called)) {
3800 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
3801 return NULL;
3802 }
3803
3804 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
3805 PyObject *result;
3806
3807 if (function->m_args_simple && 5 == function->m_args_positional_count) {
3808 for (Py_ssize_t i = 0; i < 5; i++) {
3809 Py_INCREF(args[i]);
3810 }
3811 result = function->m_c_code(tstate, function, (PyObject **)args);
3812 } else if (function->m_args_simple && 5 + function->m_defaults_given == function->m_args_positional_count) {
3813 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3814
3815 memcpy(python_pars, args, 5 * sizeof(PyObject *));
3816 memcpy(python_pars + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
3817 function->m_defaults_given * sizeof(PyObject *));
3818
3819 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
3820 Py_INCREF(python_pars[i]);
3821 }
3822
3823 result = function->m_c_code(tstate, function, python_pars);
3824 } else {
3825 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 5);
3826 }
3827
3828 Py_LeaveRecursiveCall();
3829
3830 CHECK_OBJECT_X(result);
3831
3832 return result;
3833 } else if (Nuitka_Method_Check(called)) {
3834 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
3835
3836 if (method->m_object == NULL) {
3837 PyObject *self = args[0];
3838
3839 int res = PyObject_IsInstance(self, method->m_class);
3840
3841 if (unlikely(res < 0)) {
3842 return NULL;
3843 } else if (unlikely(res == 0)) {
3844 PyErr_Format(PyExc_TypeError,
3845 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
3846 "instance instead)",
3847 GET_CALLABLE_NAME((PyObject *)method->m_function),
3848 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
3849 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
3850
3851 return NULL;
3852 }
3853
3854 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 5);
3855
3856 CHECK_OBJECT_X(result);
3857
3858 return result;
3859 } else {
3860 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
3861 return NULL;
3862 }
3863
3864 struct Nuitka_FunctionObject *function = method->m_function;
3865
3866 PyObject *result;
3867
3868 if (function->m_args_simple && 5 + 1 == function->m_args_positional_count) {
3869 PyObject *python_pars[5 + 1];
3870
3871 python_pars[0] = method->m_object;
3872 Py_INCREF(method->m_object);
3873
3874 for (Py_ssize_t i = 0; i < 5; i++) {
3875 python_pars[i + 1] = args[i];
3876 Py_INCREF(args[i]);
3877 }
3878 result = function->m_c_code(tstate, function, python_pars);
3879 } else if (function->m_args_simple &&
3880 5 + 1 + function->m_defaults_given == function->m_args_positional_count) {
3881 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
3882
3883 python_pars[0] = method->m_object;
3884 Py_INCREF(method->m_object);
3885
3886 memcpy(python_pars + 1, args, 5 * sizeof(PyObject *));
3887 memcpy(python_pars + 1 + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
3888 function->m_defaults_given * sizeof(PyObject *));
3889
3890 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
3891 Py_INCREF(python_pars[i]);
3892 }
3893
3894 result = function->m_c_code(tstate, function, python_pars);
3895 } else {
3896 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 5);
3897 }
3898
3899 Py_LeaveRecursiveCall();
3900
3901 CHECK_OBJECT_X(result);
3902
3903 return result;
3904 }
3905#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
3906 } else if (PyCFunction_CheckExact(called)) {
3907#if PYTHON_VERSION >= 0x380
3908#ifdef _NUITKA_FULL_COMPAT
3909 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
3910 return NULL;
3911 }
3912#endif
3913
3914 int flags = PyCFunction_GET_FLAGS(called);
3915
3916 PyObject *result;
3917
3918 if (!(flags & METH_VARARGS)) {
3919 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
3920
3921 assert(func != NULL);
3922 result = func(called, args, 5, NULL);
3923
3924 CHECK_OBJECT_X(result);
3925 } else {
3926 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3927 PyObject *self = PyCFunction_GET_SELF(called);
3928
3929 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3930
3931 if (flags & METH_KEYWORDS) {
3932 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
3933 } else {
3934 result = (*method)(self, pos_args);
3935 }
3936
3937 Py_DECREF(pos_args);
3938 }
3939
3940#ifdef _NUITKA_FULL_COMPAT
3941 Py_LeaveRecursiveCall();
3942#endif
3943 CHECK_OBJECT_X(result);
3944
3945 return Nuitka_CheckFunctionResult(tstate, called, result);
3946#else
3947 // Try to be fast about wrapping the arguments.
3948 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
3949
3950 if (unlikely(flags & METH_NOARGS)) {
3951 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (5 given)",
3952 ((PyCFunctionObject *)called)->m_ml->ml_name);
3953 return NULL;
3954 } else if (unlikely(flags & METH_O)) {
3955 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (5 given)",
3956 ((PyCFunctionObject *)called)->m_ml->ml_name);
3957 return NULL;
3958 } else if (flags & METH_VARARGS) {
3959 // Recursion guard is not strictly necessary, as we already have
3960 // one on our way to here.
3961#ifdef _NUITKA_FULL_COMPAT
3962 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
3963 return NULL;
3964 }
3965#endif
3966 PyCFunction method = PyCFunction_GET_FUNCTION(called);
3967 PyObject *self = PyCFunction_GET_SELF(called);
3968
3969 PyObject *result;
3970
3971#if PYTHON_VERSION < 0x360
3972 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3973 if (flags & METH_KEYWORDS) {
3974 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3975 } else {
3976 result = (*method)(self, pos_args);
3977 }
3978
3979 Py_DECREF(pos_args);
3980#else
3981 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
3982 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3983 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
3984 Py_DECREF(pos_args);
3985 } else if (flags == METH_FASTCALL) {
3986#if PYTHON_VERSION < 0x370
3987 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 5, NULL);
3988#else
3989 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3990 result = (*(_PyCFunctionFast)method)(self, &pos_args, 5);
3991 Py_DECREF(pos_args);
3992#endif
3993 } else {
3994 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
3995 result = (*method)(self, pos_args);
3996 Py_DECREF(pos_args);
3997 }
3998#endif
3999
4000#ifdef _NUITKA_FULL_COMPAT
4001 Py_LeaveRecursiveCall();
4002#endif
4003
4004 CHECK_OBJECT_X(result);
4005
4006 return Nuitka_CheckFunctionResult(tstate, called, result);
4007 }
4008#endif
4009#endif
4010#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
4011 } else if (PyFunction_Check(called)) {
4012#if PYTHON_VERSION < 0x3b0
4013 PyObject *result = callPythonFunction(called, args, 5);
4014#else
4015 PyObject *result = _PyFunction_Vectorcall(called, args, 5, NULL);
4016#endif
4017 CHECK_OBJECT_X(result);
4018
4019 return result;
4020#endif
4021#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
4022 } else if (PyType_Check(called)) {
4023 PyTypeObject *type = Py_TYPE(called);
4024
4025 if (type->tp_call == PyType_Type.tp_call) {
4026 PyTypeObject *called_type = (PyTypeObject *)(called);
4027
4028 if (unlikely(called_type->tp_new == NULL)) {
4029 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
4030 return NULL;
4031 }
4032
4033 PyObject *pos_args = NULL;
4034 PyObject *obj;
4035
4036 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
4037 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
4038 formatCannotInstantiateAbstractClass(tstate, called_type);
4039 return NULL;
4040 }
4041
4042 obj = called_type->tp_alloc(called_type, 0);
4043 CHECK_OBJECT(obj);
4044 } else {
4045 pos_args = MAKE_TUPLE(tstate, args, 5);
4046 obj = called_type->tp_new(called_type, pos_args, NULL);
4047 }
4048
4049 if (likely(obj != NULL)) {
4050 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
4051 Py_DECREF(pos_args);
4052 return obj;
4053 }
4054
4055 // Work on produced type.
4056 type = Py_TYPE(obj);
4057
4058 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
4059 if (type->tp_init == default_tp_init_wrapper) {
4060 Py_XDECREF(pos_args);
4061 pos_args = NULL;
4062
4063 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
4064
4065 // Not really allowed, since we wouldn't have the default wrapper set.
4066 assert(init_method != NULL);
4067
4068 bool is_compiled_function = false;
4069 bool init_method_needs_release = false;
4070
4071 if (likely(init_method != NULL)) {
4072 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
4073
4074 if (func == Nuitka_Function_Type.tp_descr_get) {
4075 is_compiled_function = true;
4076 } else if (func != NULL) {
4077 init_method = func(init_method, obj, (PyObject *)(type));
4078 init_method_needs_release = true;
4079 }
4080 }
4081
4082 if (unlikely(init_method == NULL)) {
4083 if (!HAS_ERROR_OCCURRED(tstate)) {
4084 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
4085 const_str_plain___init__);
4086 }
4087
4088 return NULL;
4089 }
4090
4091 PyObject *result;
4092 if (is_compiled_function) {
4093 result = Nuitka_CallMethodFunctionPosArgs(
4094 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 5);
4095 } else {
4096 result = CALL_FUNCTION_WITH_ARGS5(tstate, init_method, args);
4097 if (init_method_needs_release) {
4098 Py_DECREF(init_method);
4099 }
4100 }
4101
4102 if (unlikely(result == NULL)) {
4103 Py_DECREF(obj);
4104 return NULL;
4105 }
4106
4107 Py_DECREF(result);
4108
4109 if (unlikely(result != Py_None)) {
4110 Py_DECREF(obj);
4111
4112 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
4113 return NULL;
4114 }
4115 } else {
4116 if (pos_args == NULL) {
4117 pos_args = MAKE_TUPLE(tstate, args, 5);
4118 }
4119
4120 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
4121 Py_DECREF(obj);
4122 Py_XDECREF(pos_args);
4123 return NULL;
4124 }
4125 }
4126 }
4127 }
4128
4129 Py_XDECREF(pos_args);
4130
4131 CHECK_OBJECT_X(obj);
4132
4133 return obj;
4134 }
4135#endif
4136#if PYTHON_VERSION < 0x300
4137 } else if (PyClass_Check(called)) {
4138 PyObject *obj = PyInstance_NewRaw(called, NULL);
4139
4140 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
4141
4142 if (unlikely(init_method == NULL)) {
4143 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
4144 Py_DECREF(obj);
4145 return NULL;
4146 }
4147
4148 Py_DECREF(obj);
4149
4150 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
4151 return NULL;
4152 }
4153
4154 bool is_compiled_function = false;
4155
4156 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
4157
4158 if (descr_get == NULL) {
4159 Py_INCREF(init_method);
4160 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
4161 is_compiled_function = true;
4162 } else if (descr_get != NULL) {
4163 PyObject *descr_method = descr_get(init_method, obj, called);
4164
4165 if (unlikely(descr_method == NULL)) {
4166 return NULL;
4167 }
4168
4169 init_method = descr_method;
4170 }
4171
4172 PyObject *result;
4173 if (is_compiled_function) {
4174 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
4175 args, 5);
4176 } else {
4177 result = CALL_FUNCTION_WITH_ARGS5(tstate, init_method, args);
4178 Py_DECREF(init_method);
4179 }
4180 if (unlikely(result == NULL)) {
4181 return NULL;
4182 }
4183
4184 Py_DECREF(result);
4185
4186 if (unlikely(result != Py_None)) {
4187 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
4188 return NULL;
4189 }
4190
4191 CHECK_OBJECT_X(obj);
4192
4193 return obj;
4194#endif
4195#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
4196 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
4197 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4198
4199 if (likely(func != NULL)) {
4200 PyObject *result = func(called, args, 5, NULL);
4201
4202 CHECK_OBJECT_X(result);
4203
4204 return Nuitka_CheckFunctionResult(tstate, called, result);
4205 }
4206#endif
4207 }
4208
4209#if 0
4210 PRINT_NEW_LINE();
4211 PRINT_STRING("FALLBACK");
4212 PRINT_ITEM(called);
4213 PRINT_NEW_LINE();
4214#endif
4215
4216 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
4217
4218 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
4219
4220 Py_DECREF(pos_args);
4221
4222 CHECK_OBJECT_X(result);
4223
4224 return result;
4225}
4226PyObject *CALL_FUNCTION_WITH_POS_ARGS5(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
4227 assert(PyTuple_CheckExact(pos_args));
4228 assert(PyTuple_GET_SIZE(pos_args) == 5);
4229 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
4230 CHECK_OBJECT(called);
4231 CHECK_OBJECTS(args, 5);
4232
4233 if (Nuitka_Function_Check(called)) {
4234 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
4235 return NULL;
4236 }
4237
4238 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
4239 PyObject *result;
4240
4241 if (function->m_args_simple && 5 == function->m_args_positional_count) {
4242 for (Py_ssize_t i = 0; i < 5; i++) {
4243 Py_INCREF(args[i]);
4244 }
4245 result = function->m_c_code(tstate, function, (PyObject **)args);
4246 } else if (function->m_args_simple && 5 + function->m_defaults_given == function->m_args_positional_count) {
4247 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4248
4249 memcpy(python_pars, args, 5 * sizeof(PyObject *));
4250 memcpy(python_pars + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
4251 function->m_defaults_given * sizeof(PyObject *));
4252
4253 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
4254 Py_INCREF(python_pars[i]);
4255 }
4256
4257 result = function->m_c_code(tstate, function, python_pars);
4258 } else {
4259 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 5);
4260 }
4261
4262 Py_LeaveRecursiveCall();
4263
4264 CHECK_OBJECT_X(result);
4265
4266 return result;
4267 } else if (Nuitka_Method_Check(called)) {
4268 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
4269
4270 if (method->m_object == NULL) {
4271 PyObject *self = args[0];
4272
4273 int res = PyObject_IsInstance(self, method->m_class);
4274
4275 if (unlikely(res < 0)) {
4276 return NULL;
4277 } else if (unlikely(res == 0)) {
4278 PyErr_Format(PyExc_TypeError,
4279 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
4280 "instance instead)",
4281 GET_CALLABLE_NAME((PyObject *)method->m_function),
4282 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
4283 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
4284
4285 return NULL;
4286 }
4287
4288 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 5);
4289
4290 CHECK_OBJECT_X(result);
4291
4292 return result;
4293 } else {
4294 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
4295 return NULL;
4296 }
4297
4298 struct Nuitka_FunctionObject *function = method->m_function;
4299
4300 PyObject *result;
4301
4302 if (function->m_args_simple && 5 + 1 == function->m_args_positional_count) {
4303 PyObject *python_pars[5 + 1];
4304
4305 python_pars[0] = method->m_object;
4306 Py_INCREF(method->m_object);
4307
4308 for (Py_ssize_t i = 0; i < 5; i++) {
4309 python_pars[i + 1] = args[i];
4310 Py_INCREF(args[i]);
4311 }
4312 result = function->m_c_code(tstate, function, python_pars);
4313 } else if (function->m_args_simple &&
4314 5 + 1 + function->m_defaults_given == function->m_args_positional_count) {
4315 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4316
4317 python_pars[0] = method->m_object;
4318 Py_INCREF(method->m_object);
4319
4320 memcpy(python_pars + 1, args, 5 * sizeof(PyObject *));
4321 memcpy(python_pars + 1 + 5, &PyTuple_GET_ITEM(function->m_defaults, 0),
4322 function->m_defaults_given * sizeof(PyObject *));
4323
4324 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
4325 Py_INCREF(python_pars[i]);
4326 }
4327
4328 result = function->m_c_code(tstate, function, python_pars);
4329 } else {
4330 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 5);
4331 }
4332
4333 Py_LeaveRecursiveCall();
4334
4335 CHECK_OBJECT_X(result);
4336
4337 return result;
4338 }
4339#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
4340 } else if (PyCFunction_CheckExact(called)) {
4341#if PYTHON_VERSION >= 0x380
4342#ifdef _NUITKA_FULL_COMPAT
4343 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
4344 return NULL;
4345 }
4346#endif
4347
4348 int flags = PyCFunction_GET_FLAGS(called);
4349
4350 PyObject *result;
4351
4352 if (!(flags & METH_VARARGS)) {
4353 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4354
4355 assert(func != NULL);
4356 result = func(called, args, 5, NULL);
4357
4358 CHECK_OBJECT_X(result);
4359 } else {
4360 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4361 PyObject *self = PyCFunction_GET_SELF(called);
4362
4363 if (flags & METH_KEYWORDS) {
4364 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
4365 } else {
4366 result = (*method)(self, pos_args);
4367 }
4368 }
4369
4370#ifdef _NUITKA_FULL_COMPAT
4371 Py_LeaveRecursiveCall();
4372#endif
4373 CHECK_OBJECT_X(result);
4374
4375 return Nuitka_CheckFunctionResult(tstate, called, result);
4376#else
4377 // Try to be fast about wrapping the arguments.
4378 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
4379
4380 if (unlikely(flags & METH_NOARGS)) {
4381 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (5 given)",
4382 ((PyCFunctionObject *)called)->m_ml->ml_name);
4383 return NULL;
4384 } else if (unlikely(flags & METH_O)) {
4385 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (5 given)",
4386 ((PyCFunctionObject *)called)->m_ml->ml_name);
4387 return NULL;
4388 } else if (flags & METH_VARARGS) {
4389 // Recursion guard is not strictly necessary, as we already have
4390 // one on our way to here.
4391#ifdef _NUITKA_FULL_COMPAT
4392 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
4393 return NULL;
4394 }
4395#endif
4396 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4397 PyObject *self = PyCFunction_GET_SELF(called);
4398
4399 PyObject *result;
4400
4401#if PYTHON_VERSION < 0x360
4402 if (flags & METH_KEYWORDS) {
4403 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4404 } else {
4405 result = (*method)(self, pos_args);
4406 }
4407
4408#else
4409 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
4410 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4411 } else if (flags == METH_FASTCALL) {
4412#if PYTHON_VERSION < 0x370
4413 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 5, NULL);
4414#else
4415 result = (*(_PyCFunctionFast)method)(self, &pos_args, 5);
4416#endif
4417 } else {
4418 result = (*method)(self, pos_args);
4419 }
4420#endif
4421
4422#ifdef _NUITKA_FULL_COMPAT
4423 Py_LeaveRecursiveCall();
4424#endif
4425
4426 CHECK_OBJECT_X(result);
4427
4428 return Nuitka_CheckFunctionResult(tstate, called, result);
4429 }
4430#endif
4431#endif
4432#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
4433 } else if (PyFunction_Check(called)) {
4434#if PYTHON_VERSION < 0x3b0
4435 PyObject *result = callPythonFunction(called, args, 5);
4436#else
4437 PyObject *result = _PyFunction_Vectorcall(called, args, 5, NULL);
4438#endif
4439 CHECK_OBJECT_X(result);
4440
4441 return result;
4442#endif
4443#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
4444 } else if (PyType_Check(called)) {
4445 PyTypeObject *type = Py_TYPE(called);
4446
4447 if (type->tp_call == PyType_Type.tp_call) {
4448 PyTypeObject *called_type = (PyTypeObject *)(called);
4449
4450 if (unlikely(called_type->tp_new == NULL)) {
4451 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
4452 return NULL;
4453 }
4454
4455 PyObject *obj;
4456
4457 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
4458 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
4459 formatCannotInstantiateAbstractClass(tstate, called_type);
4460 return NULL;
4461 }
4462
4463 obj = called_type->tp_alloc(called_type, 0);
4464 CHECK_OBJECT(obj);
4465 } else {
4466 obj = called_type->tp_new(called_type, pos_args, NULL);
4467 }
4468
4469 if (likely(obj != NULL)) {
4470 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
4471 return obj;
4472 }
4473
4474 // Work on produced type.
4475 type = Py_TYPE(obj);
4476
4477 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
4478 if (type->tp_init == default_tp_init_wrapper) {
4479
4480 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
4481
4482 // Not really allowed, since we wouldn't have the default wrapper set.
4483 assert(init_method != NULL);
4484
4485 bool is_compiled_function = false;
4486 bool init_method_needs_release = false;
4487
4488 if (likely(init_method != NULL)) {
4489 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
4490
4491 if (func == Nuitka_Function_Type.tp_descr_get) {
4492 is_compiled_function = true;
4493 } else if (func != NULL) {
4494 init_method = func(init_method, obj, (PyObject *)(type));
4495 init_method_needs_release = true;
4496 }
4497 }
4498
4499 if (unlikely(init_method == NULL)) {
4500 if (!HAS_ERROR_OCCURRED(tstate)) {
4501 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
4502 const_str_plain___init__);
4503 }
4504
4505 return NULL;
4506 }
4507
4508 PyObject *result;
4509 if (is_compiled_function) {
4510 result = Nuitka_CallMethodFunctionPosArgs(
4511 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 5);
4512 } else {
4513 result = CALL_FUNCTION_WITH_POS_ARGS5(tstate, init_method, pos_args);
4514 if (init_method_needs_release) {
4515 Py_DECREF(init_method);
4516 }
4517 }
4518
4519 if (unlikely(result == NULL)) {
4520 Py_DECREF(obj);
4521 return NULL;
4522 }
4523
4524 Py_DECREF(result);
4525
4526 if (unlikely(result != Py_None)) {
4527 Py_DECREF(obj);
4528
4529 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
4530 return NULL;
4531 }
4532 } else {
4533
4534 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
4535 Py_DECREF(obj);
4536 return NULL;
4537 }
4538 }
4539 }
4540 }
4541
4542 CHECK_OBJECT_X(obj);
4543
4544 return obj;
4545 }
4546#endif
4547#if PYTHON_VERSION < 0x300
4548 } else if (PyClass_Check(called)) {
4549 PyObject *obj = PyInstance_NewRaw(called, NULL);
4550
4551 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
4552
4553 if (unlikely(init_method == NULL)) {
4554 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
4555 Py_DECREF(obj);
4556 return NULL;
4557 }
4558
4559 Py_DECREF(obj);
4560
4561 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
4562 return NULL;
4563 }
4564
4565 bool is_compiled_function = false;
4566
4567 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
4568
4569 if (descr_get == NULL) {
4570 Py_INCREF(init_method);
4571 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
4572 is_compiled_function = true;
4573 } else if (descr_get != NULL) {
4574 PyObject *descr_method = descr_get(init_method, obj, called);
4575
4576 if (unlikely(descr_method == NULL)) {
4577 return NULL;
4578 }
4579
4580 init_method = descr_method;
4581 }
4582
4583 PyObject *result;
4584 if (is_compiled_function) {
4585 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
4586 args, 5);
4587 } else {
4588 result = CALL_FUNCTION_WITH_POS_ARGS5(tstate, init_method, pos_args);
4589 Py_DECREF(init_method);
4590 }
4591 if (unlikely(result == NULL)) {
4592 return NULL;
4593 }
4594
4595 Py_DECREF(result);
4596
4597 if (unlikely(result != Py_None)) {
4598 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
4599 return NULL;
4600 }
4601
4602 CHECK_OBJECT_X(obj);
4603
4604 return obj;
4605#endif
4606#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
4607 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
4608 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4609
4610 if (likely(func != NULL)) {
4611 PyObject *result = func(called, args, 5, NULL);
4612
4613 CHECK_OBJECT_X(result);
4614
4615 return Nuitka_CheckFunctionResult(tstate, called, result);
4616 }
4617#endif
4618 }
4619
4620#if 0
4621 PRINT_NEW_LINE();
4622 PRINT_STRING("FALLBACK");
4623 PRINT_ITEM(called);
4624 PRINT_NEW_LINE();
4625#endif
4626
4627 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
4628
4629 CHECK_OBJECT_X(result);
4630
4631 return result;
4632}
4633PyObject *CALL_FUNCTION_WITH_ARGS6(PyThreadState *tstate, PyObject *called, PyObject *const *args) {
4634 CHECK_OBJECT(called);
4635 CHECK_OBJECTS(args, 6);
4636
4637 if (Nuitka_Function_Check(called)) {
4638 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
4639 return NULL;
4640 }
4641
4642 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
4643 PyObject *result;
4644
4645 if (function->m_args_simple && 6 == function->m_args_positional_count) {
4646 for (Py_ssize_t i = 0; i < 6; i++) {
4647 Py_INCREF(args[i]);
4648 }
4649 result = function->m_c_code(tstate, function, (PyObject **)args);
4650 } else if (function->m_args_simple && 6 + function->m_defaults_given == function->m_args_positional_count) {
4651 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4652
4653 memcpy(python_pars, args, 6 * sizeof(PyObject *));
4654 memcpy(python_pars + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
4655 function->m_defaults_given * sizeof(PyObject *));
4656
4657 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
4658 Py_INCREF(python_pars[i]);
4659 }
4660
4661 result = function->m_c_code(tstate, function, python_pars);
4662 } else {
4663 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 6);
4664 }
4665
4666 Py_LeaveRecursiveCall();
4667
4668 CHECK_OBJECT_X(result);
4669
4670 return result;
4671 } else if (Nuitka_Method_Check(called)) {
4672 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
4673
4674 if (method->m_object == NULL) {
4675 PyObject *self = args[0];
4676
4677 int res = PyObject_IsInstance(self, method->m_class);
4678
4679 if (unlikely(res < 0)) {
4680 return NULL;
4681 } else if (unlikely(res == 0)) {
4682 PyErr_Format(PyExc_TypeError,
4683 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
4684 "instance instead)",
4685 GET_CALLABLE_NAME((PyObject *)method->m_function),
4686 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
4687 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
4688
4689 return NULL;
4690 }
4691
4692 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 6);
4693
4694 CHECK_OBJECT_X(result);
4695
4696 return result;
4697 } else {
4698 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
4699 return NULL;
4700 }
4701
4702 struct Nuitka_FunctionObject *function = method->m_function;
4703
4704 PyObject *result;
4705
4706 if (function->m_args_simple && 6 + 1 == function->m_args_positional_count) {
4707 PyObject *python_pars[6 + 1];
4708
4709 python_pars[0] = method->m_object;
4710 Py_INCREF(method->m_object);
4711
4712 for (Py_ssize_t i = 0; i < 6; i++) {
4713 python_pars[i + 1] = args[i];
4714 Py_INCREF(args[i]);
4715 }
4716 result = function->m_c_code(tstate, function, python_pars);
4717 } else if (function->m_args_simple &&
4718 6 + 1 + function->m_defaults_given == function->m_args_positional_count) {
4719 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
4720
4721 python_pars[0] = method->m_object;
4722 Py_INCREF(method->m_object);
4723
4724 memcpy(python_pars + 1, args, 6 * sizeof(PyObject *));
4725 memcpy(python_pars + 1 + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
4726 function->m_defaults_given * sizeof(PyObject *));
4727
4728 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
4729 Py_INCREF(python_pars[i]);
4730 }
4731
4732 result = function->m_c_code(tstate, function, python_pars);
4733 } else {
4734 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 6);
4735 }
4736
4737 Py_LeaveRecursiveCall();
4738
4739 CHECK_OBJECT_X(result);
4740
4741 return result;
4742 }
4743#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
4744 } else if (PyCFunction_CheckExact(called)) {
4745#if PYTHON_VERSION >= 0x380
4746#ifdef _NUITKA_FULL_COMPAT
4747 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
4748 return NULL;
4749 }
4750#endif
4751
4752 int flags = PyCFunction_GET_FLAGS(called);
4753
4754 PyObject *result;
4755
4756 if (!(flags & METH_VARARGS)) {
4757 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
4758
4759 assert(func != NULL);
4760 result = func(called, args, 6, NULL);
4761
4762 CHECK_OBJECT_X(result);
4763 } else {
4764 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4765 PyObject *self = PyCFunction_GET_SELF(called);
4766
4767 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4768
4769 if (flags & METH_KEYWORDS) {
4770 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
4771 } else {
4772 result = (*method)(self, pos_args);
4773 }
4774
4775 Py_DECREF(pos_args);
4776 }
4777
4778#ifdef _NUITKA_FULL_COMPAT
4779 Py_LeaveRecursiveCall();
4780#endif
4781 CHECK_OBJECT_X(result);
4782
4783 return Nuitka_CheckFunctionResult(tstate, called, result);
4784#else
4785 // Try to be fast about wrapping the arguments.
4786 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
4787
4788 if (unlikely(flags & METH_NOARGS)) {
4789 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (6 given)",
4790 ((PyCFunctionObject *)called)->m_ml->ml_name);
4791 return NULL;
4792 } else if (unlikely(flags & METH_O)) {
4793 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (6 given)",
4794 ((PyCFunctionObject *)called)->m_ml->ml_name);
4795 return NULL;
4796 } else if (flags & METH_VARARGS) {
4797 // Recursion guard is not strictly necessary, as we already have
4798 // one on our way to here.
4799#ifdef _NUITKA_FULL_COMPAT
4800 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
4801 return NULL;
4802 }
4803#endif
4804 PyCFunction method = PyCFunction_GET_FUNCTION(called);
4805 PyObject *self = PyCFunction_GET_SELF(called);
4806
4807 PyObject *result;
4808
4809#if PYTHON_VERSION < 0x360
4810 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4811 if (flags & METH_KEYWORDS) {
4812 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4813 } else {
4814 result = (*method)(self, pos_args);
4815 }
4816
4817 Py_DECREF(pos_args);
4818#else
4819 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
4820 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4821 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
4822 Py_DECREF(pos_args);
4823 } else if (flags == METH_FASTCALL) {
4824#if PYTHON_VERSION < 0x370
4825 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 6, NULL);
4826#else
4827 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4828 result = (*(_PyCFunctionFast)method)(self, &pos_args, 6);
4829 Py_DECREF(pos_args);
4830#endif
4831 } else {
4832 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
4833 result = (*method)(self, pos_args);
4834 Py_DECREF(pos_args);
4835 }
4836#endif
4837
4838#ifdef _NUITKA_FULL_COMPAT
4839 Py_LeaveRecursiveCall();
4840#endif
4841
4842 CHECK_OBJECT_X(result);
4843
4844 return Nuitka_CheckFunctionResult(tstate, called, result);
4845 }
4846#endif
4847#endif
4848#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
4849 } else if (PyFunction_Check(called)) {
4850#if PYTHON_VERSION < 0x3b0
4851 PyObject *result = callPythonFunction(called, args, 6);
4852#else
4853 PyObject *result = _PyFunction_Vectorcall(called, args, 6, NULL);
4854#endif
4855 CHECK_OBJECT_X(result);
4856
4857 return result;
4858#endif
4859#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
4860 } else if (PyType_Check(called)) {
4861 PyTypeObject *type = Py_TYPE(called);
4862
4863 if (type->tp_call == PyType_Type.tp_call) {
4864 PyTypeObject *called_type = (PyTypeObject *)(called);
4865
4866 if (unlikely(called_type->tp_new == NULL)) {
4867 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
4868 return NULL;
4869 }
4870
4871 PyObject *pos_args = NULL;
4872 PyObject *obj;
4873
4874 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
4875 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
4876 formatCannotInstantiateAbstractClass(tstate, called_type);
4877 return NULL;
4878 }
4879
4880 obj = called_type->tp_alloc(called_type, 0);
4881 CHECK_OBJECT(obj);
4882 } else {
4883 pos_args = MAKE_TUPLE(tstate, args, 6);
4884 obj = called_type->tp_new(called_type, pos_args, NULL);
4885 }
4886
4887 if (likely(obj != NULL)) {
4888 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
4889 Py_DECREF(pos_args);
4890 return obj;
4891 }
4892
4893 // Work on produced type.
4894 type = Py_TYPE(obj);
4895
4896 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
4897 if (type->tp_init == default_tp_init_wrapper) {
4898 Py_XDECREF(pos_args);
4899 pos_args = NULL;
4900
4901 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
4902
4903 // Not really allowed, since we wouldn't have the default wrapper set.
4904 assert(init_method != NULL);
4905
4906 bool is_compiled_function = false;
4907 bool init_method_needs_release = false;
4908
4909 if (likely(init_method != NULL)) {
4910 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
4911
4912 if (func == Nuitka_Function_Type.tp_descr_get) {
4913 is_compiled_function = true;
4914 } else if (func != NULL) {
4915 init_method = func(init_method, obj, (PyObject *)(type));
4916 init_method_needs_release = true;
4917 }
4918 }
4919
4920 if (unlikely(init_method == NULL)) {
4921 if (!HAS_ERROR_OCCURRED(tstate)) {
4922 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
4923 const_str_plain___init__);
4924 }
4925
4926 return NULL;
4927 }
4928
4929 PyObject *result;
4930 if (is_compiled_function) {
4931 result = Nuitka_CallMethodFunctionPosArgs(
4932 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 6);
4933 } else {
4934 result = CALL_FUNCTION_WITH_ARGS6(tstate, init_method, args);
4935 if (init_method_needs_release) {
4936 Py_DECREF(init_method);
4937 }
4938 }
4939
4940 if (unlikely(result == NULL)) {
4941 Py_DECREF(obj);
4942 return NULL;
4943 }
4944
4945 Py_DECREF(result);
4946
4947 if (unlikely(result != Py_None)) {
4948 Py_DECREF(obj);
4949
4950 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
4951 return NULL;
4952 }
4953 } else {
4954 if (pos_args == NULL) {
4955 pos_args = MAKE_TUPLE(tstate, args, 6);
4956 }
4957
4958 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
4959 Py_DECREF(obj);
4960 Py_XDECREF(pos_args);
4961 return NULL;
4962 }
4963 }
4964 }
4965 }
4966
4967 Py_XDECREF(pos_args);
4968
4969 CHECK_OBJECT_X(obj);
4970
4971 return obj;
4972 }
4973#endif
4974#if PYTHON_VERSION < 0x300
4975 } else if (PyClass_Check(called)) {
4976 PyObject *obj = PyInstance_NewRaw(called, NULL);
4977
4978 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
4979
4980 if (unlikely(init_method == NULL)) {
4981 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
4982 Py_DECREF(obj);
4983 return NULL;
4984 }
4985
4986 Py_DECREF(obj);
4987
4988 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
4989 return NULL;
4990 }
4991
4992 bool is_compiled_function = false;
4993
4994 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
4995
4996 if (descr_get == NULL) {
4997 Py_INCREF(init_method);
4998 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
4999 is_compiled_function = true;
5000 } else if (descr_get != NULL) {
5001 PyObject *descr_method = descr_get(init_method, obj, called);
5002
5003 if (unlikely(descr_method == NULL)) {
5004 return NULL;
5005 }
5006
5007 init_method = descr_method;
5008 }
5009
5010 PyObject *result;
5011 if (is_compiled_function) {
5012 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
5013 args, 6);
5014 } else {
5015 result = CALL_FUNCTION_WITH_ARGS6(tstate, init_method, args);
5016 Py_DECREF(init_method);
5017 }
5018 if (unlikely(result == NULL)) {
5019 return NULL;
5020 }
5021
5022 Py_DECREF(result);
5023
5024 if (unlikely(result != Py_None)) {
5025 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
5026 return NULL;
5027 }
5028
5029 CHECK_OBJECT_X(obj);
5030
5031 return obj;
5032#endif
5033#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
5034 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
5035 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5036
5037 if (likely(func != NULL)) {
5038 PyObject *result = func(called, args, 6, NULL);
5039
5040 CHECK_OBJECT_X(result);
5041
5042 return Nuitka_CheckFunctionResult(tstate, called, result);
5043 }
5044#endif
5045 }
5046
5047#if 0
5048 PRINT_NEW_LINE();
5049 PRINT_STRING("FALLBACK");
5050 PRINT_ITEM(called);
5051 PRINT_NEW_LINE();
5052#endif
5053
5054 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
5055
5056 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
5057
5058 Py_DECREF(pos_args);
5059
5060 CHECK_OBJECT_X(result);
5061
5062 return result;
5063}
5064PyObject *CALL_FUNCTION_WITH_POS_ARGS6(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
5065 assert(PyTuple_CheckExact(pos_args));
5066 assert(PyTuple_GET_SIZE(pos_args) == 6);
5067 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
5068 CHECK_OBJECT(called);
5069 CHECK_OBJECTS(args, 6);
5070
5071 if (Nuitka_Function_Check(called)) {
5072 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
5073 return NULL;
5074 }
5075
5076 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
5077 PyObject *result;
5078
5079 if (function->m_args_simple && 6 == function->m_args_positional_count) {
5080 for (Py_ssize_t i = 0; i < 6; i++) {
5081 Py_INCREF(args[i]);
5082 }
5083 result = function->m_c_code(tstate, function, (PyObject **)args);
5084 } else if (function->m_args_simple && 6 + function->m_defaults_given == function->m_args_positional_count) {
5085 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5086
5087 memcpy(python_pars, args, 6 * sizeof(PyObject *));
5088 memcpy(python_pars + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
5089 function->m_defaults_given * sizeof(PyObject *));
5090
5091 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
5092 Py_INCREF(python_pars[i]);
5093 }
5094
5095 result = function->m_c_code(tstate, function, python_pars);
5096 } else {
5097 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 6);
5098 }
5099
5100 Py_LeaveRecursiveCall();
5101
5102 CHECK_OBJECT_X(result);
5103
5104 return result;
5105 } else if (Nuitka_Method_Check(called)) {
5106 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
5107
5108 if (method->m_object == NULL) {
5109 PyObject *self = args[0];
5110
5111 int res = PyObject_IsInstance(self, method->m_class);
5112
5113 if (unlikely(res < 0)) {
5114 return NULL;
5115 } else if (unlikely(res == 0)) {
5116 PyErr_Format(PyExc_TypeError,
5117 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
5118 "instance instead)",
5119 GET_CALLABLE_NAME((PyObject *)method->m_function),
5120 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
5121 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
5122
5123 return NULL;
5124 }
5125
5126 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 6);
5127
5128 CHECK_OBJECT_X(result);
5129
5130 return result;
5131 } else {
5132 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
5133 return NULL;
5134 }
5135
5136 struct Nuitka_FunctionObject *function = method->m_function;
5137
5138 PyObject *result;
5139
5140 if (function->m_args_simple && 6 + 1 == function->m_args_positional_count) {
5141 PyObject *python_pars[6 + 1];
5142
5143 python_pars[0] = method->m_object;
5144 Py_INCREF(method->m_object);
5145
5146 for (Py_ssize_t i = 0; i < 6; i++) {
5147 python_pars[i + 1] = args[i];
5148 Py_INCREF(args[i]);
5149 }
5150 result = function->m_c_code(tstate, function, python_pars);
5151 } else if (function->m_args_simple &&
5152 6 + 1 + function->m_defaults_given == function->m_args_positional_count) {
5153 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5154
5155 python_pars[0] = method->m_object;
5156 Py_INCREF(method->m_object);
5157
5158 memcpy(python_pars + 1, args, 6 * sizeof(PyObject *));
5159 memcpy(python_pars + 1 + 6, &PyTuple_GET_ITEM(function->m_defaults, 0),
5160 function->m_defaults_given * sizeof(PyObject *));
5161
5162 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
5163 Py_INCREF(python_pars[i]);
5164 }
5165
5166 result = function->m_c_code(tstate, function, python_pars);
5167 } else {
5168 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 6);
5169 }
5170
5171 Py_LeaveRecursiveCall();
5172
5173 CHECK_OBJECT_X(result);
5174
5175 return result;
5176 }
5177#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
5178 } else if (PyCFunction_CheckExact(called)) {
5179#if PYTHON_VERSION >= 0x380
5180#ifdef _NUITKA_FULL_COMPAT
5181 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
5182 return NULL;
5183 }
5184#endif
5185
5186 int flags = PyCFunction_GET_FLAGS(called);
5187
5188 PyObject *result;
5189
5190 if (!(flags & METH_VARARGS)) {
5191 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5192
5193 assert(func != NULL);
5194 result = func(called, args, 6, NULL);
5195
5196 CHECK_OBJECT_X(result);
5197 } else {
5198 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5199 PyObject *self = PyCFunction_GET_SELF(called);
5200
5201 if (flags & METH_KEYWORDS) {
5202 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
5203 } else {
5204 result = (*method)(self, pos_args);
5205 }
5206 }
5207
5208#ifdef _NUITKA_FULL_COMPAT
5209 Py_LeaveRecursiveCall();
5210#endif
5211 CHECK_OBJECT_X(result);
5212
5213 return Nuitka_CheckFunctionResult(tstate, called, result);
5214#else
5215 // Try to be fast about wrapping the arguments.
5216 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
5217
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);
5221 return NULL;
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);
5225 return NULL;
5226 } else if (flags & METH_VARARGS) {
5227 // Recursion guard is not strictly necessary, as we already have
5228 // one on our way to here.
5229#ifdef _NUITKA_FULL_COMPAT
5230 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
5231 return NULL;
5232 }
5233#endif
5234 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5235 PyObject *self = PyCFunction_GET_SELF(called);
5236
5237 PyObject *result;
5238
5239#if PYTHON_VERSION < 0x360
5240 if (flags & METH_KEYWORDS) {
5241 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5242 } else {
5243 result = (*method)(self, pos_args);
5244 }
5245
5246#else
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);
5252#else
5253 result = (*(_PyCFunctionFast)method)(self, &pos_args, 6);
5254#endif
5255 } else {
5256 result = (*method)(self, pos_args);
5257 }
5258#endif
5259
5260#ifdef _NUITKA_FULL_COMPAT
5261 Py_LeaveRecursiveCall();
5262#endif
5263
5264 CHECK_OBJECT_X(result);
5265
5266 return Nuitka_CheckFunctionResult(tstate, called, result);
5267 }
5268#endif
5269#endif
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);
5274#else
5275 PyObject *result = _PyFunction_Vectorcall(called, args, 6, NULL);
5276#endif
5277 CHECK_OBJECT_X(result);
5278
5279 return result;
5280#endif
5281#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
5282 } else if (PyType_Check(called)) {
5283 PyTypeObject *type = Py_TYPE(called);
5284
5285 if (type->tp_call == PyType_Type.tp_call) {
5286 PyTypeObject *called_type = (PyTypeObject *)(called);
5287
5288 if (unlikely(called_type->tp_new == NULL)) {
5289 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
5290 return NULL;
5291 }
5292
5293 PyObject *obj;
5294
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);
5298 return NULL;
5299 }
5300
5301 obj = called_type->tp_alloc(called_type, 0);
5302 CHECK_OBJECT(obj);
5303 } else {
5304 obj = called_type->tp_new(called_type, pos_args, NULL);
5305 }
5306
5307 if (likely(obj != NULL)) {
5308 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
5309 return obj;
5310 }
5311
5312 // Work on produced type.
5313 type = Py_TYPE(obj);
5314
5315 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
5316 if (type->tp_init == default_tp_init_wrapper) {
5317
5318 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
5319
5320 // Not really allowed, since we wouldn't have the default wrapper set.
5321 assert(init_method != NULL);
5322
5323 bool is_compiled_function = false;
5324 bool init_method_needs_release = false;
5325
5326 if (likely(init_method != NULL)) {
5327 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
5328
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;
5334 }
5335 }
5336
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__);
5341 }
5342
5343 return NULL;
5344 }
5345
5346 PyObject *result;
5347 if (is_compiled_function) {
5348 result = Nuitka_CallMethodFunctionPosArgs(
5349 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 6);
5350 } else {
5351 result = CALL_FUNCTION_WITH_POS_ARGS6(tstate, init_method, pos_args);
5352 if (init_method_needs_release) {
5353 Py_DECREF(init_method);
5354 }
5355 }
5356
5357 if (unlikely(result == NULL)) {
5358 Py_DECREF(obj);
5359 return NULL;
5360 }
5361
5362 Py_DECREF(result);
5363
5364 if (unlikely(result != Py_None)) {
5365 Py_DECREF(obj);
5366
5367 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
5368 return NULL;
5369 }
5370 } else {
5371
5372 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
5373 Py_DECREF(obj);
5374 return NULL;
5375 }
5376 }
5377 }
5378 }
5379
5380 CHECK_OBJECT_X(obj);
5381
5382 return obj;
5383 }
5384#endif
5385#if PYTHON_VERSION < 0x300
5386 } else if (PyClass_Check(called)) {
5387 PyObject *obj = PyInstance_NewRaw(called, NULL);
5388
5389 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
5390
5391 if (unlikely(init_method == NULL)) {
5392 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
5393 Py_DECREF(obj);
5394 return NULL;
5395 }
5396
5397 Py_DECREF(obj);
5398
5399 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
5400 return NULL;
5401 }
5402
5403 bool is_compiled_function = false;
5404
5405 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
5406
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);
5413
5414 if (unlikely(descr_method == NULL)) {
5415 return NULL;
5416 }
5417
5418 init_method = descr_method;
5419 }
5420
5421 PyObject *result;
5422 if (is_compiled_function) {
5423 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
5424 args, 6);
5425 } else {
5426 result = CALL_FUNCTION_WITH_POS_ARGS6(tstate, init_method, pos_args);
5427 Py_DECREF(init_method);
5428 }
5429 if (unlikely(result == NULL)) {
5430 return NULL;
5431 }
5432
5433 Py_DECREF(result);
5434
5435 if (unlikely(result != Py_None)) {
5436 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
5437 return NULL;
5438 }
5439
5440 CHECK_OBJECT_X(obj);
5441
5442 return obj;
5443#endif
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));
5447
5448 if (likely(func != NULL)) {
5449 PyObject *result = func(called, args, 6, NULL);
5450
5451 CHECK_OBJECT_X(result);
5452
5453 return Nuitka_CheckFunctionResult(tstate, called, result);
5454 }
5455#endif
5456 }
5457
5458#if 0
5459 PRINT_NEW_LINE();
5460 PRINT_STRING("FALLBACK");
5461 PRINT_ITEM(called);
5462 PRINT_NEW_LINE();
5463#endif
5464
5465 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
5466
5467 CHECK_OBJECT_X(result);
5468
5469 return result;
5470}
5471PyObject *CALL_FUNCTION_WITH_ARGS7(PyThreadState *tstate, PyObject *called, PyObject *const *args) {
5472 CHECK_OBJECT(called);
5473 CHECK_OBJECTS(args, 7);
5474
5475 if (Nuitka_Function_Check(called)) {
5476 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
5477 return NULL;
5478 }
5479
5480 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
5481 PyObject *result;
5482
5483 if (function->m_args_simple && 7 == function->m_args_positional_count) {
5484 for (Py_ssize_t i = 0; i < 7; i++) {
5485 Py_INCREF(args[i]);
5486 }
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);
5490
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 *));
5494
5495 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
5496 Py_INCREF(python_pars[i]);
5497 }
5498
5499 result = function->m_c_code(tstate, function, python_pars);
5500 } else {
5501 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 7);
5502 }
5503
5504 Py_LeaveRecursiveCall();
5505
5506 CHECK_OBJECT_X(result);
5507
5508 return result;
5509 } else if (Nuitka_Method_Check(called)) {
5510 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
5511
5512 if (method->m_object == NULL) {
5513 PyObject *self = args[0];
5514
5515 int res = PyObject_IsInstance(self, method->m_class);
5516
5517 if (unlikely(res < 0)) {
5518 return NULL;
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));
5526
5527 return NULL;
5528 }
5529
5530 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 7);
5531
5532 CHECK_OBJECT_X(result);
5533
5534 return result;
5535 } else {
5536 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
5537 return NULL;
5538 }
5539
5540 struct Nuitka_FunctionObject *function = method->m_function;
5541
5542 PyObject *result;
5543
5544 if (function->m_args_simple && 7 + 1 == function->m_args_positional_count) {
5545 PyObject *python_pars[7 + 1];
5546
5547 python_pars[0] = method->m_object;
5548 Py_INCREF(method->m_object);
5549
5550 for (Py_ssize_t i = 0; i < 7; i++) {
5551 python_pars[i + 1] = args[i];
5552 Py_INCREF(args[i]);
5553 }
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);
5558
5559 python_pars[0] = method->m_object;
5560 Py_INCREF(method->m_object);
5561
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 *));
5565
5566 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
5567 Py_INCREF(python_pars[i]);
5568 }
5569
5570 result = function->m_c_code(tstate, function, python_pars);
5571 } else {
5572 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 7);
5573 }
5574
5575 Py_LeaveRecursiveCall();
5576
5577 CHECK_OBJECT_X(result);
5578
5579 return result;
5580 }
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"))) {
5586 return NULL;
5587 }
5588#endif
5589
5590 int flags = PyCFunction_GET_FLAGS(called);
5591
5592 PyObject *result;
5593
5594 if (!(flags & METH_VARARGS)) {
5595 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5596
5597 assert(func != NULL);
5598 result = func(called, args, 7, NULL);
5599
5600 CHECK_OBJECT_X(result);
5601 } else {
5602 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5603 PyObject *self = PyCFunction_GET_SELF(called);
5604
5605 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5606
5607 if (flags & METH_KEYWORDS) {
5608 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
5609 } else {
5610 result = (*method)(self, pos_args);
5611 }
5612
5613 Py_DECREF(pos_args);
5614 }
5615
5616#ifdef _NUITKA_FULL_COMPAT
5617 Py_LeaveRecursiveCall();
5618#endif
5619 CHECK_OBJECT_X(result);
5620
5621 return Nuitka_CheckFunctionResult(tstate, called, result);
5622#else
5623 // Try to be fast about wrapping the arguments.
5624 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
5625
5626 if (unlikely(flags & METH_NOARGS)) {
5627 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (7 given)",
5628 ((PyCFunctionObject *)called)->m_ml->ml_name);
5629 return NULL;
5630 } else if (unlikely(flags & METH_O)) {
5631 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (7 given)",
5632 ((PyCFunctionObject *)called)->m_ml->ml_name);
5633 return NULL;
5634 } else if (flags & METH_VARARGS) {
5635 // Recursion guard is not strictly necessary, as we already have
5636 // one on our way to here.
5637#ifdef _NUITKA_FULL_COMPAT
5638 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
5639 return NULL;
5640 }
5641#endif
5642 PyCFunction method = PyCFunction_GET_FUNCTION(called);
5643 PyObject *self = PyCFunction_GET_SELF(called);
5644
5645 PyObject *result;
5646
5647#if PYTHON_VERSION < 0x360
5648 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5649 if (flags & METH_KEYWORDS) {
5650 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5651 } else {
5652 result = (*method)(self, pos_args);
5653 }
5654
5655 Py_DECREF(pos_args);
5656#else
5657 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
5658 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5659 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
5660 Py_DECREF(pos_args);
5661 } else if (flags == METH_FASTCALL) {
5662#if PYTHON_VERSION < 0x370
5663 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 7, NULL);
5664#else
5665 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5666 result = (*(_PyCFunctionFast)method)(self, &pos_args, 7);
5667 Py_DECREF(pos_args);
5668#endif
5669 } else {
5670 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5671 result = (*method)(self, pos_args);
5672 Py_DECREF(pos_args);
5673 }
5674#endif
5675
5676#ifdef _NUITKA_FULL_COMPAT
5677 Py_LeaveRecursiveCall();
5678#endif
5679
5680 CHECK_OBJECT_X(result);
5681
5682 return Nuitka_CheckFunctionResult(tstate, called, result);
5683 }
5684#endif
5685#endif
5686#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
5687 } else if (PyFunction_Check(called)) {
5688#if PYTHON_VERSION < 0x3b0
5689 PyObject *result = callPythonFunction(called, args, 7);
5690#else
5691 PyObject *result = _PyFunction_Vectorcall(called, args, 7, NULL);
5692#endif
5693 CHECK_OBJECT_X(result);
5694
5695 return result;
5696#endif
5697#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
5698 } else if (PyType_Check(called)) {
5699 PyTypeObject *type = Py_TYPE(called);
5700
5701 if (type->tp_call == PyType_Type.tp_call) {
5702 PyTypeObject *called_type = (PyTypeObject *)(called);
5703
5704 if (unlikely(called_type->tp_new == NULL)) {
5705 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
5706 return NULL;
5707 }
5708
5709 PyObject *pos_args = NULL;
5710 PyObject *obj;
5711
5712 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
5713 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
5714 formatCannotInstantiateAbstractClass(tstate, called_type);
5715 return NULL;
5716 }
5717
5718 obj = called_type->tp_alloc(called_type, 0);
5719 CHECK_OBJECT(obj);
5720 } else {
5721 pos_args = MAKE_TUPLE(tstate, args, 7);
5722 obj = called_type->tp_new(called_type, pos_args, NULL);
5723 }
5724
5725 if (likely(obj != NULL)) {
5726 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
5727 Py_DECREF(pos_args);
5728 return obj;
5729 }
5730
5731 // Work on produced type.
5732 type = Py_TYPE(obj);
5733
5734 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
5735 if (type->tp_init == default_tp_init_wrapper) {
5736 Py_XDECREF(pos_args);
5737 pos_args = NULL;
5738
5739 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
5740
5741 // Not really allowed, since we wouldn't have the default wrapper set.
5742 assert(init_method != NULL);
5743
5744 bool is_compiled_function = false;
5745 bool init_method_needs_release = false;
5746
5747 if (likely(init_method != NULL)) {
5748 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
5749
5750 if (func == Nuitka_Function_Type.tp_descr_get) {
5751 is_compiled_function = true;
5752 } else if (func != NULL) {
5753 init_method = func(init_method, obj, (PyObject *)(type));
5754 init_method_needs_release = true;
5755 }
5756 }
5757
5758 if (unlikely(init_method == NULL)) {
5759 if (!HAS_ERROR_OCCURRED(tstate)) {
5760 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
5761 const_str_plain___init__);
5762 }
5763
5764 return NULL;
5765 }
5766
5767 PyObject *result;
5768 if (is_compiled_function) {
5769 result = Nuitka_CallMethodFunctionPosArgs(
5770 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 7);
5771 } else {
5772 result = CALL_FUNCTION_WITH_ARGS7(tstate, init_method, args);
5773 if (init_method_needs_release) {
5774 Py_DECREF(init_method);
5775 }
5776 }
5777
5778 if (unlikely(result == NULL)) {
5779 Py_DECREF(obj);
5780 return NULL;
5781 }
5782
5783 Py_DECREF(result);
5784
5785 if (unlikely(result != Py_None)) {
5786 Py_DECREF(obj);
5787
5788 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
5789 return NULL;
5790 }
5791 } else {
5792 if (pos_args == NULL) {
5793 pos_args = MAKE_TUPLE(tstate, args, 7);
5794 }
5795
5796 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
5797 Py_DECREF(obj);
5798 Py_XDECREF(pos_args);
5799 return NULL;
5800 }
5801 }
5802 }
5803 }
5804
5805 Py_XDECREF(pos_args);
5806
5807 CHECK_OBJECT_X(obj);
5808
5809 return obj;
5810 }
5811#endif
5812#if PYTHON_VERSION < 0x300
5813 } else if (PyClass_Check(called)) {
5814 PyObject *obj = PyInstance_NewRaw(called, NULL);
5815
5816 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
5817
5818 if (unlikely(init_method == NULL)) {
5819 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
5820 Py_DECREF(obj);
5821 return NULL;
5822 }
5823
5824 Py_DECREF(obj);
5825
5826 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
5827 return NULL;
5828 }
5829
5830 bool is_compiled_function = false;
5831
5832 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
5833
5834 if (descr_get == NULL) {
5835 Py_INCREF(init_method);
5836 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
5837 is_compiled_function = true;
5838 } else if (descr_get != NULL) {
5839 PyObject *descr_method = descr_get(init_method, obj, called);
5840
5841 if (unlikely(descr_method == NULL)) {
5842 return NULL;
5843 }
5844
5845 init_method = descr_method;
5846 }
5847
5848 PyObject *result;
5849 if (is_compiled_function) {
5850 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
5851 args, 7);
5852 } else {
5853 result = CALL_FUNCTION_WITH_ARGS7(tstate, init_method, args);
5854 Py_DECREF(init_method);
5855 }
5856 if (unlikely(result == NULL)) {
5857 return NULL;
5858 }
5859
5860 Py_DECREF(result);
5861
5862 if (unlikely(result != Py_None)) {
5863 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
5864 return NULL;
5865 }
5866
5867 CHECK_OBJECT_X(obj);
5868
5869 return obj;
5870#endif
5871#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
5872 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
5873 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
5874
5875 if (likely(func != NULL)) {
5876 PyObject *result = func(called, args, 7, NULL);
5877
5878 CHECK_OBJECT_X(result);
5879
5880 return Nuitka_CheckFunctionResult(tstate, called, result);
5881 }
5882#endif
5883 }
5884
5885#if 0
5886 PRINT_NEW_LINE();
5887 PRINT_STRING("FALLBACK");
5888 PRINT_ITEM(called);
5889 PRINT_NEW_LINE();
5890#endif
5891
5892 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
5893
5894 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
5895
5896 Py_DECREF(pos_args);
5897
5898 CHECK_OBJECT_X(result);
5899
5900 return result;
5901}
5902PyObject *CALL_FUNCTION_WITH_POS_ARGS7(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
5903 assert(PyTuple_CheckExact(pos_args));
5904 assert(PyTuple_GET_SIZE(pos_args) == 7);
5905 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
5906 CHECK_OBJECT(called);
5907 CHECK_OBJECTS(args, 7);
5908
5909 if (Nuitka_Function_Check(called)) {
5910 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
5911 return NULL;
5912 }
5913
5914 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
5915 PyObject *result;
5916
5917 if (function->m_args_simple && 7 == function->m_args_positional_count) {
5918 for (Py_ssize_t i = 0; i < 7; i++) {
5919 Py_INCREF(args[i]);
5920 }
5921 result = function->m_c_code(tstate, function, (PyObject **)args);
5922 } else if (function->m_args_simple && 7 + function->m_defaults_given == function->m_args_positional_count) {
5923 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5924
5925 memcpy(python_pars, args, 7 * sizeof(PyObject *));
5926 memcpy(python_pars + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
5927 function->m_defaults_given * sizeof(PyObject *));
5928
5929 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
5930 Py_INCREF(python_pars[i]);
5931 }
5932
5933 result = function->m_c_code(tstate, function, python_pars);
5934 } else {
5935 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 7);
5936 }
5937
5938 Py_LeaveRecursiveCall();
5939
5940 CHECK_OBJECT_X(result);
5941
5942 return result;
5943 } else if (Nuitka_Method_Check(called)) {
5944 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
5945
5946 if (method->m_object == NULL) {
5947 PyObject *self = args[0];
5948
5949 int res = PyObject_IsInstance(self, method->m_class);
5950
5951 if (unlikely(res < 0)) {
5952 return NULL;
5953 } else if (unlikely(res == 0)) {
5954 PyErr_Format(PyExc_TypeError,
5955 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
5956 "instance instead)",
5957 GET_CALLABLE_NAME((PyObject *)method->m_function),
5958 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
5959 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
5960
5961 return NULL;
5962 }
5963
5964 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 7);
5965
5966 CHECK_OBJECT_X(result);
5967
5968 return result;
5969 } else {
5970 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
5971 return NULL;
5972 }
5973
5974 struct Nuitka_FunctionObject *function = method->m_function;
5975
5976 PyObject *result;
5977
5978 if (function->m_args_simple && 7 + 1 == function->m_args_positional_count) {
5979 PyObject *python_pars[7 + 1];
5980
5981 python_pars[0] = method->m_object;
5982 Py_INCREF(method->m_object);
5983
5984 for (Py_ssize_t i = 0; i < 7; i++) {
5985 python_pars[i + 1] = args[i];
5986 Py_INCREF(args[i]);
5987 }
5988 result = function->m_c_code(tstate, function, python_pars);
5989 } else if (function->m_args_simple &&
5990 7 + 1 + function->m_defaults_given == function->m_args_positional_count) {
5991 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
5992
5993 python_pars[0] = method->m_object;
5994 Py_INCREF(method->m_object);
5995
5996 memcpy(python_pars + 1, args, 7 * sizeof(PyObject *));
5997 memcpy(python_pars + 1 + 7, &PyTuple_GET_ITEM(function->m_defaults, 0),
5998 function->m_defaults_given * sizeof(PyObject *));
5999
6000 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
6001 Py_INCREF(python_pars[i]);
6002 }
6003
6004 result = function->m_c_code(tstate, function, python_pars);
6005 } else {
6006 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 7);
6007 }
6008
6009 Py_LeaveRecursiveCall();
6010
6011 CHECK_OBJECT_X(result);
6012
6013 return result;
6014 }
6015#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
6016 } else if (PyCFunction_CheckExact(called)) {
6017#if PYTHON_VERSION >= 0x380
6018#ifdef _NUITKA_FULL_COMPAT
6019 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
6020 return NULL;
6021 }
6022#endif
6023
6024 int flags = PyCFunction_GET_FLAGS(called);
6025
6026 PyObject *result;
6027
6028 if (!(flags & METH_VARARGS)) {
6029 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6030
6031 assert(func != NULL);
6032 result = func(called, args, 7, NULL);
6033
6034 CHECK_OBJECT_X(result);
6035 } else {
6036 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6037 PyObject *self = PyCFunction_GET_SELF(called);
6038
6039 if (flags & METH_KEYWORDS) {
6040 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
6041 } else {
6042 result = (*method)(self, pos_args);
6043 }
6044 }
6045
6046#ifdef _NUITKA_FULL_COMPAT
6047 Py_LeaveRecursiveCall();
6048#endif
6049 CHECK_OBJECT_X(result);
6050
6051 return Nuitka_CheckFunctionResult(tstate, called, result);
6052#else
6053 // Try to be fast about wrapping the arguments.
6054 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
6055
6056 if (unlikely(flags & METH_NOARGS)) {
6057 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (7 given)",
6058 ((PyCFunctionObject *)called)->m_ml->ml_name);
6059 return NULL;
6060 } else if (unlikely(flags & METH_O)) {
6061 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (7 given)",
6062 ((PyCFunctionObject *)called)->m_ml->ml_name);
6063 return NULL;
6064 } else if (flags & METH_VARARGS) {
6065 // Recursion guard is not strictly necessary, as we already have
6066 // one on our way to here.
6067#ifdef _NUITKA_FULL_COMPAT
6068 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
6069 return NULL;
6070 }
6071#endif
6072 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6073 PyObject *self = PyCFunction_GET_SELF(called);
6074
6075 PyObject *result;
6076
6077#if PYTHON_VERSION < 0x360
6078 if (flags & METH_KEYWORDS) {
6079 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6080 } else {
6081 result = (*method)(self, pos_args);
6082 }
6083
6084#else
6085 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
6086 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6087 } else if (flags == METH_FASTCALL) {
6088#if PYTHON_VERSION < 0x370
6089 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 7, NULL);
6090#else
6091 result = (*(_PyCFunctionFast)method)(self, &pos_args, 7);
6092#endif
6093 } else {
6094 result = (*method)(self, pos_args);
6095 }
6096#endif
6097
6098#ifdef _NUITKA_FULL_COMPAT
6099 Py_LeaveRecursiveCall();
6100#endif
6101
6102 CHECK_OBJECT_X(result);
6103
6104 return Nuitka_CheckFunctionResult(tstate, called, result);
6105 }
6106#endif
6107#endif
6108#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
6109 } else if (PyFunction_Check(called)) {
6110#if PYTHON_VERSION < 0x3b0
6111 PyObject *result = callPythonFunction(called, args, 7);
6112#else
6113 PyObject *result = _PyFunction_Vectorcall(called, args, 7, NULL);
6114#endif
6115 CHECK_OBJECT_X(result);
6116
6117 return result;
6118#endif
6119#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
6120 } else if (PyType_Check(called)) {
6121 PyTypeObject *type = Py_TYPE(called);
6122
6123 if (type->tp_call == PyType_Type.tp_call) {
6124 PyTypeObject *called_type = (PyTypeObject *)(called);
6125
6126 if (unlikely(called_type->tp_new == NULL)) {
6127 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
6128 return NULL;
6129 }
6130
6131 PyObject *obj;
6132
6133 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
6134 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
6135 formatCannotInstantiateAbstractClass(tstate, called_type);
6136 return NULL;
6137 }
6138
6139 obj = called_type->tp_alloc(called_type, 0);
6140 CHECK_OBJECT(obj);
6141 } else {
6142 obj = called_type->tp_new(called_type, pos_args, NULL);
6143 }
6144
6145 if (likely(obj != NULL)) {
6146 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
6147 return obj;
6148 }
6149
6150 // Work on produced type.
6151 type = Py_TYPE(obj);
6152
6153 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
6154 if (type->tp_init == default_tp_init_wrapper) {
6155
6156 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
6157
6158 // Not really allowed, since we wouldn't have the default wrapper set.
6159 assert(init_method != NULL);
6160
6161 bool is_compiled_function = false;
6162 bool init_method_needs_release = false;
6163
6164 if (likely(init_method != NULL)) {
6165 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
6166
6167 if (func == Nuitka_Function_Type.tp_descr_get) {
6168 is_compiled_function = true;
6169 } else if (func != NULL) {
6170 init_method = func(init_method, obj, (PyObject *)(type));
6171 init_method_needs_release = true;
6172 }
6173 }
6174
6175 if (unlikely(init_method == NULL)) {
6176 if (!HAS_ERROR_OCCURRED(tstate)) {
6177 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
6178 const_str_plain___init__);
6179 }
6180
6181 return NULL;
6182 }
6183
6184 PyObject *result;
6185 if (is_compiled_function) {
6186 result = Nuitka_CallMethodFunctionPosArgs(
6187 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 7);
6188 } else {
6189 result = CALL_FUNCTION_WITH_POS_ARGS7(tstate, init_method, pos_args);
6190 if (init_method_needs_release) {
6191 Py_DECREF(init_method);
6192 }
6193 }
6194
6195 if (unlikely(result == NULL)) {
6196 Py_DECREF(obj);
6197 return NULL;
6198 }
6199
6200 Py_DECREF(result);
6201
6202 if (unlikely(result != Py_None)) {
6203 Py_DECREF(obj);
6204
6205 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
6206 return NULL;
6207 }
6208 } else {
6209
6210 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
6211 Py_DECREF(obj);
6212 return NULL;
6213 }
6214 }
6215 }
6216 }
6217
6218 CHECK_OBJECT_X(obj);
6219
6220 return obj;
6221 }
6222#endif
6223#if PYTHON_VERSION < 0x300
6224 } else if (PyClass_Check(called)) {
6225 PyObject *obj = PyInstance_NewRaw(called, NULL);
6226
6227 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
6228
6229 if (unlikely(init_method == NULL)) {
6230 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
6231 Py_DECREF(obj);
6232 return NULL;
6233 }
6234
6235 Py_DECREF(obj);
6236
6237 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
6238 return NULL;
6239 }
6240
6241 bool is_compiled_function = false;
6242
6243 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
6244
6245 if (descr_get == NULL) {
6246 Py_INCREF(init_method);
6247 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
6248 is_compiled_function = true;
6249 } else if (descr_get != NULL) {
6250 PyObject *descr_method = descr_get(init_method, obj, called);
6251
6252 if (unlikely(descr_method == NULL)) {
6253 return NULL;
6254 }
6255
6256 init_method = descr_method;
6257 }
6258
6259 PyObject *result;
6260 if (is_compiled_function) {
6261 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
6262 args, 7);
6263 } else {
6264 result = CALL_FUNCTION_WITH_POS_ARGS7(tstate, init_method, pos_args);
6265 Py_DECREF(init_method);
6266 }
6267 if (unlikely(result == NULL)) {
6268 return NULL;
6269 }
6270
6271 Py_DECREF(result);
6272
6273 if (unlikely(result != Py_None)) {
6274 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
6275 return NULL;
6276 }
6277
6278 CHECK_OBJECT_X(obj);
6279
6280 return obj;
6281#endif
6282#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
6283 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
6284 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6285
6286 if (likely(func != NULL)) {
6287 PyObject *result = func(called, args, 7, NULL);
6288
6289 CHECK_OBJECT_X(result);
6290
6291 return Nuitka_CheckFunctionResult(tstate, called, result);
6292 }
6293#endif
6294 }
6295
6296#if 0
6297 PRINT_NEW_LINE();
6298 PRINT_STRING("FALLBACK");
6299 PRINT_ITEM(called);
6300 PRINT_NEW_LINE();
6301#endif
6302
6303 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
6304
6305 CHECK_OBJECT_X(result);
6306
6307 return result;
6308}
6309PyObject *CALL_FUNCTION_WITH_ARGS8(PyThreadState *tstate, PyObject *called, PyObject *const *args) {
6310 CHECK_OBJECT(called);
6311 CHECK_OBJECTS(args, 8);
6312
6313 if (Nuitka_Function_Check(called)) {
6314 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
6315 return NULL;
6316 }
6317
6318 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
6319 PyObject *result;
6320
6321 if (function->m_args_simple && 8 == function->m_args_positional_count) {
6322 for (Py_ssize_t i = 0; i < 8; i++) {
6323 Py_INCREF(args[i]);
6324 }
6325 result = function->m_c_code(tstate, function, (PyObject **)args);
6326 } else if (function->m_args_simple && 8 + function->m_defaults_given == function->m_args_positional_count) {
6327 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6328
6329 memcpy(python_pars, args, 8 * sizeof(PyObject *));
6330 memcpy(python_pars + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6331 function->m_defaults_given * sizeof(PyObject *));
6332
6333 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
6334 Py_INCREF(python_pars[i]);
6335 }
6336
6337 result = function->m_c_code(tstate, function, python_pars);
6338 } else {
6339 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 8);
6340 }
6341
6342 Py_LeaveRecursiveCall();
6343
6344 CHECK_OBJECT_X(result);
6345
6346 return result;
6347 } else if (Nuitka_Method_Check(called)) {
6348 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
6349
6350 if (method->m_object == NULL) {
6351 PyObject *self = args[0];
6352
6353 int res = PyObject_IsInstance(self, method->m_class);
6354
6355 if (unlikely(res < 0)) {
6356 return NULL;
6357 } else if (unlikely(res == 0)) {
6358 PyErr_Format(PyExc_TypeError,
6359 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
6360 "instance instead)",
6361 GET_CALLABLE_NAME((PyObject *)method->m_function),
6362 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
6363 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
6364
6365 return NULL;
6366 }
6367
6368 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 8);
6369
6370 CHECK_OBJECT_X(result);
6371
6372 return result;
6373 } else {
6374 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
6375 return NULL;
6376 }
6377
6378 struct Nuitka_FunctionObject *function = method->m_function;
6379
6380 PyObject *result;
6381
6382 if (function->m_args_simple && 8 + 1 == function->m_args_positional_count) {
6383 PyObject *python_pars[8 + 1];
6384
6385 python_pars[0] = method->m_object;
6386 Py_INCREF(method->m_object);
6387
6388 for (Py_ssize_t i = 0; i < 8; i++) {
6389 python_pars[i + 1] = args[i];
6390 Py_INCREF(args[i]);
6391 }
6392 result = function->m_c_code(tstate, function, python_pars);
6393 } else if (function->m_args_simple &&
6394 8 + 1 + function->m_defaults_given == function->m_args_positional_count) {
6395 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6396
6397 python_pars[0] = method->m_object;
6398 Py_INCREF(method->m_object);
6399
6400 memcpy(python_pars + 1, args, 8 * sizeof(PyObject *));
6401 memcpy(python_pars + 1 + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6402 function->m_defaults_given * sizeof(PyObject *));
6403
6404 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
6405 Py_INCREF(python_pars[i]);
6406 }
6407
6408 result = function->m_c_code(tstate, function, python_pars);
6409 } else {
6410 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 8);
6411 }
6412
6413 Py_LeaveRecursiveCall();
6414
6415 CHECK_OBJECT_X(result);
6416
6417 return result;
6418 }
6419#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
6420 } else if (PyCFunction_CheckExact(called)) {
6421#if PYTHON_VERSION >= 0x380
6422#ifdef _NUITKA_FULL_COMPAT
6423 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
6424 return NULL;
6425 }
6426#endif
6427
6428 int flags = PyCFunction_GET_FLAGS(called);
6429
6430 PyObject *result;
6431
6432 if (!(flags & METH_VARARGS)) {
6433 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6434
6435 assert(func != NULL);
6436 result = func(called, args, 8, NULL);
6437
6438 CHECK_OBJECT_X(result);
6439 } else {
6440 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6441 PyObject *self = PyCFunction_GET_SELF(called);
6442
6443 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6444
6445 if (flags & METH_KEYWORDS) {
6446 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
6447 } else {
6448 result = (*method)(self, pos_args);
6449 }
6450
6451 Py_DECREF(pos_args);
6452 }
6453
6454#ifdef _NUITKA_FULL_COMPAT
6455 Py_LeaveRecursiveCall();
6456#endif
6457 CHECK_OBJECT_X(result);
6458
6459 return Nuitka_CheckFunctionResult(tstate, called, result);
6460#else
6461 // Try to be fast about wrapping the arguments.
6462 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
6463
6464 if (unlikely(flags & METH_NOARGS)) {
6465 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (8 given)",
6466 ((PyCFunctionObject *)called)->m_ml->ml_name);
6467 return NULL;
6468 } else if (unlikely(flags & METH_O)) {
6469 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (8 given)",
6470 ((PyCFunctionObject *)called)->m_ml->ml_name);
6471 return NULL;
6472 } else if (flags & METH_VARARGS) {
6473 // Recursion guard is not strictly necessary, as we already have
6474 // one on our way to here.
6475#ifdef _NUITKA_FULL_COMPAT
6476 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
6477 return NULL;
6478 }
6479#endif
6480 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6481 PyObject *self = PyCFunction_GET_SELF(called);
6482
6483 PyObject *result;
6484
6485#if PYTHON_VERSION < 0x360
6486 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6487 if (flags & METH_KEYWORDS) {
6488 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6489 } else {
6490 result = (*method)(self, pos_args);
6491 }
6492
6493 Py_DECREF(pos_args);
6494#else
6495 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
6496 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6497 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6498 Py_DECREF(pos_args);
6499 } else if (flags == METH_FASTCALL) {
6500#if PYTHON_VERSION < 0x370
6501 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 8, NULL);
6502#else
6503 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6504 result = (*(_PyCFunctionFast)method)(self, &pos_args, 8);
6505 Py_DECREF(pos_args);
6506#endif
6507 } else {
6508 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6509 result = (*method)(self, pos_args);
6510 Py_DECREF(pos_args);
6511 }
6512#endif
6513
6514#ifdef _NUITKA_FULL_COMPAT
6515 Py_LeaveRecursiveCall();
6516#endif
6517
6518 CHECK_OBJECT_X(result);
6519
6520 return Nuitka_CheckFunctionResult(tstate, called, result);
6521 }
6522#endif
6523#endif
6524#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
6525 } else if (PyFunction_Check(called)) {
6526#if PYTHON_VERSION < 0x3b0
6527 PyObject *result = callPythonFunction(called, args, 8);
6528#else
6529 PyObject *result = _PyFunction_Vectorcall(called, args, 8, NULL);
6530#endif
6531 CHECK_OBJECT_X(result);
6532
6533 return result;
6534#endif
6535#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
6536 } else if (PyType_Check(called)) {
6537 PyTypeObject *type = Py_TYPE(called);
6538
6539 if (type->tp_call == PyType_Type.tp_call) {
6540 PyTypeObject *called_type = (PyTypeObject *)(called);
6541
6542 if (unlikely(called_type->tp_new == NULL)) {
6543 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
6544 return NULL;
6545 }
6546
6547 PyObject *pos_args = NULL;
6548 PyObject *obj;
6549
6550 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
6551 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
6552 formatCannotInstantiateAbstractClass(tstate, called_type);
6553 return NULL;
6554 }
6555
6556 obj = called_type->tp_alloc(called_type, 0);
6557 CHECK_OBJECT(obj);
6558 } else {
6559 pos_args = MAKE_TUPLE(tstate, args, 8);
6560 obj = called_type->tp_new(called_type, pos_args, NULL);
6561 }
6562
6563 if (likely(obj != NULL)) {
6564 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
6565 Py_DECREF(pos_args);
6566 return obj;
6567 }
6568
6569 // Work on produced type.
6570 type = Py_TYPE(obj);
6571
6572 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
6573 if (type->tp_init == default_tp_init_wrapper) {
6574 Py_XDECREF(pos_args);
6575 pos_args = NULL;
6576
6577 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
6578
6579 // Not really allowed, since we wouldn't have the default wrapper set.
6580 assert(init_method != NULL);
6581
6582 bool is_compiled_function = false;
6583 bool init_method_needs_release = false;
6584
6585 if (likely(init_method != NULL)) {
6586 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
6587
6588 if (func == Nuitka_Function_Type.tp_descr_get) {
6589 is_compiled_function = true;
6590 } else if (func != NULL) {
6591 init_method = func(init_method, obj, (PyObject *)(type));
6592 init_method_needs_release = true;
6593 }
6594 }
6595
6596 if (unlikely(init_method == NULL)) {
6597 if (!HAS_ERROR_OCCURRED(tstate)) {
6598 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
6599 const_str_plain___init__);
6600 }
6601
6602 return NULL;
6603 }
6604
6605 PyObject *result;
6606 if (is_compiled_function) {
6607 result = Nuitka_CallMethodFunctionPosArgs(
6608 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 8);
6609 } else {
6610 result = CALL_FUNCTION_WITH_ARGS8(tstate, init_method, args);
6611 if (init_method_needs_release) {
6612 Py_DECREF(init_method);
6613 }
6614 }
6615
6616 if (unlikely(result == NULL)) {
6617 Py_DECREF(obj);
6618 return NULL;
6619 }
6620
6621 Py_DECREF(result);
6622
6623 if (unlikely(result != Py_None)) {
6624 Py_DECREF(obj);
6625
6626 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
6627 return NULL;
6628 }
6629 } else {
6630 if (pos_args == NULL) {
6631 pos_args = MAKE_TUPLE(tstate, args, 8);
6632 }
6633
6634 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
6635 Py_DECREF(obj);
6636 Py_XDECREF(pos_args);
6637 return NULL;
6638 }
6639 }
6640 }
6641 }
6642
6643 Py_XDECREF(pos_args);
6644
6645 CHECK_OBJECT_X(obj);
6646
6647 return obj;
6648 }
6649#endif
6650#if PYTHON_VERSION < 0x300
6651 } else if (PyClass_Check(called)) {
6652 PyObject *obj = PyInstance_NewRaw(called, NULL);
6653
6654 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
6655
6656 if (unlikely(init_method == NULL)) {
6657 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
6658 Py_DECREF(obj);
6659 return NULL;
6660 }
6661
6662 Py_DECREF(obj);
6663
6664 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
6665 return NULL;
6666 }
6667
6668 bool is_compiled_function = false;
6669
6670 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
6671
6672 if (descr_get == NULL) {
6673 Py_INCREF(init_method);
6674 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
6675 is_compiled_function = true;
6676 } else if (descr_get != NULL) {
6677 PyObject *descr_method = descr_get(init_method, obj, called);
6678
6679 if (unlikely(descr_method == NULL)) {
6680 return NULL;
6681 }
6682
6683 init_method = descr_method;
6684 }
6685
6686 PyObject *result;
6687 if (is_compiled_function) {
6688 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
6689 args, 8);
6690 } else {
6691 result = CALL_FUNCTION_WITH_ARGS8(tstate, init_method, args);
6692 Py_DECREF(init_method);
6693 }
6694 if (unlikely(result == NULL)) {
6695 return NULL;
6696 }
6697
6698 Py_DECREF(result);
6699
6700 if (unlikely(result != Py_None)) {
6701 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
6702 return NULL;
6703 }
6704
6705 CHECK_OBJECT_X(obj);
6706
6707 return obj;
6708#endif
6709#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
6710 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
6711 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6712
6713 if (likely(func != NULL)) {
6714 PyObject *result = func(called, args, 8, NULL);
6715
6716 CHECK_OBJECT_X(result);
6717
6718 return Nuitka_CheckFunctionResult(tstate, called, result);
6719 }
6720#endif
6721 }
6722
6723#if 0
6724 PRINT_NEW_LINE();
6725 PRINT_STRING("FALLBACK");
6726 PRINT_ITEM(called);
6727 PRINT_NEW_LINE();
6728#endif
6729
6730 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
6731
6732 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
6733
6734 Py_DECREF(pos_args);
6735
6736 CHECK_OBJECT_X(result);
6737
6738 return result;
6739}
6740PyObject *CALL_FUNCTION_WITH_POS_ARGS8(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
6741 assert(PyTuple_CheckExact(pos_args));
6742 assert(PyTuple_GET_SIZE(pos_args) == 8);
6743 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
6744 CHECK_OBJECT(called);
6745 CHECK_OBJECTS(args, 8);
6746
6747 if (Nuitka_Function_Check(called)) {
6748 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
6749 return NULL;
6750 }
6751
6752 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
6753 PyObject *result;
6754
6755 if (function->m_args_simple && 8 == function->m_args_positional_count) {
6756 for (Py_ssize_t i = 0; i < 8; i++) {
6757 Py_INCREF(args[i]);
6758 }
6759 result = function->m_c_code(tstate, function, (PyObject **)args);
6760 } else if (function->m_args_simple && 8 + function->m_defaults_given == function->m_args_positional_count) {
6761 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6762
6763 memcpy(python_pars, args, 8 * sizeof(PyObject *));
6764 memcpy(python_pars + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6765 function->m_defaults_given * sizeof(PyObject *));
6766
6767 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
6768 Py_INCREF(python_pars[i]);
6769 }
6770
6771 result = function->m_c_code(tstate, function, python_pars);
6772 } else {
6773 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 8);
6774 }
6775
6776 Py_LeaveRecursiveCall();
6777
6778 CHECK_OBJECT_X(result);
6779
6780 return result;
6781 } else if (Nuitka_Method_Check(called)) {
6782 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
6783
6784 if (method->m_object == NULL) {
6785 PyObject *self = args[0];
6786
6787 int res = PyObject_IsInstance(self, method->m_class);
6788
6789 if (unlikely(res < 0)) {
6790 return NULL;
6791 } else if (unlikely(res == 0)) {
6792 PyErr_Format(PyExc_TypeError,
6793 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
6794 "instance instead)",
6795 GET_CALLABLE_NAME((PyObject *)method->m_function),
6796 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
6797 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
6798
6799 return NULL;
6800 }
6801
6802 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 8);
6803
6804 CHECK_OBJECT_X(result);
6805
6806 return result;
6807 } else {
6808 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
6809 return NULL;
6810 }
6811
6812 struct Nuitka_FunctionObject *function = method->m_function;
6813
6814 PyObject *result;
6815
6816 if (function->m_args_simple && 8 + 1 == function->m_args_positional_count) {
6817 PyObject *python_pars[8 + 1];
6818
6819 python_pars[0] = method->m_object;
6820 Py_INCREF(method->m_object);
6821
6822 for (Py_ssize_t i = 0; i < 8; i++) {
6823 python_pars[i + 1] = args[i];
6824 Py_INCREF(args[i]);
6825 }
6826 result = function->m_c_code(tstate, function, python_pars);
6827 } else if (function->m_args_simple &&
6828 8 + 1 + function->m_defaults_given == function->m_args_positional_count) {
6829 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
6830
6831 python_pars[0] = method->m_object;
6832 Py_INCREF(method->m_object);
6833
6834 memcpy(python_pars + 1, args, 8 * sizeof(PyObject *));
6835 memcpy(python_pars + 1 + 8, &PyTuple_GET_ITEM(function->m_defaults, 0),
6836 function->m_defaults_given * sizeof(PyObject *));
6837
6838 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
6839 Py_INCREF(python_pars[i]);
6840 }
6841
6842 result = function->m_c_code(tstate, function, python_pars);
6843 } else {
6844 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 8);
6845 }
6846
6847 Py_LeaveRecursiveCall();
6848
6849 CHECK_OBJECT_X(result);
6850
6851 return result;
6852 }
6853#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
6854 } else if (PyCFunction_CheckExact(called)) {
6855#if PYTHON_VERSION >= 0x380
6856#ifdef _NUITKA_FULL_COMPAT
6857 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
6858 return NULL;
6859 }
6860#endif
6861
6862 int flags = PyCFunction_GET_FLAGS(called);
6863
6864 PyObject *result;
6865
6866 if (!(flags & METH_VARARGS)) {
6867 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
6868
6869 assert(func != NULL);
6870 result = func(called, args, 8, NULL);
6871
6872 CHECK_OBJECT_X(result);
6873 } else {
6874 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6875 PyObject *self = PyCFunction_GET_SELF(called);
6876
6877 if (flags & METH_KEYWORDS) {
6878 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
6879 } else {
6880 result = (*method)(self, pos_args);
6881 }
6882 }
6883
6884#ifdef _NUITKA_FULL_COMPAT
6885 Py_LeaveRecursiveCall();
6886#endif
6887 CHECK_OBJECT_X(result);
6888
6889 return Nuitka_CheckFunctionResult(tstate, called, result);
6890#else
6891 // Try to be fast about wrapping the arguments.
6892 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
6893
6894 if (unlikely(flags & METH_NOARGS)) {
6895 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (8 given)",
6896 ((PyCFunctionObject *)called)->m_ml->ml_name);
6897 return NULL;
6898 } else if (unlikely(flags & METH_O)) {
6899 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (8 given)",
6900 ((PyCFunctionObject *)called)->m_ml->ml_name);
6901 return NULL;
6902 } else if (flags & METH_VARARGS) {
6903 // Recursion guard is not strictly necessary, as we already have
6904 // one on our way to here.
6905#ifdef _NUITKA_FULL_COMPAT
6906 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
6907 return NULL;
6908 }
6909#endif
6910 PyCFunction method = PyCFunction_GET_FUNCTION(called);
6911 PyObject *self = PyCFunction_GET_SELF(called);
6912
6913 PyObject *result;
6914
6915#if PYTHON_VERSION < 0x360
6916 if (flags & METH_KEYWORDS) {
6917 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6918 } else {
6919 result = (*method)(self, pos_args);
6920 }
6921
6922#else
6923 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
6924 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
6925 } else if (flags == METH_FASTCALL) {
6926#if PYTHON_VERSION < 0x370
6927 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 8, NULL);
6928#else
6929 result = (*(_PyCFunctionFast)method)(self, &pos_args, 8);
6930#endif
6931 } else {
6932 result = (*method)(self, pos_args);
6933 }
6934#endif
6935
6936#ifdef _NUITKA_FULL_COMPAT
6937 Py_LeaveRecursiveCall();
6938#endif
6939
6940 CHECK_OBJECT_X(result);
6941
6942 return Nuitka_CheckFunctionResult(tstate, called, result);
6943 }
6944#endif
6945#endif
6946#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
6947 } else if (PyFunction_Check(called)) {
6948#if PYTHON_VERSION < 0x3b0
6949 PyObject *result = callPythonFunction(called, args, 8);
6950#else
6951 PyObject *result = _PyFunction_Vectorcall(called, args, 8, NULL);
6952#endif
6953 CHECK_OBJECT_X(result);
6954
6955 return result;
6956#endif
6957#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
6958 } else if (PyType_Check(called)) {
6959 PyTypeObject *type = Py_TYPE(called);
6960
6961 if (type->tp_call == PyType_Type.tp_call) {
6962 PyTypeObject *called_type = (PyTypeObject *)(called);
6963
6964 if (unlikely(called_type->tp_new == NULL)) {
6965 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
6966 return NULL;
6967 }
6968
6969 PyObject *obj;
6970
6971 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
6972 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
6973 formatCannotInstantiateAbstractClass(tstate, called_type);
6974 return NULL;
6975 }
6976
6977 obj = called_type->tp_alloc(called_type, 0);
6978 CHECK_OBJECT(obj);
6979 } else {
6980 obj = called_type->tp_new(called_type, pos_args, NULL);
6981 }
6982
6983 if (likely(obj != NULL)) {
6984 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
6985 return obj;
6986 }
6987
6988 // Work on produced type.
6989 type = Py_TYPE(obj);
6990
6991 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
6992 if (type->tp_init == default_tp_init_wrapper) {
6993
6994 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
6995
6996 // Not really allowed, since we wouldn't have the default wrapper set.
6997 assert(init_method != NULL);
6998
6999 bool is_compiled_function = false;
7000 bool init_method_needs_release = false;
7001
7002 if (likely(init_method != NULL)) {
7003 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
7004
7005 if (func == Nuitka_Function_Type.tp_descr_get) {
7006 is_compiled_function = true;
7007 } else if (func != NULL) {
7008 init_method = func(init_method, obj, (PyObject *)(type));
7009 init_method_needs_release = true;
7010 }
7011 }
7012
7013 if (unlikely(init_method == NULL)) {
7014 if (!HAS_ERROR_OCCURRED(tstate)) {
7015 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
7016 const_str_plain___init__);
7017 }
7018
7019 return NULL;
7020 }
7021
7022 PyObject *result;
7023 if (is_compiled_function) {
7024 result = Nuitka_CallMethodFunctionPosArgs(
7025 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 8);
7026 } else {
7027 result = CALL_FUNCTION_WITH_POS_ARGS8(tstate, init_method, pos_args);
7028 if (init_method_needs_release) {
7029 Py_DECREF(init_method);
7030 }
7031 }
7032
7033 if (unlikely(result == NULL)) {
7034 Py_DECREF(obj);
7035 return NULL;
7036 }
7037
7038 Py_DECREF(result);
7039
7040 if (unlikely(result != Py_None)) {
7041 Py_DECREF(obj);
7042
7043 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
7044 return NULL;
7045 }
7046 } else {
7047
7048 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
7049 Py_DECREF(obj);
7050 return NULL;
7051 }
7052 }
7053 }
7054 }
7055
7056 CHECK_OBJECT_X(obj);
7057
7058 return obj;
7059 }
7060#endif
7061#if PYTHON_VERSION < 0x300
7062 } else if (PyClass_Check(called)) {
7063 PyObject *obj = PyInstance_NewRaw(called, NULL);
7064
7065 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
7066
7067 if (unlikely(init_method == NULL)) {
7068 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
7069 Py_DECREF(obj);
7070 return NULL;
7071 }
7072
7073 Py_DECREF(obj);
7074
7075 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
7076 return NULL;
7077 }
7078
7079 bool is_compiled_function = false;
7080
7081 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
7082
7083 if (descr_get == NULL) {
7084 Py_INCREF(init_method);
7085 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
7086 is_compiled_function = true;
7087 } else if (descr_get != NULL) {
7088 PyObject *descr_method = descr_get(init_method, obj, called);
7089
7090 if (unlikely(descr_method == NULL)) {
7091 return NULL;
7092 }
7093
7094 init_method = descr_method;
7095 }
7096
7097 PyObject *result;
7098 if (is_compiled_function) {
7099 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
7100 args, 8);
7101 } else {
7102 result = CALL_FUNCTION_WITH_POS_ARGS8(tstate, init_method, pos_args);
7103 Py_DECREF(init_method);
7104 }
7105 if (unlikely(result == NULL)) {
7106 return NULL;
7107 }
7108
7109 Py_DECREF(result);
7110
7111 if (unlikely(result != Py_None)) {
7112 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
7113 return NULL;
7114 }
7115
7116 CHECK_OBJECT_X(obj);
7117
7118 return obj;
7119#endif
7120#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
7121 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
7122 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7123
7124 if (likely(func != NULL)) {
7125 PyObject *result = func(called, args, 8, NULL);
7126
7127 CHECK_OBJECT_X(result);
7128
7129 return Nuitka_CheckFunctionResult(tstate, called, result);
7130 }
7131#endif
7132 }
7133
7134#if 0
7135 PRINT_NEW_LINE();
7136 PRINT_STRING("FALLBACK");
7137 PRINT_ITEM(called);
7138 PRINT_NEW_LINE();
7139#endif
7140
7141 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
7142
7143 CHECK_OBJECT_X(result);
7144
7145 return result;
7146}
7147PyObject *CALL_FUNCTION_WITH_ARGS9(PyThreadState *tstate, PyObject *called, PyObject *const *args) {
7148 CHECK_OBJECT(called);
7149 CHECK_OBJECTS(args, 9);
7150
7151 if (Nuitka_Function_Check(called)) {
7152 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
7153 return NULL;
7154 }
7155
7156 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
7157 PyObject *result;
7158
7159 if (function->m_args_simple && 9 == function->m_args_positional_count) {
7160 for (Py_ssize_t i = 0; i < 9; i++) {
7161 Py_INCREF(args[i]);
7162 }
7163 result = function->m_c_code(tstate, function, (PyObject **)args);
7164 } else if (function->m_args_simple && 9 + function->m_defaults_given == function->m_args_positional_count) {
7165 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7166
7167 memcpy(python_pars, args, 9 * sizeof(PyObject *));
7168 memcpy(python_pars + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7169 function->m_defaults_given * sizeof(PyObject *));
7170
7171 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
7172 Py_INCREF(python_pars[i]);
7173 }
7174
7175 result = function->m_c_code(tstate, function, python_pars);
7176 } else {
7177 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 9);
7178 }
7179
7180 Py_LeaveRecursiveCall();
7181
7182 CHECK_OBJECT_X(result);
7183
7184 return result;
7185 } else if (Nuitka_Method_Check(called)) {
7186 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
7187
7188 if (method->m_object == NULL) {
7189 PyObject *self = args[0];
7190
7191 int res = PyObject_IsInstance(self, method->m_class);
7192
7193 if (unlikely(res < 0)) {
7194 return NULL;
7195 } else if (unlikely(res == 0)) {
7196 PyErr_Format(PyExc_TypeError,
7197 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
7198 "instance instead)",
7199 GET_CALLABLE_NAME((PyObject *)method->m_function),
7200 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
7201 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
7202
7203 return NULL;
7204 }
7205
7206 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 9);
7207
7208 CHECK_OBJECT_X(result);
7209
7210 return result;
7211 } else {
7212 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
7213 return NULL;
7214 }
7215
7216 struct Nuitka_FunctionObject *function = method->m_function;
7217
7218 PyObject *result;
7219
7220 if (function->m_args_simple && 9 + 1 == function->m_args_positional_count) {
7221 PyObject *python_pars[9 + 1];
7222
7223 python_pars[0] = method->m_object;
7224 Py_INCREF(method->m_object);
7225
7226 for (Py_ssize_t i = 0; i < 9; i++) {
7227 python_pars[i + 1] = args[i];
7228 Py_INCREF(args[i]);
7229 }
7230 result = function->m_c_code(tstate, function, python_pars);
7231 } else if (function->m_args_simple &&
7232 9 + 1 + function->m_defaults_given == function->m_args_positional_count) {
7233 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7234
7235 python_pars[0] = method->m_object;
7236 Py_INCREF(method->m_object);
7237
7238 memcpy(python_pars + 1, args, 9 * sizeof(PyObject *));
7239 memcpy(python_pars + 1 + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7240 function->m_defaults_given * sizeof(PyObject *));
7241
7242 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
7243 Py_INCREF(python_pars[i]);
7244 }
7245
7246 result = function->m_c_code(tstate, function, python_pars);
7247 } else {
7248 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 9);
7249 }
7250
7251 Py_LeaveRecursiveCall();
7252
7253 CHECK_OBJECT_X(result);
7254
7255 return result;
7256 }
7257#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
7258 } else if (PyCFunction_CheckExact(called)) {
7259#if PYTHON_VERSION >= 0x380
7260#ifdef _NUITKA_FULL_COMPAT
7261 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
7262 return NULL;
7263 }
7264#endif
7265
7266 int flags = PyCFunction_GET_FLAGS(called);
7267
7268 PyObject *result;
7269
7270 if (!(flags & METH_VARARGS)) {
7271 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7272
7273 assert(func != NULL);
7274 result = func(called, args, 9, NULL);
7275
7276 CHECK_OBJECT_X(result);
7277 } else {
7278 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7279 PyObject *self = PyCFunction_GET_SELF(called);
7280
7281 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7282
7283 if (flags & METH_KEYWORDS) {
7284 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
7285 } else {
7286 result = (*method)(self, pos_args);
7287 }
7288
7289 Py_DECREF(pos_args);
7290 }
7291
7292#ifdef _NUITKA_FULL_COMPAT
7293 Py_LeaveRecursiveCall();
7294#endif
7295 CHECK_OBJECT_X(result);
7296
7297 return Nuitka_CheckFunctionResult(tstate, called, result);
7298#else
7299 // Try to be fast about wrapping the arguments.
7300 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
7301
7302 if (unlikely(flags & METH_NOARGS)) {
7303 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (9 given)",
7304 ((PyCFunctionObject *)called)->m_ml->ml_name);
7305 return NULL;
7306 } else if (unlikely(flags & METH_O)) {
7307 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (9 given)",
7308 ((PyCFunctionObject *)called)->m_ml->ml_name);
7309 return NULL;
7310 } else if (flags & METH_VARARGS) {
7311 // Recursion guard is not strictly necessary, as we already have
7312 // one on our way to here.
7313#ifdef _NUITKA_FULL_COMPAT
7314 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
7315 return NULL;
7316 }
7317#endif
7318 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7319 PyObject *self = PyCFunction_GET_SELF(called);
7320
7321 PyObject *result;
7322
7323#if PYTHON_VERSION < 0x360
7324 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7325 if (flags & METH_KEYWORDS) {
7326 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7327 } else {
7328 result = (*method)(self, pos_args);
7329 }
7330
7331 Py_DECREF(pos_args);
7332#else
7333 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
7334 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7335 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7336 Py_DECREF(pos_args);
7337 } else if (flags == METH_FASTCALL) {
7338#if PYTHON_VERSION < 0x370
7339 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 9, NULL);
7340#else
7341 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7342 result = (*(_PyCFunctionFast)method)(self, &pos_args, 9);
7343 Py_DECREF(pos_args);
7344#endif
7345 } else {
7346 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7347 result = (*method)(self, pos_args);
7348 Py_DECREF(pos_args);
7349 }
7350#endif
7351
7352#ifdef _NUITKA_FULL_COMPAT
7353 Py_LeaveRecursiveCall();
7354#endif
7355
7356 CHECK_OBJECT_X(result);
7357
7358 return Nuitka_CheckFunctionResult(tstate, called, result);
7359 }
7360#endif
7361#endif
7362#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
7363 } else if (PyFunction_Check(called)) {
7364#if PYTHON_VERSION < 0x3b0
7365 PyObject *result = callPythonFunction(called, args, 9);
7366#else
7367 PyObject *result = _PyFunction_Vectorcall(called, args, 9, NULL);
7368#endif
7369 CHECK_OBJECT_X(result);
7370
7371 return result;
7372#endif
7373#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
7374 } else if (PyType_Check(called)) {
7375 PyTypeObject *type = Py_TYPE(called);
7376
7377 if (type->tp_call == PyType_Type.tp_call) {
7378 PyTypeObject *called_type = (PyTypeObject *)(called);
7379
7380 if (unlikely(called_type->tp_new == NULL)) {
7381 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
7382 return NULL;
7383 }
7384
7385 PyObject *pos_args = NULL;
7386 PyObject *obj;
7387
7388 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
7389 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
7390 formatCannotInstantiateAbstractClass(tstate, called_type);
7391 return NULL;
7392 }
7393
7394 obj = called_type->tp_alloc(called_type, 0);
7395 CHECK_OBJECT(obj);
7396 } else {
7397 pos_args = MAKE_TUPLE(tstate, args, 9);
7398 obj = called_type->tp_new(called_type, pos_args, NULL);
7399 }
7400
7401 if (likely(obj != NULL)) {
7402 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
7403 Py_DECREF(pos_args);
7404 return obj;
7405 }
7406
7407 // Work on produced type.
7408 type = Py_TYPE(obj);
7409
7410 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
7411 if (type->tp_init == default_tp_init_wrapper) {
7412 Py_XDECREF(pos_args);
7413 pos_args = NULL;
7414
7415 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
7416
7417 // Not really allowed, since we wouldn't have the default wrapper set.
7418 assert(init_method != NULL);
7419
7420 bool is_compiled_function = false;
7421 bool init_method_needs_release = false;
7422
7423 if (likely(init_method != NULL)) {
7424 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
7425
7426 if (func == Nuitka_Function_Type.tp_descr_get) {
7427 is_compiled_function = true;
7428 } else if (func != NULL) {
7429 init_method = func(init_method, obj, (PyObject *)(type));
7430 init_method_needs_release = true;
7431 }
7432 }
7433
7434 if (unlikely(init_method == NULL)) {
7435 if (!HAS_ERROR_OCCURRED(tstate)) {
7436 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
7437 const_str_plain___init__);
7438 }
7439
7440 return NULL;
7441 }
7442
7443 PyObject *result;
7444 if (is_compiled_function) {
7445 result = Nuitka_CallMethodFunctionPosArgs(
7446 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 9);
7447 } else {
7448 result = CALL_FUNCTION_WITH_ARGS9(tstate, init_method, args);
7449 if (init_method_needs_release) {
7450 Py_DECREF(init_method);
7451 }
7452 }
7453
7454 if (unlikely(result == NULL)) {
7455 Py_DECREF(obj);
7456 return NULL;
7457 }
7458
7459 Py_DECREF(result);
7460
7461 if (unlikely(result != Py_None)) {
7462 Py_DECREF(obj);
7463
7464 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
7465 return NULL;
7466 }
7467 } else {
7468 if (pos_args == NULL) {
7469 pos_args = MAKE_TUPLE(tstate, args, 9);
7470 }
7471
7472 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
7473 Py_DECREF(obj);
7474 Py_XDECREF(pos_args);
7475 return NULL;
7476 }
7477 }
7478 }
7479 }
7480
7481 Py_XDECREF(pos_args);
7482
7483 CHECK_OBJECT_X(obj);
7484
7485 return obj;
7486 }
7487#endif
7488#if PYTHON_VERSION < 0x300
7489 } else if (PyClass_Check(called)) {
7490 PyObject *obj = PyInstance_NewRaw(called, NULL);
7491
7492 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
7493
7494 if (unlikely(init_method == NULL)) {
7495 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
7496 Py_DECREF(obj);
7497 return NULL;
7498 }
7499
7500 Py_DECREF(obj);
7501
7502 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
7503 return NULL;
7504 }
7505
7506 bool is_compiled_function = false;
7507
7508 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
7509
7510 if (descr_get == NULL) {
7511 Py_INCREF(init_method);
7512 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
7513 is_compiled_function = true;
7514 } else if (descr_get != NULL) {
7515 PyObject *descr_method = descr_get(init_method, obj, called);
7516
7517 if (unlikely(descr_method == NULL)) {
7518 return NULL;
7519 }
7520
7521 init_method = descr_method;
7522 }
7523
7524 PyObject *result;
7525 if (is_compiled_function) {
7526 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
7527 args, 9);
7528 } else {
7529 result = CALL_FUNCTION_WITH_ARGS9(tstate, init_method, args);
7530 Py_DECREF(init_method);
7531 }
7532 if (unlikely(result == NULL)) {
7533 return NULL;
7534 }
7535
7536 Py_DECREF(result);
7537
7538 if (unlikely(result != Py_None)) {
7539 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
7540 return NULL;
7541 }
7542
7543 CHECK_OBJECT_X(obj);
7544
7545 return obj;
7546#endif
7547#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
7548 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
7549 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7550
7551 if (likely(func != NULL)) {
7552 PyObject *result = func(called, args, 9, NULL);
7553
7554 CHECK_OBJECT_X(result);
7555
7556 return Nuitka_CheckFunctionResult(tstate, called, result);
7557 }
7558#endif
7559 }
7560
7561#if 0
7562 PRINT_NEW_LINE();
7563 PRINT_STRING("FALLBACK");
7564 PRINT_ITEM(called);
7565 PRINT_NEW_LINE();
7566#endif
7567
7568 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
7569
7570 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
7571
7572 Py_DECREF(pos_args);
7573
7574 CHECK_OBJECT_X(result);
7575
7576 return result;
7577}
7578PyObject *CALL_FUNCTION_WITH_POS_ARGS9(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
7579 assert(PyTuple_CheckExact(pos_args));
7580 assert(PyTuple_GET_SIZE(pos_args) == 9);
7581 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
7582 CHECK_OBJECT(called);
7583 CHECK_OBJECTS(args, 9);
7584
7585 if (Nuitka_Function_Check(called)) {
7586 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
7587 return NULL;
7588 }
7589
7590 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
7591 PyObject *result;
7592
7593 if (function->m_args_simple && 9 == function->m_args_positional_count) {
7594 for (Py_ssize_t i = 0; i < 9; i++) {
7595 Py_INCREF(args[i]);
7596 }
7597 result = function->m_c_code(tstate, function, (PyObject **)args);
7598 } else if (function->m_args_simple && 9 + function->m_defaults_given == function->m_args_positional_count) {
7599 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7600
7601 memcpy(python_pars, args, 9 * sizeof(PyObject *));
7602 memcpy(python_pars + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7603 function->m_defaults_given * sizeof(PyObject *));
7604
7605 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
7606 Py_INCREF(python_pars[i]);
7607 }
7608
7609 result = function->m_c_code(tstate, function, python_pars);
7610 } else {
7611 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 9);
7612 }
7613
7614 Py_LeaveRecursiveCall();
7615
7616 CHECK_OBJECT_X(result);
7617
7618 return result;
7619 } else if (Nuitka_Method_Check(called)) {
7620 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
7621
7622 if (method->m_object == NULL) {
7623 PyObject *self = args[0];
7624
7625 int res = PyObject_IsInstance(self, method->m_class);
7626
7627 if (unlikely(res < 0)) {
7628 return NULL;
7629 } else if (unlikely(res == 0)) {
7630 PyErr_Format(PyExc_TypeError,
7631 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
7632 "instance instead)",
7633 GET_CALLABLE_NAME((PyObject *)method->m_function),
7634 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
7635 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
7636
7637 return NULL;
7638 }
7639
7640 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 9);
7641
7642 CHECK_OBJECT_X(result);
7643
7644 return result;
7645 } else {
7646 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
7647 return NULL;
7648 }
7649
7650 struct Nuitka_FunctionObject *function = method->m_function;
7651
7652 PyObject *result;
7653
7654 if (function->m_args_simple && 9 + 1 == function->m_args_positional_count) {
7655 PyObject *python_pars[9 + 1];
7656
7657 python_pars[0] = method->m_object;
7658 Py_INCREF(method->m_object);
7659
7660 for (Py_ssize_t i = 0; i < 9; i++) {
7661 python_pars[i + 1] = args[i];
7662 Py_INCREF(args[i]);
7663 }
7664 result = function->m_c_code(tstate, function, python_pars);
7665 } else if (function->m_args_simple &&
7666 9 + 1 + function->m_defaults_given == function->m_args_positional_count) {
7667 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
7668
7669 python_pars[0] = method->m_object;
7670 Py_INCREF(method->m_object);
7671
7672 memcpy(python_pars + 1, args, 9 * sizeof(PyObject *));
7673 memcpy(python_pars + 1 + 9, &PyTuple_GET_ITEM(function->m_defaults, 0),
7674 function->m_defaults_given * sizeof(PyObject *));
7675
7676 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
7677 Py_INCREF(python_pars[i]);
7678 }
7679
7680 result = function->m_c_code(tstate, function, python_pars);
7681 } else {
7682 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 9);
7683 }
7684
7685 Py_LeaveRecursiveCall();
7686
7687 CHECK_OBJECT_X(result);
7688
7689 return result;
7690 }
7691#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
7692 } else if (PyCFunction_CheckExact(called)) {
7693#if PYTHON_VERSION >= 0x380
7694#ifdef _NUITKA_FULL_COMPAT
7695 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
7696 return NULL;
7697 }
7698#endif
7699
7700 int flags = PyCFunction_GET_FLAGS(called);
7701
7702 PyObject *result;
7703
7704 if (!(flags & METH_VARARGS)) {
7705 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7706
7707 assert(func != NULL);
7708 result = func(called, args, 9, NULL);
7709
7710 CHECK_OBJECT_X(result);
7711 } else {
7712 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7713 PyObject *self = PyCFunction_GET_SELF(called);
7714
7715 if (flags & METH_KEYWORDS) {
7716 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
7717 } else {
7718 result = (*method)(self, pos_args);
7719 }
7720 }
7721
7722#ifdef _NUITKA_FULL_COMPAT
7723 Py_LeaveRecursiveCall();
7724#endif
7725 CHECK_OBJECT_X(result);
7726
7727 return Nuitka_CheckFunctionResult(tstate, called, result);
7728#else
7729 // Try to be fast about wrapping the arguments.
7730 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
7731
7732 if (unlikely(flags & METH_NOARGS)) {
7733 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (9 given)",
7734 ((PyCFunctionObject *)called)->m_ml->ml_name);
7735 return NULL;
7736 } else if (unlikely(flags & METH_O)) {
7737 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (9 given)",
7738 ((PyCFunctionObject *)called)->m_ml->ml_name);
7739 return NULL;
7740 } else if (flags & METH_VARARGS) {
7741 // Recursion guard is not strictly necessary, as we already have
7742 // one on our way to here.
7743#ifdef _NUITKA_FULL_COMPAT
7744 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
7745 return NULL;
7746 }
7747#endif
7748 PyCFunction method = PyCFunction_GET_FUNCTION(called);
7749 PyObject *self = PyCFunction_GET_SELF(called);
7750
7751 PyObject *result;
7752
7753#if PYTHON_VERSION < 0x360
7754 if (flags & METH_KEYWORDS) {
7755 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7756 } else {
7757 result = (*method)(self, pos_args);
7758 }
7759
7760#else
7761 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
7762 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
7763 } else if (flags == METH_FASTCALL) {
7764#if PYTHON_VERSION < 0x370
7765 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 9, NULL);
7766#else
7767 result = (*(_PyCFunctionFast)method)(self, &pos_args, 9);
7768#endif
7769 } else {
7770 result = (*method)(self, pos_args);
7771 }
7772#endif
7773
7774#ifdef _NUITKA_FULL_COMPAT
7775 Py_LeaveRecursiveCall();
7776#endif
7777
7778 CHECK_OBJECT_X(result);
7779
7780 return Nuitka_CheckFunctionResult(tstate, called, result);
7781 }
7782#endif
7783#endif
7784#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
7785 } else if (PyFunction_Check(called)) {
7786#if PYTHON_VERSION < 0x3b0
7787 PyObject *result = callPythonFunction(called, args, 9);
7788#else
7789 PyObject *result = _PyFunction_Vectorcall(called, args, 9, NULL);
7790#endif
7791 CHECK_OBJECT_X(result);
7792
7793 return result;
7794#endif
7795#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
7796 } else if (PyType_Check(called)) {
7797 PyTypeObject *type = Py_TYPE(called);
7798
7799 if (type->tp_call == PyType_Type.tp_call) {
7800 PyTypeObject *called_type = (PyTypeObject *)(called);
7801
7802 if (unlikely(called_type->tp_new == NULL)) {
7803 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
7804 return NULL;
7805 }
7806
7807 PyObject *obj;
7808
7809 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
7810 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
7811 formatCannotInstantiateAbstractClass(tstate, called_type);
7812 return NULL;
7813 }
7814
7815 obj = called_type->tp_alloc(called_type, 0);
7816 CHECK_OBJECT(obj);
7817 } else {
7818 obj = called_type->tp_new(called_type, pos_args, NULL);
7819 }
7820
7821 if (likely(obj != NULL)) {
7822 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
7823 return obj;
7824 }
7825
7826 // Work on produced type.
7827 type = Py_TYPE(obj);
7828
7829 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
7830 if (type->tp_init == default_tp_init_wrapper) {
7831
7832 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
7833
7834 // Not really allowed, since we wouldn't have the default wrapper set.
7835 assert(init_method != NULL);
7836
7837 bool is_compiled_function = false;
7838 bool init_method_needs_release = false;
7839
7840 if (likely(init_method != NULL)) {
7841 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
7842
7843 if (func == Nuitka_Function_Type.tp_descr_get) {
7844 is_compiled_function = true;
7845 } else if (func != NULL) {
7846 init_method = func(init_method, obj, (PyObject *)(type));
7847 init_method_needs_release = true;
7848 }
7849 }
7850
7851 if (unlikely(init_method == NULL)) {
7852 if (!HAS_ERROR_OCCURRED(tstate)) {
7853 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
7854 const_str_plain___init__);
7855 }
7856
7857 return NULL;
7858 }
7859
7860 PyObject *result;
7861 if (is_compiled_function) {
7862 result = Nuitka_CallMethodFunctionPosArgs(
7863 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 9);
7864 } else {
7865 result = CALL_FUNCTION_WITH_POS_ARGS9(tstate, init_method, pos_args);
7866 if (init_method_needs_release) {
7867 Py_DECREF(init_method);
7868 }
7869 }
7870
7871 if (unlikely(result == NULL)) {
7872 Py_DECREF(obj);
7873 return NULL;
7874 }
7875
7876 Py_DECREF(result);
7877
7878 if (unlikely(result != Py_None)) {
7879 Py_DECREF(obj);
7880
7881 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
7882 return NULL;
7883 }
7884 } else {
7885
7886 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
7887 Py_DECREF(obj);
7888 return NULL;
7889 }
7890 }
7891 }
7892 }
7893
7894 CHECK_OBJECT_X(obj);
7895
7896 return obj;
7897 }
7898#endif
7899#if PYTHON_VERSION < 0x300
7900 } else if (PyClass_Check(called)) {
7901 PyObject *obj = PyInstance_NewRaw(called, NULL);
7902
7903 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
7904
7905 if (unlikely(init_method == NULL)) {
7906 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
7907 Py_DECREF(obj);
7908 return NULL;
7909 }
7910
7911 Py_DECREF(obj);
7912
7913 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
7914 return NULL;
7915 }
7916
7917 bool is_compiled_function = false;
7918
7919 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
7920
7921 if (descr_get == NULL) {
7922 Py_INCREF(init_method);
7923 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
7924 is_compiled_function = true;
7925 } else if (descr_get != NULL) {
7926 PyObject *descr_method = descr_get(init_method, obj, called);
7927
7928 if (unlikely(descr_method == NULL)) {
7929 return NULL;
7930 }
7931
7932 init_method = descr_method;
7933 }
7934
7935 PyObject *result;
7936 if (is_compiled_function) {
7937 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
7938 args, 9);
7939 } else {
7940 result = CALL_FUNCTION_WITH_POS_ARGS9(tstate, init_method, pos_args);
7941 Py_DECREF(init_method);
7942 }
7943 if (unlikely(result == NULL)) {
7944 return NULL;
7945 }
7946
7947 Py_DECREF(result);
7948
7949 if (unlikely(result != Py_None)) {
7950 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
7951 return NULL;
7952 }
7953
7954 CHECK_OBJECT_X(obj);
7955
7956 return obj;
7957#endif
7958#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
7959 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
7960 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
7961
7962 if (likely(func != NULL)) {
7963 PyObject *result = func(called, args, 9, NULL);
7964
7965 CHECK_OBJECT_X(result);
7966
7967 return Nuitka_CheckFunctionResult(tstate, called, result);
7968 }
7969#endif
7970 }
7971
7972#if 0
7973 PRINT_NEW_LINE();
7974 PRINT_STRING("FALLBACK");
7975 PRINT_ITEM(called);
7976 PRINT_NEW_LINE();
7977#endif
7978
7979 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
7980
7981 CHECK_OBJECT_X(result);
7982
7983 return result;
7984}
7985PyObject *CALL_FUNCTION_WITH_ARGS10(PyThreadState *tstate, PyObject *called, PyObject *const *args) {
7986 CHECK_OBJECT(called);
7987 CHECK_OBJECTS(args, 10);
7988
7989 if (Nuitka_Function_Check(called)) {
7990 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
7991 return NULL;
7992 }
7993
7994 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
7995 PyObject *result;
7996
7997 if (function->m_args_simple && 10 == function->m_args_positional_count) {
7998 for (Py_ssize_t i = 0; i < 10; i++) {
7999 Py_INCREF(args[i]);
8000 }
8001 result = function->m_c_code(tstate, function, (PyObject **)args);
8002 } else if (function->m_args_simple && 10 + function->m_defaults_given == function->m_args_positional_count) {
8003 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8004
8005 memcpy(python_pars, args, 10 * sizeof(PyObject *));
8006 memcpy(python_pars + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8007 function->m_defaults_given * sizeof(PyObject *));
8008
8009 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
8010 Py_INCREF(python_pars[i]);
8011 }
8012
8013 result = function->m_c_code(tstate, function, python_pars);
8014 } else {
8015 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 10);
8016 }
8017
8018 Py_LeaveRecursiveCall();
8019
8020 CHECK_OBJECT_X(result);
8021
8022 return result;
8023 } else if (Nuitka_Method_Check(called)) {
8024 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
8025
8026 if (method->m_object == NULL) {
8027 PyObject *self = args[0];
8028
8029 int res = PyObject_IsInstance(self, method->m_class);
8030
8031 if (unlikely(res < 0)) {
8032 return NULL;
8033 } else if (unlikely(res == 0)) {
8034 PyErr_Format(PyExc_TypeError,
8035 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
8036 "instance instead)",
8037 GET_CALLABLE_NAME((PyObject *)method->m_function),
8038 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
8039 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
8040
8041 return NULL;
8042 }
8043
8044 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 10);
8045
8046 CHECK_OBJECT_X(result);
8047
8048 return result;
8049 } else {
8050 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
8051 return NULL;
8052 }
8053
8054 struct Nuitka_FunctionObject *function = method->m_function;
8055
8056 PyObject *result;
8057
8058 if (function->m_args_simple && 10 + 1 == function->m_args_positional_count) {
8059 PyObject *python_pars[10 + 1];
8060
8061 python_pars[0] = method->m_object;
8062 Py_INCREF(method->m_object);
8063
8064 for (Py_ssize_t i = 0; i < 10; i++) {
8065 python_pars[i + 1] = args[i];
8066 Py_INCREF(args[i]);
8067 }
8068 result = function->m_c_code(tstate, function, python_pars);
8069 } else if (function->m_args_simple &&
8070 10 + 1 + function->m_defaults_given == function->m_args_positional_count) {
8071 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8072
8073 python_pars[0] = method->m_object;
8074 Py_INCREF(method->m_object);
8075
8076 memcpy(python_pars + 1, args, 10 * sizeof(PyObject *));
8077 memcpy(python_pars + 1 + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8078 function->m_defaults_given * sizeof(PyObject *));
8079
8080 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
8081 Py_INCREF(python_pars[i]);
8082 }
8083
8084 result = function->m_c_code(tstate, function, python_pars);
8085 } else {
8086 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 10);
8087 }
8088
8089 Py_LeaveRecursiveCall();
8090
8091 CHECK_OBJECT_X(result);
8092
8093 return result;
8094 }
8095#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
8096 } else if (PyCFunction_CheckExact(called)) {
8097#if PYTHON_VERSION >= 0x380
8098#ifdef _NUITKA_FULL_COMPAT
8099 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
8100 return NULL;
8101 }
8102#endif
8103
8104 int flags = PyCFunction_GET_FLAGS(called);
8105
8106 PyObject *result;
8107
8108 if (!(flags & METH_VARARGS)) {
8109 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8110
8111 assert(func != NULL);
8112 result = func(called, args, 10, NULL);
8113
8114 CHECK_OBJECT_X(result);
8115 } else {
8116 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8117 PyObject *self = PyCFunction_GET_SELF(called);
8118
8119 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8120
8121 if (flags & METH_KEYWORDS) {
8122 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
8123 } else {
8124 result = (*method)(self, pos_args);
8125 }
8126
8127 Py_DECREF(pos_args);
8128 }
8129
8130#ifdef _NUITKA_FULL_COMPAT
8131 Py_LeaveRecursiveCall();
8132#endif
8133 CHECK_OBJECT_X(result);
8134
8135 return Nuitka_CheckFunctionResult(tstate, called, result);
8136#else
8137 // Try to be fast about wrapping the arguments.
8138 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
8139
8140 if (unlikely(flags & METH_NOARGS)) {
8141 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (10 given)",
8142 ((PyCFunctionObject *)called)->m_ml->ml_name);
8143 return NULL;
8144 } else if (unlikely(flags & METH_O)) {
8145 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (10 given)",
8146 ((PyCFunctionObject *)called)->m_ml->ml_name);
8147 return NULL;
8148 } else if (flags & METH_VARARGS) {
8149 // Recursion guard is not strictly necessary, as we already have
8150 // one on our way to here.
8151#ifdef _NUITKA_FULL_COMPAT
8152 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
8153 return NULL;
8154 }
8155#endif
8156 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8157 PyObject *self = PyCFunction_GET_SELF(called);
8158
8159 PyObject *result;
8160
8161#if PYTHON_VERSION < 0x360
8162 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8163 if (flags & METH_KEYWORDS) {
8164 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8165 } else {
8166 result = (*method)(self, pos_args);
8167 }
8168
8169 Py_DECREF(pos_args);
8170#else
8171 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
8172 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8173 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8174 Py_DECREF(pos_args);
8175 } else if (flags == METH_FASTCALL) {
8176#if PYTHON_VERSION < 0x370
8177 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 10, NULL);
8178#else
8179 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8180 result = (*(_PyCFunctionFast)method)(self, &pos_args, 10);
8181 Py_DECREF(pos_args);
8182#endif
8183 } else {
8184 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8185 result = (*method)(self, pos_args);
8186 Py_DECREF(pos_args);
8187 }
8188#endif
8189
8190#ifdef _NUITKA_FULL_COMPAT
8191 Py_LeaveRecursiveCall();
8192#endif
8193
8194 CHECK_OBJECT_X(result);
8195
8196 return Nuitka_CheckFunctionResult(tstate, called, result);
8197 }
8198#endif
8199#endif
8200#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
8201 } else if (PyFunction_Check(called)) {
8202#if PYTHON_VERSION < 0x3b0
8203 PyObject *result = callPythonFunction(called, args, 10);
8204#else
8205 PyObject *result = _PyFunction_Vectorcall(called, args, 10, NULL);
8206#endif
8207 CHECK_OBJECT_X(result);
8208
8209 return result;
8210#endif
8211#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
8212 } else if (PyType_Check(called)) {
8213 PyTypeObject *type = Py_TYPE(called);
8214
8215 if (type->tp_call == PyType_Type.tp_call) {
8216 PyTypeObject *called_type = (PyTypeObject *)(called);
8217
8218 if (unlikely(called_type->tp_new == NULL)) {
8219 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
8220 return NULL;
8221 }
8222
8223 PyObject *pos_args = NULL;
8224 PyObject *obj;
8225
8226 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
8227 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
8228 formatCannotInstantiateAbstractClass(tstate, called_type);
8229 return NULL;
8230 }
8231
8232 obj = called_type->tp_alloc(called_type, 0);
8233 CHECK_OBJECT(obj);
8234 } else {
8235 pos_args = MAKE_TUPLE(tstate, args, 10);
8236 obj = called_type->tp_new(called_type, pos_args, NULL);
8237 }
8238
8239 if (likely(obj != NULL)) {
8240 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
8241 Py_DECREF(pos_args);
8242 return obj;
8243 }
8244
8245 // Work on produced type.
8246 type = Py_TYPE(obj);
8247
8248 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
8249 if (type->tp_init == default_tp_init_wrapper) {
8250 Py_XDECREF(pos_args);
8251 pos_args = NULL;
8252
8253 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
8254
8255 // Not really allowed, since we wouldn't have the default wrapper set.
8256 assert(init_method != NULL);
8257
8258 bool is_compiled_function = false;
8259 bool init_method_needs_release = false;
8260
8261 if (likely(init_method != NULL)) {
8262 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
8263
8264 if (func == Nuitka_Function_Type.tp_descr_get) {
8265 is_compiled_function = true;
8266 } else if (func != NULL) {
8267 init_method = func(init_method, obj, (PyObject *)(type));
8268 init_method_needs_release = true;
8269 }
8270 }
8271
8272 if (unlikely(init_method == NULL)) {
8273 if (!HAS_ERROR_OCCURRED(tstate)) {
8274 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
8275 const_str_plain___init__);
8276 }
8277
8278 return NULL;
8279 }
8280
8281 PyObject *result;
8282 if (is_compiled_function) {
8283 result = Nuitka_CallMethodFunctionPosArgs(
8284 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 10);
8285 } else {
8286 result = CALL_FUNCTION_WITH_ARGS10(tstate, init_method, args);
8287 if (init_method_needs_release) {
8288 Py_DECREF(init_method);
8289 }
8290 }
8291
8292 if (unlikely(result == NULL)) {
8293 Py_DECREF(obj);
8294 return NULL;
8295 }
8296
8297 Py_DECREF(result);
8298
8299 if (unlikely(result != Py_None)) {
8300 Py_DECREF(obj);
8301
8302 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
8303 return NULL;
8304 }
8305 } else {
8306 if (pos_args == NULL) {
8307 pos_args = MAKE_TUPLE(tstate, args, 10);
8308 }
8309
8310 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
8311 Py_DECREF(obj);
8312 Py_XDECREF(pos_args);
8313 return NULL;
8314 }
8315 }
8316 }
8317 }
8318
8319 Py_XDECREF(pos_args);
8320
8321 CHECK_OBJECT_X(obj);
8322
8323 return obj;
8324 }
8325#endif
8326#if PYTHON_VERSION < 0x300
8327 } else if (PyClass_Check(called)) {
8328 PyObject *obj = PyInstance_NewRaw(called, NULL);
8329
8330 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
8331
8332 if (unlikely(init_method == NULL)) {
8333 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
8334 Py_DECREF(obj);
8335 return NULL;
8336 }
8337
8338 Py_DECREF(obj);
8339
8340 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
8341 return NULL;
8342 }
8343
8344 bool is_compiled_function = false;
8345
8346 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
8347
8348 if (descr_get == NULL) {
8349 Py_INCREF(init_method);
8350 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
8351 is_compiled_function = true;
8352 } else if (descr_get != NULL) {
8353 PyObject *descr_method = descr_get(init_method, obj, called);
8354
8355 if (unlikely(descr_method == NULL)) {
8356 return NULL;
8357 }
8358
8359 init_method = descr_method;
8360 }
8361
8362 PyObject *result;
8363 if (is_compiled_function) {
8364 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
8365 args, 10);
8366 } else {
8367 result = CALL_FUNCTION_WITH_ARGS10(tstate, init_method, args);
8368 Py_DECREF(init_method);
8369 }
8370 if (unlikely(result == NULL)) {
8371 return NULL;
8372 }
8373
8374 Py_DECREF(result);
8375
8376 if (unlikely(result != Py_None)) {
8377 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
8378 return NULL;
8379 }
8380
8381 CHECK_OBJECT_X(obj);
8382
8383 return obj;
8384#endif
8385#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8386 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8387 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8388
8389 if (likely(func != NULL)) {
8390 PyObject *result = func(called, args, 10, NULL);
8391
8392 CHECK_OBJECT_X(result);
8393
8394 return Nuitka_CheckFunctionResult(tstate, called, result);
8395 }
8396#endif
8397 }
8398
8399#if 0
8400 PRINT_NEW_LINE();
8401 PRINT_STRING("FALLBACK");
8402 PRINT_ITEM(called);
8403 PRINT_NEW_LINE();
8404#endif
8405
8406 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
8407
8408 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
8409
8410 Py_DECREF(pos_args);
8411
8412 CHECK_OBJECT_X(result);
8413
8414 return result;
8415}
8416PyObject *CALL_FUNCTION_WITH_POS_ARGS10(PyThreadState *tstate, PyObject *called, PyObject *pos_args) {
8417 assert(PyTuple_CheckExact(pos_args));
8418 assert(PyTuple_GET_SIZE(pos_args) == 10);
8419 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
8420 CHECK_OBJECT(called);
8421 CHECK_OBJECTS(args, 10);
8422
8423 if (Nuitka_Function_Check(called)) {
8424 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
8425 return NULL;
8426 }
8427
8428 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
8429 PyObject *result;
8430
8431 if (function->m_args_simple && 10 == function->m_args_positional_count) {
8432 for (Py_ssize_t i = 0; i < 10; i++) {
8433 Py_INCREF(args[i]);
8434 }
8435 result = function->m_c_code(tstate, function, (PyObject **)args);
8436 } else if (function->m_args_simple && 10 + function->m_defaults_given == function->m_args_positional_count) {
8437 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8438
8439 memcpy(python_pars, args, 10 * sizeof(PyObject *));
8440 memcpy(python_pars + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8441 function->m_defaults_given * sizeof(PyObject *));
8442
8443 for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) {
8444 Py_INCREF(python_pars[i]);
8445 }
8446
8447 result = function->m_c_code(tstate, function, python_pars);
8448 } else {
8449 result = Nuitka_CallFunctionPosArgs(tstate, function, args, 10);
8450 }
8451
8452 Py_LeaveRecursiveCall();
8453
8454 CHECK_OBJECT_X(result);
8455
8456 return result;
8457 } else if (Nuitka_Method_Check(called)) {
8458 struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called;
8459
8460 if (method->m_object == NULL) {
8461 PyObject *self = args[0];
8462
8463 int res = PyObject_IsInstance(self, method->m_class);
8464
8465 if (unlikely(res < 0)) {
8466 return NULL;
8467 } else if (unlikely(res == 0)) {
8468 PyErr_Format(PyExc_TypeError,
8469 "unbound compiled_method %s%s must be called with %s instance as first argument (got %s "
8470 "instance instead)",
8471 GET_CALLABLE_NAME((PyObject *)method->m_function),
8472 GET_CALLABLE_DESC((PyObject *)method->m_function), GET_CLASS_NAME(method->m_class),
8473 GET_INSTANCE_CLASS_NAME(tstate, (PyObject *)self));
8474
8475 return NULL;
8476 }
8477
8478 PyObject *result = Nuitka_CallFunctionPosArgs(tstate, method->m_function, args, 10);
8479
8480 CHECK_OBJECT_X(result);
8481
8482 return result;
8483 } else {
8484 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
8485 return NULL;
8486 }
8487
8488 struct Nuitka_FunctionObject *function = method->m_function;
8489
8490 PyObject *result;
8491
8492 if (function->m_args_simple && 10 + 1 == function->m_args_positional_count) {
8493 PyObject *python_pars[10 + 1];
8494
8495 python_pars[0] = method->m_object;
8496 Py_INCREF(method->m_object);
8497
8498 for (Py_ssize_t i = 0; i < 10; i++) {
8499 python_pars[i + 1] = args[i];
8500 Py_INCREF(args[i]);
8501 }
8502 result = function->m_c_code(tstate, function, python_pars);
8503 } else if (function->m_args_simple &&
8504 10 + 1 + function->m_defaults_given == function->m_args_positional_count) {
8505 NUITKA_DYNAMIC_ARRAY_DECL(python_pars, PyObject *, function->m_args_positional_count);
8506
8507 python_pars[0] = method->m_object;
8508 Py_INCREF(method->m_object);
8509
8510 memcpy(python_pars + 1, args, 10 * sizeof(PyObject *));
8511 memcpy(python_pars + 1 + 10, &PyTuple_GET_ITEM(function->m_defaults, 0),
8512 function->m_defaults_given * sizeof(PyObject *));
8513
8514 for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) {
8515 Py_INCREF(python_pars[i]);
8516 }
8517
8518 result = function->m_c_code(tstate, function, python_pars);
8519 } else {
8520 result = Nuitka_CallMethodFunctionPosArgs(tstate, function, method->m_object, args, 10);
8521 }
8522
8523 Py_LeaveRecursiveCall();
8524
8525 CHECK_OBJECT_X(result);
8526
8527 return result;
8528 }
8529#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_CFUNCTION_CALL_OPT)
8530 } else if (PyCFunction_CheckExact(called)) {
8531#if PYTHON_VERSION >= 0x380
8532#ifdef _NUITKA_FULL_COMPAT
8533 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
8534 return NULL;
8535 }
8536#endif
8537
8538 int flags = PyCFunction_GET_FLAGS(called);
8539
8540 PyObject *result;
8541
8542 if (!(flags & METH_VARARGS)) {
8543 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8544
8545 assert(func != NULL);
8546 result = func(called, args, 10, NULL);
8547
8548 CHECK_OBJECT_X(result);
8549 } else {
8550 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8551 PyObject *self = PyCFunction_GET_SELF(called);
8552
8553 if (flags & METH_KEYWORDS) {
8554 result = (*(PyCFunctionWithKeywords)(void (*)(void))method)(self, pos_args, NULL);
8555 } else {
8556 result = (*method)(self, pos_args);
8557 }
8558 }
8559
8560#ifdef _NUITKA_FULL_COMPAT
8561 Py_LeaveRecursiveCall();
8562#endif
8563 CHECK_OBJECT_X(result);
8564
8565 return Nuitka_CheckFunctionResult(tstate, called, result);
8566#else
8567 // Try to be fast about wrapping the arguments.
8568 int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
8569
8570 if (unlikely(flags & METH_NOARGS)) {
8571 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes no arguments (10 given)",
8572 ((PyCFunctionObject *)called)->m_ml->ml_name);
8573 return NULL;
8574 } else if (unlikely(flags & METH_O)) {
8575 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (10 given)",
8576 ((PyCFunctionObject *)called)->m_ml->ml_name);
8577 return NULL;
8578 } else if (flags & METH_VARARGS) {
8579 // Recursion guard is not strictly necessary, as we already have
8580 // one on our way to here.
8581#ifdef _NUITKA_FULL_COMPAT
8582 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
8583 return NULL;
8584 }
8585#endif
8586 PyCFunction method = PyCFunction_GET_FUNCTION(called);
8587 PyObject *self = PyCFunction_GET_SELF(called);
8588
8589 PyObject *result;
8590
8591#if PYTHON_VERSION < 0x360
8592 if (flags & METH_KEYWORDS) {
8593 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8594 } else {
8595 result = (*method)(self, pos_args);
8596 }
8597
8598#else
8599 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
8600 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
8601 } else if (flags == METH_FASTCALL) {
8602#if PYTHON_VERSION < 0x370
8603 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args, 10, NULL);
8604#else
8605 result = (*(_PyCFunctionFast)method)(self, &pos_args, 10);
8606#endif
8607 } else {
8608 result = (*method)(self, pos_args);
8609 }
8610#endif
8611
8612#ifdef _NUITKA_FULL_COMPAT
8613 Py_LeaveRecursiveCall();
8614#endif
8615
8616 CHECK_OBJECT_X(result);
8617
8618 return Nuitka_CheckFunctionResult(tstate, called, result);
8619 }
8620#endif
8621#endif
8622#if PYTHON_VERSION < 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_UNCOMPILED_FUNCTION_CALL_OPT)
8623 } else if (PyFunction_Check(called)) {
8624#if PYTHON_VERSION < 0x3b0
8625 PyObject *result = callPythonFunction(called, args, 10);
8626#else
8627 PyObject *result = _PyFunction_Vectorcall(called, args, 10, NULL);
8628#endif
8629 CHECK_OBJECT_X(result);
8630
8631 return result;
8632#endif
8633#if !defined(_NUITKA_EXPERIMENTAL_DISABLE_TYPE_CREATION_OPT)
8634 } else if (PyType_Check(called)) {
8635 PyTypeObject *type = Py_TYPE(called);
8636
8637 if (type->tp_call == PyType_Type.tp_call) {
8638 PyTypeObject *called_type = (PyTypeObject *)(called);
8639
8640 if (unlikely(called_type->tp_new == NULL)) {
8641 PyErr_Format(PyExc_TypeError, "cannot create '%s' instances", called_type->tp_name);
8642 return NULL;
8643 }
8644
8645 PyObject *obj;
8646
8647 if (called_type->tp_new == PyBaseObject_Type.tp_new) {
8648 if (unlikely(called_type->tp_flags & Py_TPFLAGS_IS_ABSTRACT)) {
8649 formatCannotInstantiateAbstractClass(tstate, called_type);
8650 return NULL;
8651 }
8652
8653 obj = called_type->tp_alloc(called_type, 0);
8654 CHECK_OBJECT(obj);
8655 } else {
8656 obj = called_type->tp_new(called_type, pos_args, NULL);
8657 }
8658
8659 if (likely(obj != NULL)) {
8660 if (!Nuitka_Type_IsSubtype(obj->ob_type, called_type)) {
8661 return obj;
8662 }
8663
8664 // Work on produced type.
8665 type = Py_TYPE(obj);
8666
8667 if (NuitkaType_HasFeatureClass(type) && type->tp_init != NULL) {
8668 if (type->tp_init == default_tp_init_wrapper) {
8669
8670 PyObject *init_method = Nuitka_TypeLookup(type, const_str_plain___init__);
8671
8672 // Not really allowed, since we wouldn't have the default wrapper set.
8673 assert(init_method != NULL);
8674
8675 bool is_compiled_function = false;
8676 bool init_method_needs_release = false;
8677
8678 if (likely(init_method != NULL)) {
8679 descrgetfunc func = Py_TYPE(init_method)->tp_descr_get;
8680
8681 if (func == Nuitka_Function_Type.tp_descr_get) {
8682 is_compiled_function = true;
8683 } else if (func != NULL) {
8684 init_method = func(init_method, obj, (PyObject *)(type));
8685 init_method_needs_release = true;
8686 }
8687 }
8688
8689 if (unlikely(init_method == NULL)) {
8690 if (!HAS_ERROR_OCCURRED(tstate)) {
8691 SET_CURRENT_EXCEPTION_TYPE0_VALUE0(tstate, PyExc_AttributeError,
8692 const_str_plain___init__);
8693 }
8694
8695 return NULL;
8696 }
8697
8698 PyObject *result;
8699 if (is_compiled_function) {
8700 result = Nuitka_CallMethodFunctionPosArgs(
8701 tstate, (struct Nuitka_FunctionObject const *)init_method, obj, args, 10);
8702 } else {
8703 result = CALL_FUNCTION_WITH_POS_ARGS10(tstate, init_method, pos_args);
8704 if (init_method_needs_release) {
8705 Py_DECREF(init_method);
8706 }
8707 }
8708
8709 if (unlikely(result == NULL)) {
8710 Py_DECREF(obj);
8711 return NULL;
8712 }
8713
8714 Py_DECREF(result);
8715
8716 if (unlikely(result != Py_None)) {
8717 Py_DECREF(obj);
8718
8719 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
8720 return NULL;
8721 }
8722 } else {
8723
8724 if (unlikely(type->tp_init(obj, pos_args, NULL) < 0)) {
8725 Py_DECREF(obj);
8726 return NULL;
8727 }
8728 }
8729 }
8730 }
8731
8732 CHECK_OBJECT_X(obj);
8733
8734 return obj;
8735 }
8736#endif
8737#if PYTHON_VERSION < 0x300
8738 } else if (PyClass_Check(called)) {
8739 PyObject *obj = PyInstance_NewRaw(called, NULL);
8740
8741 PyObject *init_method = FIND_ATTRIBUTE_IN_CLASS((PyClassObject *)called, const_str_plain___init__);
8742
8743 if (unlikely(init_method == NULL)) {
8744 if (unlikely(HAS_ERROR_OCCURRED(tstate))) {
8745 Py_DECREF(obj);
8746 return NULL;
8747 }
8748
8749 Py_DECREF(obj);
8750
8751 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_TypeError, "this constructor takes no arguments");
8752 return NULL;
8753 }
8754
8755 bool is_compiled_function = false;
8756
8757 descrgetfunc descr_get = Py_TYPE(init_method)->tp_descr_get;
8758
8759 if (descr_get == NULL) {
8760 Py_INCREF(init_method);
8761 } else if (descr_get == Nuitka_Function_Type.tp_descr_get) {
8762 is_compiled_function = true;
8763 } else if (descr_get != NULL) {
8764 PyObject *descr_method = descr_get(init_method, obj, called);
8765
8766 if (unlikely(descr_method == NULL)) {
8767 return NULL;
8768 }
8769
8770 init_method = descr_method;
8771 }
8772
8773 PyObject *result;
8774 if (is_compiled_function) {
8775 result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)init_method, obj,
8776 args, 10);
8777 } else {
8778 result = CALL_FUNCTION_WITH_POS_ARGS10(tstate, init_method, pos_args);
8779 Py_DECREF(init_method);
8780 }
8781 if (unlikely(result == NULL)) {
8782 return NULL;
8783 }
8784
8785 Py_DECREF(result);
8786
8787 if (unlikely(result != Py_None)) {
8788 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("__init__() should return None, not '%s'", result);
8789 return NULL;
8790 }
8791
8792 CHECK_OBJECT_X(obj);
8793
8794 return obj;
8795#endif
8796#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8797 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8798 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8799
8800 if (likely(func != NULL)) {
8801 PyObject *result = func(called, args, 10, NULL);
8802
8803 CHECK_OBJECT_X(result);
8804
8805 return Nuitka_CheckFunctionResult(tstate, called, result);
8806 }
8807#endif
8808 }
8809
8810#if 0
8811 PRINT_NEW_LINE();
8812 PRINT_STRING("FALLBACK");
8813 PRINT_ITEM(called);
8814 PRINT_NEW_LINE();
8815#endif
8816
8817 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
8818
8819 CHECK_OBJECT_X(result);
8820
8821 return result;
8822}
8823PyObject *CALL_FUNCTION_WITH_NO_ARGS_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *const *kw_values,
8824 PyObject *kw_names) {
8825
8826 CHECK_OBJECT(kw_names);
8827 assert(PyTuple_CheckExact(kw_names));
8828 CHECK_OBJECT(called);
8829
8830 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
8831
8832 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
8833
8834 if (Nuitka_Function_Check(called)) {
8835 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
8836 return NULL;
8837 }
8838
8839 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
8840
8841 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, NULL, 0, kw_values, kw_names);
8842
8843 Py_LeaveRecursiveCall();
8844
8845 CHECK_OBJECT_X(result);
8846
8847 return result;
8848#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8849 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8850 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8851
8852 if (likely(func != NULL)) {
8853 PyObject *result = func(called, kw_values, 0, kw_names);
8854
8855 CHECK_OBJECT_X(result);
8856
8857 return Nuitka_CheckFunctionResult(tstate, called, result);
8858 }
8859#endif
8860 }
8861
8862#if 0
8863 PRINT_STRING("FALLBACK");
8864 PRINT_ITEM(called);
8865 PRINT_NEW_LINE();
8866#endif
8867
8868 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
8869
8870 if (unlikely(call_slot == NULL)) {
8871 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
8872
8873 return NULL;
8874 }
8875
8876 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
8877 return NULL;
8878 }
8879
8880 PyObject *pos_args = const_tuple_empty;
8881
8882 PyObject *named_args = _PyDict_NewPresized(nkwargs);
8883
8884 for (Py_ssize_t i = 0; i < nkwargs; i++) {
8885 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
8886
8887 PyObject *value = kw_values[i];
8888
8889 CHECK_OBJECT(key);
8890 CHECK_OBJECT(value);
8891
8892 DICT_SET_ITEM(named_args, key, value);
8893 }
8894
8895 PyObject *result = (*call_slot)(called, pos_args, named_args);
8896
8897 Py_DECREF(named_args);
8898
8899 Py_LeaveRecursiveCall();
8900
8901 CHECK_OBJECT_X(result);
8902
8903 return Nuitka_CheckFunctionResult(tstate, called, result);
8904}
8905PyObject *CALL_FUNCTION_WITH_ARGS1_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *const *args,
8906 PyObject *kw_names) {
8907 CHECK_OBJECTS(args, 1);
8908 CHECK_OBJECT(kw_names);
8909 assert(PyTuple_CheckExact(kw_names));
8910 CHECK_OBJECT(called);
8911
8912 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
8913
8914 CHECK_OBJECTS(&args[1], nkwargs);
8915
8916 if (Nuitka_Function_Check(called)) {
8917 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
8918 return NULL;
8919 }
8920
8921 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
8922
8923 PyObject *result =
8924 Nuitka_CallFunctionVectorcall(tstate, function, args, 1, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
8925
8926 Py_LeaveRecursiveCall();
8927
8928 CHECK_OBJECT_X(result);
8929
8930 return result;
8931#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
8932 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
8933 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
8934
8935 if (likely(func != NULL)) {
8936 PyObject *result = func(called, args, 1, kw_names);
8937
8938 CHECK_OBJECT_X(result);
8939
8940 return Nuitka_CheckFunctionResult(tstate, called, result);
8941 }
8942#endif
8943 }
8944
8945#if 0
8946 PRINT_STRING("FALLBACK");
8947 PRINT_ITEM(called);
8948 PRINT_NEW_LINE();
8949#endif
8950
8951 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
8952
8953 if (unlikely(call_slot == NULL)) {
8954 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
8955
8956 return NULL;
8957 }
8958
8959 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
8960 return NULL;
8961 }
8962
8963 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
8964
8965 PyObject *named_args = _PyDict_NewPresized(nkwargs);
8966
8967 for (Py_ssize_t i = 0; i < nkwargs; i++) {
8968 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
8969
8970 PyObject *value = args[1 + i];
8971
8972 CHECK_OBJECT(key);
8973 CHECK_OBJECT(value);
8974
8975 DICT_SET_ITEM(named_args, key, value);
8976 }
8977
8978 PyObject *result = (*call_slot)(called, pos_args, named_args);
8979
8980 Py_DECREF(pos_args);
8981 Py_DECREF(named_args);
8982
8983 Py_LeaveRecursiveCall();
8984
8985 CHECK_OBJECT_X(result);
8986
8987 return Nuitka_CheckFunctionResult(tstate, called, result);
8988}
8989PyObject *CALL_FUNCTION_WITH_ARGS1_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *const *args,
8990 PyObject *const *kw_values, PyObject *kw_names) {
8991 CHECK_OBJECTS(args, 1);
8992 CHECK_OBJECT(kw_names);
8993 assert(PyTuple_CheckExact(kw_names));
8994 CHECK_OBJECT(called);
8995
8996 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
8997
8998 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
8999
9000 if (Nuitka_Function_Check(called)) {
9001 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9002 return NULL;
9003 }
9004
9005 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
9006
9007 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 1, kw_values, kw_names);
9008
9009 Py_LeaveRecursiveCall();
9010
9011 CHECK_OBJECT_X(result);
9012
9013 return result;
9014#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9015 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9016 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9017
9018 if (likely(func != NULL)) {
9019 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 1 + nkwargs);
9020
9021 memcpy(vectorcall_args, args, 1 * sizeof(PyObject *));
9022 memcpy(&vectorcall_args[1], kw_values, nkwargs * sizeof(PyObject *));
9023
9024 PyObject *result = func(called, vectorcall_args, 1, kw_names);
9025
9026 CHECK_OBJECT_X(result);
9027
9028 return Nuitka_CheckFunctionResult(tstate, called, result);
9029 }
9030#endif
9031 }
9032
9033#if 0
9034 PRINT_STRING("FALLBACK");
9035 PRINT_ITEM(called);
9036 PRINT_NEW_LINE();
9037#endif
9038
9039 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9040
9041 if (unlikely(call_slot == NULL)) {
9042 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
9043
9044 return NULL;
9045 }
9046
9047 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9048 return NULL;
9049 }
9050
9051 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
9052
9053 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9054
9055 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9056 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9057
9058 PyObject *value = kw_values[i];
9059
9060 CHECK_OBJECT(key);
9061 CHECK_OBJECT(value);
9062
9063 DICT_SET_ITEM(named_args, key, value);
9064 }
9065
9066 PyObject *result = (*call_slot)(called, pos_args, named_args);
9067
9068 Py_DECREF(pos_args);
9069 Py_DECREF(named_args);
9070
9071 Py_LeaveRecursiveCall();
9072
9073 CHECK_OBJECT_X(result);
9074
9075 return Nuitka_CheckFunctionResult(tstate, called, result);
9076}
9077PyObject *CALL_FUNCTION_WITH_POS_ARGS1_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9078 PyObject *const *kw_values, PyObject *kw_names) {
9079 assert(PyTuple_CheckExact(pos_args));
9080 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
9081 CHECK_OBJECTS(args, 1);
9082 CHECK_OBJECT(kw_names);
9083 assert(PyTuple_CheckExact(kw_names));
9084 CHECK_OBJECT(called);
9085
9086 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9087
9088 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9089
9090 if (Nuitka_Function_Check(called)) {
9091 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9092 return NULL;
9093 }
9094
9095 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
9096
9097 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 1, kw_values, kw_names);
9098
9099 Py_LeaveRecursiveCall();
9100
9101 CHECK_OBJECT_X(result);
9102
9103 return result;
9104#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9105 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9106 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9107
9108 if (likely(func != NULL)) {
9109 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 1 + nkwargs);
9110
9111 memcpy(vectorcall_args, args, 1 * sizeof(PyObject *));
9112 memcpy(&vectorcall_args[1], kw_values, nkwargs * sizeof(PyObject *));
9113
9114 PyObject *result = func(called, vectorcall_args, 1, kw_names);
9115
9116 CHECK_OBJECT_X(result);
9117
9118 return Nuitka_CheckFunctionResult(tstate, called, result);
9119 }
9120#endif
9121 }
9122
9123#if 0
9124 PRINT_STRING("FALLBACK");
9125 PRINT_ITEM(called);
9126 PRINT_NEW_LINE();
9127#endif
9128
9129 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9130
9131 if (unlikely(call_slot == NULL)) {
9132 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
9133
9134 return NULL;
9135 }
9136
9137 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9138 return NULL;
9139 }
9140
9141 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9142
9143 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9144 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9145
9146 PyObject *value = kw_values[i];
9147
9148 CHECK_OBJECT(key);
9149 CHECK_OBJECT(value);
9150
9151 DICT_SET_ITEM(named_args, key, value);
9152 }
9153
9154 PyObject *result = (*call_slot)(called, pos_args, named_args);
9155
9156 Py_DECREF(named_args);
9157
9158 Py_LeaveRecursiveCall();
9159
9160 CHECK_OBJECT_X(result);
9161
9162 return Nuitka_CheckFunctionResult(tstate, called, result);
9163}
9164PyObject *CALL_FUNCTION_WITH_ARGS2_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *const *args,
9165 PyObject *kw_names) {
9166 CHECK_OBJECTS(args, 2);
9167 CHECK_OBJECT(kw_names);
9168 assert(PyTuple_CheckExact(kw_names));
9169 CHECK_OBJECT(called);
9170
9171 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9172
9173 CHECK_OBJECTS(&args[2], nkwargs);
9174
9175 if (Nuitka_Function_Check(called)) {
9176 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9177 return NULL;
9178 }
9179
9180 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
9181
9182 PyObject *result =
9183 Nuitka_CallFunctionVectorcall(tstate, function, args, 2, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
9184
9185 Py_LeaveRecursiveCall();
9186
9187 CHECK_OBJECT_X(result);
9188
9189 return result;
9190#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9191 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9192 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9193
9194 if (likely(func != NULL)) {
9195 PyObject *result = func(called, args, 2, kw_names);
9196
9197 CHECK_OBJECT_X(result);
9198
9199 return Nuitka_CheckFunctionResult(tstate, called, result);
9200 }
9201#endif
9202 }
9203
9204#if 0
9205 PRINT_STRING("FALLBACK");
9206 PRINT_ITEM(called);
9207 PRINT_NEW_LINE();
9208#endif
9209
9210 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9211
9212 if (unlikely(call_slot == NULL)) {
9213 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
9214
9215 return NULL;
9216 }
9217
9218 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9219 return NULL;
9220 }
9221
9222 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
9223
9224 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9225
9226 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9227 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9228
9229 PyObject *value = args[2 + i];
9230
9231 CHECK_OBJECT(key);
9232 CHECK_OBJECT(value);
9233
9234 DICT_SET_ITEM(named_args, key, value);
9235 }
9236
9237 PyObject *result = (*call_slot)(called, pos_args, named_args);
9238
9239 Py_DECREF(pos_args);
9240 Py_DECREF(named_args);
9241
9242 Py_LeaveRecursiveCall();
9243
9244 CHECK_OBJECT_X(result);
9245
9246 return Nuitka_CheckFunctionResult(tstate, called, result);
9247}
9248PyObject *CALL_FUNCTION_WITH_ARGS2_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *const *args,
9249 PyObject *const *kw_values, PyObject *kw_names) {
9250 CHECK_OBJECTS(args, 2);
9251 CHECK_OBJECT(kw_names);
9252 assert(PyTuple_CheckExact(kw_names));
9253 CHECK_OBJECT(called);
9254
9255 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9256
9257 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9258
9259 if (Nuitka_Function_Check(called)) {
9260 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9261 return NULL;
9262 }
9263
9264 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
9265
9266 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 2, kw_values, kw_names);
9267
9268 Py_LeaveRecursiveCall();
9269
9270 CHECK_OBJECT_X(result);
9271
9272 return result;
9273#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9274 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9275 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9276
9277 if (likely(func != NULL)) {
9278 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 2 + nkwargs);
9279
9280 memcpy(vectorcall_args, args, 2 * sizeof(PyObject *));
9281 memcpy(&vectorcall_args[2], kw_values, nkwargs * sizeof(PyObject *));
9282
9283 PyObject *result = func(called, vectorcall_args, 2, kw_names);
9284
9285 CHECK_OBJECT_X(result);
9286
9287 return Nuitka_CheckFunctionResult(tstate, called, result);
9288 }
9289#endif
9290 }
9291
9292#if 0
9293 PRINT_STRING("FALLBACK");
9294 PRINT_ITEM(called);
9295 PRINT_NEW_LINE();
9296#endif
9297
9298 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9299
9300 if (unlikely(call_slot == NULL)) {
9301 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
9302
9303 return NULL;
9304 }
9305
9306 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9307 return NULL;
9308 }
9309
9310 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
9311
9312 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9313
9314 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9315 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9316
9317 PyObject *value = kw_values[i];
9318
9319 CHECK_OBJECT(key);
9320 CHECK_OBJECT(value);
9321
9322 DICT_SET_ITEM(named_args, key, value);
9323 }
9324
9325 PyObject *result = (*call_slot)(called, pos_args, named_args);
9326
9327 Py_DECREF(pos_args);
9328 Py_DECREF(named_args);
9329
9330 Py_LeaveRecursiveCall();
9331
9332 CHECK_OBJECT_X(result);
9333
9334 return Nuitka_CheckFunctionResult(tstate, called, result);
9335}
9336PyObject *CALL_FUNCTION_WITH_POS_ARGS2_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9337 PyObject *const *kw_values, PyObject *kw_names) {
9338 assert(PyTuple_CheckExact(pos_args));
9339 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
9340 CHECK_OBJECTS(args, 2);
9341 CHECK_OBJECT(kw_names);
9342 assert(PyTuple_CheckExact(kw_names));
9343 CHECK_OBJECT(called);
9344
9345 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9346
9347 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9348
9349 if (Nuitka_Function_Check(called)) {
9350 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9351 return NULL;
9352 }
9353
9354 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
9355
9356 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 2, kw_values, kw_names);
9357
9358 Py_LeaveRecursiveCall();
9359
9360 CHECK_OBJECT_X(result);
9361
9362 return result;
9363#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9364 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9365 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9366
9367 if (likely(func != NULL)) {
9368 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 2 + nkwargs);
9369
9370 memcpy(vectorcall_args, args, 2 * sizeof(PyObject *));
9371 memcpy(&vectorcall_args[2], kw_values, nkwargs * sizeof(PyObject *));
9372
9373 PyObject *result = func(called, vectorcall_args, 2, kw_names);
9374
9375 CHECK_OBJECT_X(result);
9376
9377 return Nuitka_CheckFunctionResult(tstate, called, result);
9378 }
9379#endif
9380 }
9381
9382#if 0
9383 PRINT_STRING("FALLBACK");
9384 PRINT_ITEM(called);
9385 PRINT_NEW_LINE();
9386#endif
9387
9388 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9389
9390 if (unlikely(call_slot == NULL)) {
9391 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
9392
9393 return NULL;
9394 }
9395
9396 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9397 return NULL;
9398 }
9399
9400 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9401
9402 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9403 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9404
9405 PyObject *value = kw_values[i];
9406
9407 CHECK_OBJECT(key);
9408 CHECK_OBJECT(value);
9409
9410 DICT_SET_ITEM(named_args, key, value);
9411 }
9412
9413 PyObject *result = (*call_slot)(called, pos_args, named_args);
9414
9415 Py_DECREF(named_args);
9416
9417 Py_LeaveRecursiveCall();
9418
9419 CHECK_OBJECT_X(result);
9420
9421 return Nuitka_CheckFunctionResult(tstate, called, result);
9422}
9423PyObject *CALL_FUNCTION_WITH_ARGS3_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *const *args,
9424 PyObject *kw_names) {
9425 CHECK_OBJECTS(args, 3);
9426 CHECK_OBJECT(kw_names);
9427 assert(PyTuple_CheckExact(kw_names));
9428 CHECK_OBJECT(called);
9429
9430 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9431
9432 CHECK_OBJECTS(&args[3], nkwargs);
9433
9434 if (Nuitka_Function_Check(called)) {
9435 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9436 return NULL;
9437 }
9438
9439 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
9440
9441 PyObject *result =
9442 Nuitka_CallFunctionVectorcall(tstate, function, args, 3, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
9443
9444 Py_LeaveRecursiveCall();
9445
9446 CHECK_OBJECT_X(result);
9447
9448 return result;
9449#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9450 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9451 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9452
9453 if (likely(func != NULL)) {
9454 PyObject *result = func(called, args, 3, kw_names);
9455
9456 CHECK_OBJECT_X(result);
9457
9458 return Nuitka_CheckFunctionResult(tstate, called, result);
9459 }
9460#endif
9461 }
9462
9463#if 0
9464 PRINT_STRING("FALLBACK");
9465 PRINT_ITEM(called);
9466 PRINT_NEW_LINE();
9467#endif
9468
9469 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9470
9471 if (unlikely(call_slot == NULL)) {
9472 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
9473
9474 return NULL;
9475 }
9476
9477 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9478 return NULL;
9479 }
9480
9481 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
9482
9483 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9484
9485 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9486 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9487
9488 PyObject *value = args[3 + i];
9489
9490 CHECK_OBJECT(key);
9491 CHECK_OBJECT(value);
9492
9493 DICT_SET_ITEM(named_args, key, value);
9494 }
9495
9496 PyObject *result = (*call_slot)(called, pos_args, named_args);
9497
9498 Py_DECREF(pos_args);
9499 Py_DECREF(named_args);
9500
9501 Py_LeaveRecursiveCall();
9502
9503 CHECK_OBJECT_X(result);
9504
9505 return Nuitka_CheckFunctionResult(tstate, called, result);
9506}
9507PyObject *CALL_FUNCTION_WITH_ARGS3_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *const *args,
9508 PyObject *const *kw_values, PyObject *kw_names) {
9509 CHECK_OBJECTS(args, 3);
9510 CHECK_OBJECT(kw_names);
9511 assert(PyTuple_CheckExact(kw_names));
9512 CHECK_OBJECT(called);
9513
9514 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9515
9516 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9517
9518 if (Nuitka_Function_Check(called)) {
9519 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9520 return NULL;
9521 }
9522
9523 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
9524
9525 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 3, kw_values, kw_names);
9526
9527 Py_LeaveRecursiveCall();
9528
9529 CHECK_OBJECT_X(result);
9530
9531 return result;
9532#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9533 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9534 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9535
9536 if (likely(func != NULL)) {
9537 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 3 + nkwargs);
9538
9539 memcpy(vectorcall_args, args, 3 * sizeof(PyObject *));
9540 memcpy(&vectorcall_args[3], kw_values, nkwargs * sizeof(PyObject *));
9541
9542 PyObject *result = func(called, vectorcall_args, 3, kw_names);
9543
9544 CHECK_OBJECT_X(result);
9545
9546 return Nuitka_CheckFunctionResult(tstate, called, result);
9547 }
9548#endif
9549 }
9550
9551#if 0
9552 PRINT_STRING("FALLBACK");
9553 PRINT_ITEM(called);
9554 PRINT_NEW_LINE();
9555#endif
9556
9557 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9558
9559 if (unlikely(call_slot == NULL)) {
9560 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
9561
9562 return NULL;
9563 }
9564
9565 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9566 return NULL;
9567 }
9568
9569 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
9570
9571 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9572
9573 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9574 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9575
9576 PyObject *value = kw_values[i];
9577
9578 CHECK_OBJECT(key);
9579 CHECK_OBJECT(value);
9580
9581 DICT_SET_ITEM(named_args, key, value);
9582 }
9583
9584 PyObject *result = (*call_slot)(called, pos_args, named_args);
9585
9586 Py_DECREF(pos_args);
9587 Py_DECREF(named_args);
9588
9589 Py_LeaveRecursiveCall();
9590
9591 CHECK_OBJECT_X(result);
9592
9593 return Nuitka_CheckFunctionResult(tstate, called, result);
9594}
9595PyObject *CALL_FUNCTION_WITH_POS_ARGS3_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9596 PyObject *const *kw_values, PyObject *kw_names) {
9597 assert(PyTuple_CheckExact(pos_args));
9598 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
9599 CHECK_OBJECTS(args, 3);
9600 CHECK_OBJECT(kw_names);
9601 assert(PyTuple_CheckExact(kw_names));
9602 CHECK_OBJECT(called);
9603
9604 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9605
9606 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9607
9608 if (Nuitka_Function_Check(called)) {
9609 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9610 return NULL;
9611 }
9612
9613 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
9614
9615 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 3, kw_values, kw_names);
9616
9617 Py_LeaveRecursiveCall();
9618
9619 CHECK_OBJECT_X(result);
9620
9621 return result;
9622#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9623 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9624 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9625
9626 if (likely(func != NULL)) {
9627 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 3 + nkwargs);
9628
9629 memcpy(vectorcall_args, args, 3 * sizeof(PyObject *));
9630 memcpy(&vectorcall_args[3], kw_values, nkwargs * sizeof(PyObject *));
9631
9632 PyObject *result = func(called, vectorcall_args, 3, kw_names);
9633
9634 CHECK_OBJECT_X(result);
9635
9636 return Nuitka_CheckFunctionResult(tstate, called, result);
9637 }
9638#endif
9639 }
9640
9641#if 0
9642 PRINT_STRING("FALLBACK");
9643 PRINT_ITEM(called);
9644 PRINT_NEW_LINE();
9645#endif
9646
9647 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9648
9649 if (unlikely(call_slot == NULL)) {
9650 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
9651
9652 return NULL;
9653 }
9654
9655 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9656 return NULL;
9657 }
9658
9659 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9660
9661 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9662 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9663
9664 PyObject *value = kw_values[i];
9665
9666 CHECK_OBJECT(key);
9667 CHECK_OBJECT(value);
9668
9669 DICT_SET_ITEM(named_args, key, value);
9670 }
9671
9672 PyObject *result = (*call_slot)(called, pos_args, named_args);
9673
9674 Py_DECREF(named_args);
9675
9676 Py_LeaveRecursiveCall();
9677
9678 CHECK_OBJECT_X(result);
9679
9680 return Nuitka_CheckFunctionResult(tstate, called, result);
9681}
9682PyObject *CALL_FUNCTION_WITH_ARGS4_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *const *args,
9683 PyObject *kw_names) {
9684 CHECK_OBJECTS(args, 4);
9685 CHECK_OBJECT(kw_names);
9686 assert(PyTuple_CheckExact(kw_names));
9687 CHECK_OBJECT(called);
9688
9689 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9690
9691 CHECK_OBJECTS(&args[4], nkwargs);
9692
9693 if (Nuitka_Function_Check(called)) {
9694 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9695 return NULL;
9696 }
9697
9698 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
9699
9700 PyObject *result =
9701 Nuitka_CallFunctionVectorcall(tstate, function, args, 4, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
9702
9703 Py_LeaveRecursiveCall();
9704
9705 CHECK_OBJECT_X(result);
9706
9707 return result;
9708#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9709 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9710 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9711
9712 if (likely(func != NULL)) {
9713 PyObject *result = func(called, args, 4, kw_names);
9714
9715 CHECK_OBJECT_X(result);
9716
9717 return Nuitka_CheckFunctionResult(tstate, called, result);
9718 }
9719#endif
9720 }
9721
9722#if 0
9723 PRINT_STRING("FALLBACK");
9724 PRINT_ITEM(called);
9725 PRINT_NEW_LINE();
9726#endif
9727
9728 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9729
9730 if (unlikely(call_slot == NULL)) {
9731 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
9732
9733 return NULL;
9734 }
9735
9736 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9737 return NULL;
9738 }
9739
9740 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
9741
9742 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9743
9744 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9745 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9746
9747 PyObject *value = args[4 + i];
9748
9749 CHECK_OBJECT(key);
9750 CHECK_OBJECT(value);
9751
9752 DICT_SET_ITEM(named_args, key, value);
9753 }
9754
9755 PyObject *result = (*call_slot)(called, pos_args, named_args);
9756
9757 Py_DECREF(pos_args);
9758 Py_DECREF(named_args);
9759
9760 Py_LeaveRecursiveCall();
9761
9762 CHECK_OBJECT_X(result);
9763
9764 return Nuitka_CheckFunctionResult(tstate, called, result);
9765}
9766PyObject *CALL_FUNCTION_WITH_ARGS4_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *const *args,
9767 PyObject *const *kw_values, PyObject *kw_names) {
9768 CHECK_OBJECTS(args, 4);
9769 CHECK_OBJECT(kw_names);
9770 assert(PyTuple_CheckExact(kw_names));
9771 CHECK_OBJECT(called);
9772
9773 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9774
9775 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9776
9777 if (Nuitka_Function_Check(called)) {
9778 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9779 return NULL;
9780 }
9781
9782 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
9783
9784 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 4, kw_values, kw_names);
9785
9786 Py_LeaveRecursiveCall();
9787
9788 CHECK_OBJECT_X(result);
9789
9790 return result;
9791#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9792 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9793 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9794
9795 if (likely(func != NULL)) {
9796 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 4 + nkwargs);
9797
9798 memcpy(vectorcall_args, args, 4 * sizeof(PyObject *));
9799 memcpy(&vectorcall_args[4], kw_values, nkwargs * sizeof(PyObject *));
9800
9801 PyObject *result = func(called, vectorcall_args, 4, kw_names);
9802
9803 CHECK_OBJECT_X(result);
9804
9805 return Nuitka_CheckFunctionResult(tstate, called, result);
9806 }
9807#endif
9808 }
9809
9810#if 0
9811 PRINT_STRING("FALLBACK");
9812 PRINT_ITEM(called);
9813 PRINT_NEW_LINE();
9814#endif
9815
9816 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9817
9818 if (unlikely(call_slot == NULL)) {
9819 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
9820
9821 return NULL;
9822 }
9823
9824 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9825 return NULL;
9826 }
9827
9828 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
9829
9830 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9831
9832 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9833 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9834
9835 PyObject *value = kw_values[i];
9836
9837 CHECK_OBJECT(key);
9838 CHECK_OBJECT(value);
9839
9840 DICT_SET_ITEM(named_args, key, value);
9841 }
9842
9843 PyObject *result = (*call_slot)(called, pos_args, named_args);
9844
9845 Py_DECREF(pos_args);
9846 Py_DECREF(named_args);
9847
9848 Py_LeaveRecursiveCall();
9849
9850 CHECK_OBJECT_X(result);
9851
9852 return Nuitka_CheckFunctionResult(tstate, called, result);
9853}
9854PyObject *CALL_FUNCTION_WITH_POS_ARGS4_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
9855 PyObject *const *kw_values, PyObject *kw_names) {
9856 assert(PyTuple_CheckExact(pos_args));
9857 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
9858 CHECK_OBJECTS(args, 4);
9859 CHECK_OBJECT(kw_names);
9860 assert(PyTuple_CheckExact(kw_names));
9861 CHECK_OBJECT(called);
9862
9863 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9864
9865 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
9866
9867 if (Nuitka_Function_Check(called)) {
9868 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9869 return NULL;
9870 }
9871
9872 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
9873
9874 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 4, kw_values, kw_names);
9875
9876 Py_LeaveRecursiveCall();
9877
9878 CHECK_OBJECT_X(result);
9879
9880 return result;
9881#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9882 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9883 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9884
9885 if (likely(func != NULL)) {
9886 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 4 + nkwargs);
9887
9888 memcpy(vectorcall_args, args, 4 * sizeof(PyObject *));
9889 memcpy(&vectorcall_args[4], kw_values, nkwargs * sizeof(PyObject *));
9890
9891 PyObject *result = func(called, vectorcall_args, 4, kw_names);
9892
9893 CHECK_OBJECT_X(result);
9894
9895 return Nuitka_CheckFunctionResult(tstate, called, result);
9896 }
9897#endif
9898 }
9899
9900#if 0
9901 PRINT_STRING("FALLBACK");
9902 PRINT_ITEM(called);
9903 PRINT_NEW_LINE();
9904#endif
9905
9906 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9907
9908 if (unlikely(call_slot == NULL)) {
9909 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
9910
9911 return NULL;
9912 }
9913
9914 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9915 return NULL;
9916 }
9917
9918 PyObject *named_args = _PyDict_NewPresized(nkwargs);
9919
9920 for (Py_ssize_t i = 0; i < nkwargs; i++) {
9921 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
9922
9923 PyObject *value = kw_values[i];
9924
9925 CHECK_OBJECT(key);
9926 CHECK_OBJECT(value);
9927
9928 DICT_SET_ITEM(named_args, key, value);
9929 }
9930
9931 PyObject *result = (*call_slot)(called, pos_args, named_args);
9932
9933 Py_DECREF(named_args);
9934
9935 Py_LeaveRecursiveCall();
9936
9937 CHECK_OBJECT_X(result);
9938
9939 return Nuitka_CheckFunctionResult(tstate, called, result);
9940}
9941PyObject *CALL_FUNCTION_WITH_ARGS5_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *const *args,
9942 PyObject *kw_names) {
9943 CHECK_OBJECTS(args, 5);
9944 CHECK_OBJECT(kw_names);
9945 assert(PyTuple_CheckExact(kw_names));
9946 CHECK_OBJECT(called);
9947
9948 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
9949
9950 CHECK_OBJECTS(&args[5], nkwargs);
9951
9952 if (Nuitka_Function_Check(called)) {
9953 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9954 return NULL;
9955 }
9956
9957 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
9958
9959 PyObject *result =
9960 Nuitka_CallFunctionVectorcall(tstate, function, args, 5, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
9961
9962 Py_LeaveRecursiveCall();
9963
9964 CHECK_OBJECT_X(result);
9965
9966 return result;
9967#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
9968 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
9969 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
9970
9971 if (likely(func != NULL)) {
9972 PyObject *result = func(called, args, 5, kw_names);
9973
9974 CHECK_OBJECT_X(result);
9975
9976 return Nuitka_CheckFunctionResult(tstate, called, result);
9977 }
9978#endif
9979 }
9980
9981#if 0
9982 PRINT_STRING("FALLBACK");
9983 PRINT_ITEM(called);
9984 PRINT_NEW_LINE();
9985#endif
9986
9987 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
9988
9989 if (unlikely(call_slot == NULL)) {
9990 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
9991
9992 return NULL;
9993 }
9994
9995 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
9996 return NULL;
9997 }
9998
9999 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
10000
10001 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10002
10003 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10004 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10005
10006 PyObject *value = args[5 + i];
10007
10008 CHECK_OBJECT(key);
10009 CHECK_OBJECT(value);
10010
10011 DICT_SET_ITEM(named_args, key, value);
10012 }
10013
10014 PyObject *result = (*call_slot)(called, pos_args, named_args);
10015
10016 Py_DECREF(pos_args);
10017 Py_DECREF(named_args);
10018
10019 Py_LeaveRecursiveCall();
10020
10021 CHECK_OBJECT_X(result);
10022
10023 return Nuitka_CheckFunctionResult(tstate, called, result);
10024}
10025PyObject *CALL_FUNCTION_WITH_ARGS5_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *const *args,
10026 PyObject *const *kw_values, PyObject *kw_names) {
10027 CHECK_OBJECTS(args, 5);
10028 CHECK_OBJECT(kw_names);
10029 assert(PyTuple_CheckExact(kw_names));
10030 CHECK_OBJECT(called);
10031
10032 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10033
10034 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10035
10036 if (Nuitka_Function_Check(called)) {
10037 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10038 return NULL;
10039 }
10040
10041 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
10042
10043 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 5, kw_values, kw_names);
10044
10045 Py_LeaveRecursiveCall();
10046
10047 CHECK_OBJECT_X(result);
10048
10049 return result;
10050#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10051 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10052 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10053
10054 if (likely(func != NULL)) {
10055 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 5 + nkwargs);
10056
10057 memcpy(vectorcall_args, args, 5 * sizeof(PyObject *));
10058 memcpy(&vectorcall_args[5], kw_values, nkwargs * sizeof(PyObject *));
10059
10060 PyObject *result = func(called, vectorcall_args, 5, kw_names);
10061
10062 CHECK_OBJECT_X(result);
10063
10064 return Nuitka_CheckFunctionResult(tstate, called, result);
10065 }
10066#endif
10067 }
10068
10069#if 0
10070 PRINT_STRING("FALLBACK");
10071 PRINT_ITEM(called);
10072 PRINT_NEW_LINE();
10073#endif
10074
10075 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10076
10077 if (unlikely(call_slot == NULL)) {
10078 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
10079
10080 return NULL;
10081 }
10082
10083 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10084 return NULL;
10085 }
10086
10087 PyObject *pos_args = MAKE_TUPLE(tstate, args, 5);
10088
10089 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10090
10091 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10092 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10093
10094 PyObject *value = kw_values[i];
10095
10096 CHECK_OBJECT(key);
10097 CHECK_OBJECT(value);
10098
10099 DICT_SET_ITEM(named_args, key, value);
10100 }
10101
10102 PyObject *result = (*call_slot)(called, pos_args, named_args);
10103
10104 Py_DECREF(pos_args);
10105 Py_DECREF(named_args);
10106
10107 Py_LeaveRecursiveCall();
10108
10109 CHECK_OBJECT_X(result);
10110
10111 return Nuitka_CheckFunctionResult(tstate, called, result);
10112}
10113PyObject *CALL_FUNCTION_WITH_POS_ARGS5_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10114 PyObject *const *kw_values, PyObject *kw_names) {
10115 assert(PyTuple_CheckExact(pos_args));
10116 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
10117 CHECK_OBJECTS(args, 5);
10118 CHECK_OBJECT(kw_names);
10119 assert(PyTuple_CheckExact(kw_names));
10120 CHECK_OBJECT(called);
10121
10122 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10123
10124 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10125
10126 if (Nuitka_Function_Check(called)) {
10127 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10128 return NULL;
10129 }
10130
10131 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
10132
10133 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 5, kw_values, kw_names);
10134
10135 Py_LeaveRecursiveCall();
10136
10137 CHECK_OBJECT_X(result);
10138
10139 return result;
10140#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10141 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10142 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10143
10144 if (likely(func != NULL)) {
10145 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 5 + nkwargs);
10146
10147 memcpy(vectorcall_args, args, 5 * sizeof(PyObject *));
10148 memcpy(&vectorcall_args[5], kw_values, nkwargs * sizeof(PyObject *));
10149
10150 PyObject *result = func(called, vectorcall_args, 5, kw_names);
10151
10152 CHECK_OBJECT_X(result);
10153
10154 return Nuitka_CheckFunctionResult(tstate, called, result);
10155 }
10156#endif
10157 }
10158
10159#if 0
10160 PRINT_STRING("FALLBACK");
10161 PRINT_ITEM(called);
10162 PRINT_NEW_LINE();
10163#endif
10164
10165 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10166
10167 if (unlikely(call_slot == NULL)) {
10168 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
10169
10170 return NULL;
10171 }
10172
10173 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10174 return NULL;
10175 }
10176
10177 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10178
10179 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10180 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10181
10182 PyObject *value = kw_values[i];
10183
10184 CHECK_OBJECT(key);
10185 CHECK_OBJECT(value);
10186
10187 DICT_SET_ITEM(named_args, key, value);
10188 }
10189
10190 PyObject *result = (*call_slot)(called, pos_args, named_args);
10191
10192 Py_DECREF(named_args);
10193
10194 Py_LeaveRecursiveCall();
10195
10196 CHECK_OBJECT_X(result);
10197
10198 return Nuitka_CheckFunctionResult(tstate, called, result);
10199}
10200PyObject *CALL_FUNCTION_WITH_ARGS6_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *const *args,
10201 PyObject *kw_names) {
10202 CHECK_OBJECTS(args, 6);
10203 CHECK_OBJECT(kw_names);
10204 assert(PyTuple_CheckExact(kw_names));
10205 CHECK_OBJECT(called);
10206
10207 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10208
10209 CHECK_OBJECTS(&args[6], nkwargs);
10210
10211 if (Nuitka_Function_Check(called)) {
10212 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10213 return NULL;
10214 }
10215
10216 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
10217
10218 PyObject *result =
10219 Nuitka_CallFunctionVectorcall(tstate, function, args, 6, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
10220
10221 Py_LeaveRecursiveCall();
10222
10223 CHECK_OBJECT_X(result);
10224
10225 return result;
10226#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10227 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10228 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10229
10230 if (likely(func != NULL)) {
10231 PyObject *result = func(called, args, 6, kw_names);
10232
10233 CHECK_OBJECT_X(result);
10234
10235 return Nuitka_CheckFunctionResult(tstate, called, result);
10236 }
10237#endif
10238 }
10239
10240#if 0
10241 PRINT_STRING("FALLBACK");
10242 PRINT_ITEM(called);
10243 PRINT_NEW_LINE();
10244#endif
10245
10246 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10247
10248 if (unlikely(call_slot == NULL)) {
10249 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
10250
10251 return NULL;
10252 }
10253
10254 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10255 return NULL;
10256 }
10257
10258 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
10259
10260 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10261
10262 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10263 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10264
10265 PyObject *value = args[6 + i];
10266
10267 CHECK_OBJECT(key);
10268 CHECK_OBJECT(value);
10269
10270 DICT_SET_ITEM(named_args, key, value);
10271 }
10272
10273 PyObject *result = (*call_slot)(called, pos_args, named_args);
10274
10275 Py_DECREF(pos_args);
10276 Py_DECREF(named_args);
10277
10278 Py_LeaveRecursiveCall();
10279
10280 CHECK_OBJECT_X(result);
10281
10282 return Nuitka_CheckFunctionResult(tstate, called, result);
10283}
10284PyObject *CALL_FUNCTION_WITH_ARGS6_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *const *args,
10285 PyObject *const *kw_values, PyObject *kw_names) {
10286 CHECK_OBJECTS(args, 6);
10287 CHECK_OBJECT(kw_names);
10288 assert(PyTuple_CheckExact(kw_names));
10289 CHECK_OBJECT(called);
10290
10291 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10292
10293 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10294
10295 if (Nuitka_Function_Check(called)) {
10296 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10297 return NULL;
10298 }
10299
10300 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
10301
10302 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 6, kw_values, kw_names);
10303
10304 Py_LeaveRecursiveCall();
10305
10306 CHECK_OBJECT_X(result);
10307
10308 return result;
10309#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10310 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10311 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10312
10313 if (likely(func != NULL)) {
10314 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 6 + nkwargs);
10315
10316 memcpy(vectorcall_args, args, 6 * sizeof(PyObject *));
10317 memcpy(&vectorcall_args[6], kw_values, nkwargs * sizeof(PyObject *));
10318
10319 PyObject *result = func(called, vectorcall_args, 6, kw_names);
10320
10321 CHECK_OBJECT_X(result);
10322
10323 return Nuitka_CheckFunctionResult(tstate, called, result);
10324 }
10325#endif
10326 }
10327
10328#if 0
10329 PRINT_STRING("FALLBACK");
10330 PRINT_ITEM(called);
10331 PRINT_NEW_LINE();
10332#endif
10333
10334 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10335
10336 if (unlikely(call_slot == NULL)) {
10337 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
10338
10339 return NULL;
10340 }
10341
10342 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10343 return NULL;
10344 }
10345
10346 PyObject *pos_args = MAKE_TUPLE(tstate, args, 6);
10347
10348 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10349
10350 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10351 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10352
10353 PyObject *value = kw_values[i];
10354
10355 CHECK_OBJECT(key);
10356 CHECK_OBJECT(value);
10357
10358 DICT_SET_ITEM(named_args, key, value);
10359 }
10360
10361 PyObject *result = (*call_slot)(called, pos_args, named_args);
10362
10363 Py_DECREF(pos_args);
10364 Py_DECREF(named_args);
10365
10366 Py_LeaveRecursiveCall();
10367
10368 CHECK_OBJECT_X(result);
10369
10370 return Nuitka_CheckFunctionResult(tstate, called, result);
10371}
10372PyObject *CALL_FUNCTION_WITH_POS_ARGS6_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10373 PyObject *const *kw_values, PyObject *kw_names) {
10374 assert(PyTuple_CheckExact(pos_args));
10375 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
10376 CHECK_OBJECTS(args, 6);
10377 CHECK_OBJECT(kw_names);
10378 assert(PyTuple_CheckExact(kw_names));
10379 CHECK_OBJECT(called);
10380
10381 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10382
10383 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10384
10385 if (Nuitka_Function_Check(called)) {
10386 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10387 return NULL;
10388 }
10389
10390 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
10391
10392 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 6, kw_values, kw_names);
10393
10394 Py_LeaveRecursiveCall();
10395
10396 CHECK_OBJECT_X(result);
10397
10398 return result;
10399#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10400 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10401 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10402
10403 if (likely(func != NULL)) {
10404 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 6 + nkwargs);
10405
10406 memcpy(vectorcall_args, args, 6 * sizeof(PyObject *));
10407 memcpy(&vectorcall_args[6], kw_values, nkwargs * sizeof(PyObject *));
10408
10409 PyObject *result = func(called, vectorcall_args, 6, kw_names);
10410
10411 CHECK_OBJECT_X(result);
10412
10413 return Nuitka_CheckFunctionResult(tstate, called, result);
10414 }
10415#endif
10416 }
10417
10418#if 0
10419 PRINT_STRING("FALLBACK");
10420 PRINT_ITEM(called);
10421 PRINT_NEW_LINE();
10422#endif
10423
10424 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10425
10426 if (unlikely(call_slot == NULL)) {
10427 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
10428
10429 return NULL;
10430 }
10431
10432 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10433 return NULL;
10434 }
10435
10436 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10437
10438 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10439 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10440
10441 PyObject *value = kw_values[i];
10442
10443 CHECK_OBJECT(key);
10444 CHECK_OBJECT(value);
10445
10446 DICT_SET_ITEM(named_args, key, value);
10447 }
10448
10449 PyObject *result = (*call_slot)(called, pos_args, named_args);
10450
10451 Py_DECREF(named_args);
10452
10453 Py_LeaveRecursiveCall();
10454
10455 CHECK_OBJECT_X(result);
10456
10457 return Nuitka_CheckFunctionResult(tstate, called, result);
10458}
10459PyObject *CALL_FUNCTION_WITH_ARGS7_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *const *args,
10460 PyObject *kw_names) {
10461 CHECK_OBJECTS(args, 7);
10462 CHECK_OBJECT(kw_names);
10463 assert(PyTuple_CheckExact(kw_names));
10464 CHECK_OBJECT(called);
10465
10466 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10467
10468 CHECK_OBJECTS(&args[7], nkwargs);
10469
10470 if (Nuitka_Function_Check(called)) {
10471 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10472 return NULL;
10473 }
10474
10475 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
10476
10477 PyObject *result =
10478 Nuitka_CallFunctionVectorcall(tstate, function, args, 7, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
10479
10480 Py_LeaveRecursiveCall();
10481
10482 CHECK_OBJECT_X(result);
10483
10484 return result;
10485#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10486 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10487 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10488
10489 if (likely(func != NULL)) {
10490 PyObject *result = func(called, args, 7, kw_names);
10491
10492 CHECK_OBJECT_X(result);
10493
10494 return Nuitka_CheckFunctionResult(tstate, called, result);
10495 }
10496#endif
10497 }
10498
10499#if 0
10500 PRINT_STRING("FALLBACK");
10501 PRINT_ITEM(called);
10502 PRINT_NEW_LINE();
10503#endif
10504
10505 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10506
10507 if (unlikely(call_slot == NULL)) {
10508 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
10509
10510 return NULL;
10511 }
10512
10513 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10514 return NULL;
10515 }
10516
10517 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
10518
10519 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10520
10521 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10522 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10523
10524 PyObject *value = args[7 + i];
10525
10526 CHECK_OBJECT(key);
10527 CHECK_OBJECT(value);
10528
10529 DICT_SET_ITEM(named_args, key, value);
10530 }
10531
10532 PyObject *result = (*call_slot)(called, pos_args, named_args);
10533
10534 Py_DECREF(pos_args);
10535 Py_DECREF(named_args);
10536
10537 Py_LeaveRecursiveCall();
10538
10539 CHECK_OBJECT_X(result);
10540
10541 return Nuitka_CheckFunctionResult(tstate, called, result);
10542}
10543PyObject *CALL_FUNCTION_WITH_ARGS7_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *const *args,
10544 PyObject *const *kw_values, PyObject *kw_names) {
10545 CHECK_OBJECTS(args, 7);
10546 CHECK_OBJECT(kw_names);
10547 assert(PyTuple_CheckExact(kw_names));
10548 CHECK_OBJECT(called);
10549
10550 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10551
10552 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10553
10554 if (Nuitka_Function_Check(called)) {
10555 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10556 return NULL;
10557 }
10558
10559 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
10560
10561 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 7, kw_values, kw_names);
10562
10563 Py_LeaveRecursiveCall();
10564
10565 CHECK_OBJECT_X(result);
10566
10567 return result;
10568#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10569 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10570 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10571
10572 if (likely(func != NULL)) {
10573 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 7 + nkwargs);
10574
10575 memcpy(vectorcall_args, args, 7 * sizeof(PyObject *));
10576 memcpy(&vectorcall_args[7], kw_values, nkwargs * sizeof(PyObject *));
10577
10578 PyObject *result = func(called, vectorcall_args, 7, kw_names);
10579
10580 CHECK_OBJECT_X(result);
10581
10582 return Nuitka_CheckFunctionResult(tstate, called, result);
10583 }
10584#endif
10585 }
10586
10587#if 0
10588 PRINT_STRING("FALLBACK");
10589 PRINT_ITEM(called);
10590 PRINT_NEW_LINE();
10591#endif
10592
10593 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10594
10595 if (unlikely(call_slot == NULL)) {
10596 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
10597
10598 return NULL;
10599 }
10600
10601 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10602 return NULL;
10603 }
10604
10605 PyObject *pos_args = MAKE_TUPLE(tstate, args, 7);
10606
10607 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10608
10609 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10610 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10611
10612 PyObject *value = kw_values[i];
10613
10614 CHECK_OBJECT(key);
10615 CHECK_OBJECT(value);
10616
10617 DICT_SET_ITEM(named_args, key, value);
10618 }
10619
10620 PyObject *result = (*call_slot)(called, pos_args, named_args);
10621
10622 Py_DECREF(pos_args);
10623 Py_DECREF(named_args);
10624
10625 Py_LeaveRecursiveCall();
10626
10627 CHECK_OBJECT_X(result);
10628
10629 return Nuitka_CheckFunctionResult(tstate, called, result);
10630}
10631PyObject *CALL_FUNCTION_WITH_POS_ARGS7_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10632 PyObject *const *kw_values, PyObject *kw_names) {
10633 assert(PyTuple_CheckExact(pos_args));
10634 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
10635 CHECK_OBJECTS(args, 7);
10636 CHECK_OBJECT(kw_names);
10637 assert(PyTuple_CheckExact(kw_names));
10638 CHECK_OBJECT(called);
10639
10640 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10641
10642 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10643
10644 if (Nuitka_Function_Check(called)) {
10645 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10646 return NULL;
10647 }
10648
10649 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
10650
10651 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 7, kw_values, kw_names);
10652
10653 Py_LeaveRecursiveCall();
10654
10655 CHECK_OBJECT_X(result);
10656
10657 return result;
10658#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10659 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10660 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10661
10662 if (likely(func != NULL)) {
10663 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 7 + nkwargs);
10664
10665 memcpy(vectorcall_args, args, 7 * sizeof(PyObject *));
10666 memcpy(&vectorcall_args[7], kw_values, nkwargs * sizeof(PyObject *));
10667
10668 PyObject *result = func(called, vectorcall_args, 7, kw_names);
10669
10670 CHECK_OBJECT_X(result);
10671
10672 return Nuitka_CheckFunctionResult(tstate, called, result);
10673 }
10674#endif
10675 }
10676
10677#if 0
10678 PRINT_STRING("FALLBACK");
10679 PRINT_ITEM(called);
10680 PRINT_NEW_LINE();
10681#endif
10682
10683 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10684
10685 if (unlikely(call_slot == NULL)) {
10686 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
10687
10688 return NULL;
10689 }
10690
10691 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10692 return NULL;
10693 }
10694
10695 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10696
10697 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10698 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10699
10700 PyObject *value = kw_values[i];
10701
10702 CHECK_OBJECT(key);
10703 CHECK_OBJECT(value);
10704
10705 DICT_SET_ITEM(named_args, key, value);
10706 }
10707
10708 PyObject *result = (*call_slot)(called, pos_args, named_args);
10709
10710 Py_DECREF(named_args);
10711
10712 Py_LeaveRecursiveCall();
10713
10714 CHECK_OBJECT_X(result);
10715
10716 return Nuitka_CheckFunctionResult(tstate, called, result);
10717}
10718PyObject *CALL_FUNCTION_WITH_ARGS8_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *const *args,
10719 PyObject *kw_names) {
10720 CHECK_OBJECTS(args, 8);
10721 CHECK_OBJECT(kw_names);
10722 assert(PyTuple_CheckExact(kw_names));
10723 CHECK_OBJECT(called);
10724
10725 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10726
10727 CHECK_OBJECTS(&args[8], nkwargs);
10728
10729 if (Nuitka_Function_Check(called)) {
10730 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10731 return NULL;
10732 }
10733
10734 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
10735
10736 PyObject *result =
10737 Nuitka_CallFunctionVectorcall(tstate, function, args, 8, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
10738
10739 Py_LeaveRecursiveCall();
10740
10741 CHECK_OBJECT_X(result);
10742
10743 return result;
10744#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10745 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10746 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10747
10748 if (likely(func != NULL)) {
10749 PyObject *result = func(called, args, 8, kw_names);
10750
10751 CHECK_OBJECT_X(result);
10752
10753 return Nuitka_CheckFunctionResult(tstate, called, result);
10754 }
10755#endif
10756 }
10757
10758#if 0
10759 PRINT_STRING("FALLBACK");
10760 PRINT_ITEM(called);
10761 PRINT_NEW_LINE();
10762#endif
10763
10764 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10765
10766 if (unlikely(call_slot == NULL)) {
10767 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
10768
10769 return NULL;
10770 }
10771
10772 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10773 return NULL;
10774 }
10775
10776 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
10777
10778 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10779
10780 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10781 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10782
10783 PyObject *value = args[8 + i];
10784
10785 CHECK_OBJECT(key);
10786 CHECK_OBJECT(value);
10787
10788 DICT_SET_ITEM(named_args, key, value);
10789 }
10790
10791 PyObject *result = (*call_slot)(called, pos_args, named_args);
10792
10793 Py_DECREF(pos_args);
10794 Py_DECREF(named_args);
10795
10796 Py_LeaveRecursiveCall();
10797
10798 CHECK_OBJECT_X(result);
10799
10800 return Nuitka_CheckFunctionResult(tstate, called, result);
10801}
10802PyObject *CALL_FUNCTION_WITH_ARGS8_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *const *args,
10803 PyObject *const *kw_values, PyObject *kw_names) {
10804 CHECK_OBJECTS(args, 8);
10805 CHECK_OBJECT(kw_names);
10806 assert(PyTuple_CheckExact(kw_names));
10807 CHECK_OBJECT(called);
10808
10809 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10810
10811 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10812
10813 if (Nuitka_Function_Check(called)) {
10814 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10815 return NULL;
10816 }
10817
10818 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
10819
10820 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 8, kw_values, kw_names);
10821
10822 Py_LeaveRecursiveCall();
10823
10824 CHECK_OBJECT_X(result);
10825
10826 return result;
10827#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10828 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10829 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10830
10831 if (likely(func != NULL)) {
10832 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 8 + nkwargs);
10833
10834 memcpy(vectorcall_args, args, 8 * sizeof(PyObject *));
10835 memcpy(&vectorcall_args[8], kw_values, nkwargs * sizeof(PyObject *));
10836
10837 PyObject *result = func(called, vectorcall_args, 8, kw_names);
10838
10839 CHECK_OBJECT_X(result);
10840
10841 return Nuitka_CheckFunctionResult(tstate, called, result);
10842 }
10843#endif
10844 }
10845
10846#if 0
10847 PRINT_STRING("FALLBACK");
10848 PRINT_ITEM(called);
10849 PRINT_NEW_LINE();
10850#endif
10851
10852 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10853
10854 if (unlikely(call_slot == NULL)) {
10855 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
10856
10857 return NULL;
10858 }
10859
10860 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10861 return NULL;
10862 }
10863
10864 PyObject *pos_args = MAKE_TUPLE(tstate, args, 8);
10865
10866 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10867
10868 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10869 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10870
10871 PyObject *value = kw_values[i];
10872
10873 CHECK_OBJECT(key);
10874 CHECK_OBJECT(value);
10875
10876 DICT_SET_ITEM(named_args, key, value);
10877 }
10878
10879 PyObject *result = (*call_slot)(called, pos_args, named_args);
10880
10881 Py_DECREF(pos_args);
10882 Py_DECREF(named_args);
10883
10884 Py_LeaveRecursiveCall();
10885
10886 CHECK_OBJECT_X(result);
10887
10888 return Nuitka_CheckFunctionResult(tstate, called, result);
10889}
10890PyObject *CALL_FUNCTION_WITH_POS_ARGS8_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
10891 PyObject *const *kw_values, PyObject *kw_names) {
10892 assert(PyTuple_CheckExact(pos_args));
10893 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
10894 CHECK_OBJECTS(args, 8);
10895 CHECK_OBJECT(kw_names);
10896 assert(PyTuple_CheckExact(kw_names));
10897 CHECK_OBJECT(called);
10898
10899 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10900
10901 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
10902
10903 if (Nuitka_Function_Check(called)) {
10904 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10905 return NULL;
10906 }
10907
10908 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
10909
10910 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 8, kw_values, kw_names);
10911
10912 Py_LeaveRecursiveCall();
10913
10914 CHECK_OBJECT_X(result);
10915
10916 return result;
10917#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
10918 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
10919 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
10920
10921 if (likely(func != NULL)) {
10922 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 8 + nkwargs);
10923
10924 memcpy(vectorcall_args, args, 8 * sizeof(PyObject *));
10925 memcpy(&vectorcall_args[8], kw_values, nkwargs * sizeof(PyObject *));
10926
10927 PyObject *result = func(called, vectorcall_args, 8, kw_names);
10928
10929 CHECK_OBJECT_X(result);
10930
10931 return Nuitka_CheckFunctionResult(tstate, called, result);
10932 }
10933#endif
10934 }
10935
10936#if 0
10937 PRINT_STRING("FALLBACK");
10938 PRINT_ITEM(called);
10939 PRINT_NEW_LINE();
10940#endif
10941
10942 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
10943
10944 if (unlikely(call_slot == NULL)) {
10945 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
10946
10947 return NULL;
10948 }
10949
10950 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10951 return NULL;
10952 }
10953
10954 PyObject *named_args = _PyDict_NewPresized(nkwargs);
10955
10956 for (Py_ssize_t i = 0; i < nkwargs; i++) {
10957 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
10958
10959 PyObject *value = kw_values[i];
10960
10961 CHECK_OBJECT(key);
10962 CHECK_OBJECT(value);
10963
10964 DICT_SET_ITEM(named_args, key, value);
10965 }
10966
10967 PyObject *result = (*call_slot)(called, pos_args, named_args);
10968
10969 Py_DECREF(named_args);
10970
10971 Py_LeaveRecursiveCall();
10972
10973 CHECK_OBJECT_X(result);
10974
10975 return Nuitka_CheckFunctionResult(tstate, called, result);
10976}
10977PyObject *CALL_FUNCTION_WITH_ARGS9_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *const *args,
10978 PyObject *kw_names) {
10979 CHECK_OBJECTS(args, 9);
10980 CHECK_OBJECT(kw_names);
10981 assert(PyTuple_CheckExact(kw_names));
10982 CHECK_OBJECT(called);
10983
10984 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
10985
10986 CHECK_OBJECTS(&args[9], nkwargs);
10987
10988 if (Nuitka_Function_Check(called)) {
10989 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
10990 return NULL;
10991 }
10992
10993 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
10994
10995 PyObject *result =
10996 Nuitka_CallFunctionVectorcall(tstate, function, args, 9, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
10997
10998 Py_LeaveRecursiveCall();
10999
11000 CHECK_OBJECT_X(result);
11001
11002 return result;
11003#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11004 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11005 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11006
11007 if (likely(func != NULL)) {
11008 PyObject *result = func(called, args, 9, kw_names);
11009
11010 CHECK_OBJECT_X(result);
11011
11012 return Nuitka_CheckFunctionResult(tstate, called, result);
11013 }
11014#endif
11015 }
11016
11017#if 0
11018 PRINT_STRING("FALLBACK");
11019 PRINT_ITEM(called);
11020 PRINT_NEW_LINE();
11021#endif
11022
11023 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11024
11025 if (unlikely(call_slot == NULL)) {
11026 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
11027
11028 return NULL;
11029 }
11030
11031 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
11032 return NULL;
11033 }
11034
11035 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
11036
11037 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11038
11039 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11040 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11041
11042 PyObject *value = args[9 + i];
11043
11044 CHECK_OBJECT(key);
11045 CHECK_OBJECT(value);
11046
11047 DICT_SET_ITEM(named_args, key, value);
11048 }
11049
11050 PyObject *result = (*call_slot)(called, pos_args, named_args);
11051
11052 Py_DECREF(pos_args);
11053 Py_DECREF(named_args);
11054
11055 Py_LeaveRecursiveCall();
11056
11057 CHECK_OBJECT_X(result);
11058
11059 return Nuitka_CheckFunctionResult(tstate, called, result);
11060}
11061PyObject *CALL_FUNCTION_WITH_ARGS9_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *const *args,
11062 PyObject *const *kw_values, PyObject *kw_names) {
11063 CHECK_OBJECTS(args, 9);
11064 CHECK_OBJECT(kw_names);
11065 assert(PyTuple_CheckExact(kw_names));
11066 CHECK_OBJECT(called);
11067
11068 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11069
11070 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11071
11072 if (Nuitka_Function_Check(called)) {
11073 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
11074 return NULL;
11075 }
11076
11077 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
11078
11079 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 9, kw_values, kw_names);
11080
11081 Py_LeaveRecursiveCall();
11082
11083 CHECK_OBJECT_X(result);
11084
11085 return result;
11086#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11087 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11088 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11089
11090 if (likely(func != NULL)) {
11091 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 9 + nkwargs);
11092
11093 memcpy(vectorcall_args, args, 9 * sizeof(PyObject *));
11094 memcpy(&vectorcall_args[9], kw_values, nkwargs * sizeof(PyObject *));
11095
11096 PyObject *result = func(called, vectorcall_args, 9, kw_names);
11097
11098 CHECK_OBJECT_X(result);
11099
11100 return Nuitka_CheckFunctionResult(tstate, called, result);
11101 }
11102#endif
11103 }
11104
11105#if 0
11106 PRINT_STRING("FALLBACK");
11107 PRINT_ITEM(called);
11108 PRINT_NEW_LINE();
11109#endif
11110
11111 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11112
11113 if (unlikely(call_slot == NULL)) {
11114 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
11115
11116 return NULL;
11117 }
11118
11119 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
11120 return NULL;
11121 }
11122
11123 PyObject *pos_args = MAKE_TUPLE(tstate, args, 9);
11124
11125 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11126
11127 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11128 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11129
11130 PyObject *value = kw_values[i];
11131
11132 CHECK_OBJECT(key);
11133 CHECK_OBJECT(value);
11134
11135 DICT_SET_ITEM(named_args, key, value);
11136 }
11137
11138 PyObject *result = (*call_slot)(called, pos_args, named_args);
11139
11140 Py_DECREF(pos_args);
11141 Py_DECREF(named_args);
11142
11143 Py_LeaveRecursiveCall();
11144
11145 CHECK_OBJECT_X(result);
11146
11147 return Nuitka_CheckFunctionResult(tstate, called, result);
11148}
11149PyObject *CALL_FUNCTION_WITH_POS_ARGS9_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
11150 PyObject *const *kw_values, PyObject *kw_names) {
11151 assert(PyTuple_CheckExact(pos_args));
11152 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
11153 CHECK_OBJECTS(args, 9);
11154 CHECK_OBJECT(kw_names);
11155 assert(PyTuple_CheckExact(kw_names));
11156 CHECK_OBJECT(called);
11157
11158 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11159
11160 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11161
11162 if (Nuitka_Function_Check(called)) {
11163 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
11164 return NULL;
11165 }
11166
11167 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
11168
11169 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 9, kw_values, kw_names);
11170
11171 Py_LeaveRecursiveCall();
11172
11173 CHECK_OBJECT_X(result);
11174
11175 return result;
11176#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11177 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11178 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11179
11180 if (likely(func != NULL)) {
11181 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 9 + nkwargs);
11182
11183 memcpy(vectorcall_args, args, 9 * sizeof(PyObject *));
11184 memcpy(&vectorcall_args[9], kw_values, nkwargs * sizeof(PyObject *));
11185
11186 PyObject *result = func(called, vectorcall_args, 9, kw_names);
11187
11188 CHECK_OBJECT_X(result);
11189
11190 return Nuitka_CheckFunctionResult(tstate, called, result);
11191 }
11192#endif
11193 }
11194
11195#if 0
11196 PRINT_STRING("FALLBACK");
11197 PRINT_ITEM(called);
11198 PRINT_NEW_LINE();
11199#endif
11200
11201 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11202
11203 if (unlikely(call_slot == NULL)) {
11204 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
11205
11206 return NULL;
11207 }
11208
11209 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
11210 return NULL;
11211 }
11212
11213 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11214
11215 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11216 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11217
11218 PyObject *value = kw_values[i];
11219
11220 CHECK_OBJECT(key);
11221 CHECK_OBJECT(value);
11222
11223 DICT_SET_ITEM(named_args, key, value);
11224 }
11225
11226 PyObject *result = (*call_slot)(called, pos_args, named_args);
11227
11228 Py_DECREF(named_args);
11229
11230 Py_LeaveRecursiveCall();
11231
11232 CHECK_OBJECT_X(result);
11233
11234 return Nuitka_CheckFunctionResult(tstate, called, result);
11235}
11236PyObject *CALL_FUNCTION_WITH_ARGS10_VECTORCALL(PyThreadState *tstate, PyObject *called, PyObject *const *args,
11237 PyObject *kw_names) {
11238 CHECK_OBJECTS(args, 10);
11239 CHECK_OBJECT(kw_names);
11240 assert(PyTuple_CheckExact(kw_names));
11241 CHECK_OBJECT(called);
11242
11243 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11244
11245 CHECK_OBJECTS(&args[10], nkwargs);
11246
11247 if (Nuitka_Function_Check(called)) {
11248 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
11249 return NULL;
11250 }
11251
11252 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
11253
11254 PyObject *result =
11255 Nuitka_CallFunctionVectorcall(tstate, function, args, 10, &PyTuple_GET_ITEM(kw_names, 0), nkwargs);
11256
11257 Py_LeaveRecursiveCall();
11258
11259 CHECK_OBJECT_X(result);
11260
11261 return result;
11262#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11263 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11264 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11265
11266 if (likely(func != NULL)) {
11267 PyObject *result = func(called, args, 10, kw_names);
11268
11269 CHECK_OBJECT_X(result);
11270
11271 return Nuitka_CheckFunctionResult(tstate, called, result);
11272 }
11273#endif
11274 }
11275
11276#if 0
11277 PRINT_STRING("FALLBACK");
11278 PRINT_ITEM(called);
11279 PRINT_NEW_LINE();
11280#endif
11281
11282 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11283
11284 if (unlikely(call_slot == NULL)) {
11285 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
11286
11287 return NULL;
11288 }
11289
11290 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
11291 return NULL;
11292 }
11293
11294 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
11295
11296 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11297
11298 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11299 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11300
11301 PyObject *value = args[10 + i];
11302
11303 CHECK_OBJECT(key);
11304 CHECK_OBJECT(value);
11305
11306 DICT_SET_ITEM(named_args, key, value);
11307 }
11308
11309 PyObject *result = (*call_slot)(called, pos_args, named_args);
11310
11311 Py_DECREF(pos_args);
11312 Py_DECREF(named_args);
11313
11314 Py_LeaveRecursiveCall();
11315
11316 CHECK_OBJECT_X(result);
11317
11318 return Nuitka_CheckFunctionResult(tstate, called, result);
11319}
11320PyObject *CALL_FUNCTION_WITH_ARGS10_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *const *args,
11321 PyObject *const *kw_values, PyObject *kw_names) {
11322 CHECK_OBJECTS(args, 10);
11323 CHECK_OBJECT(kw_names);
11324 assert(PyTuple_CheckExact(kw_names));
11325 CHECK_OBJECT(called);
11326
11327 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11328
11329 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11330
11331 if (Nuitka_Function_Check(called)) {
11332 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
11333 return NULL;
11334 }
11335
11336 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
11337
11338 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 10, kw_values, kw_names);
11339
11340 Py_LeaveRecursiveCall();
11341
11342 CHECK_OBJECT_X(result);
11343
11344 return result;
11345#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11346 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11347 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11348
11349 if (likely(func != NULL)) {
11350 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 10 + nkwargs);
11351
11352 memcpy(vectorcall_args, args, 10 * sizeof(PyObject *));
11353 memcpy(&vectorcall_args[10], kw_values, nkwargs * sizeof(PyObject *));
11354
11355 PyObject *result = func(called, vectorcall_args, 10, kw_names);
11356
11357 CHECK_OBJECT_X(result);
11358
11359 return Nuitka_CheckFunctionResult(tstate, called, result);
11360 }
11361#endif
11362 }
11363
11364#if 0
11365 PRINT_STRING("FALLBACK");
11366 PRINT_ITEM(called);
11367 PRINT_NEW_LINE();
11368#endif
11369
11370 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11371
11372 if (unlikely(call_slot == NULL)) {
11373 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
11374
11375 return NULL;
11376 }
11377
11378 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
11379 return NULL;
11380 }
11381
11382 PyObject *pos_args = MAKE_TUPLE(tstate, args, 10);
11383
11384 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11385
11386 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11387 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11388
11389 PyObject *value = kw_values[i];
11390
11391 CHECK_OBJECT(key);
11392 CHECK_OBJECT(value);
11393
11394 DICT_SET_ITEM(named_args, key, value);
11395 }
11396
11397 PyObject *result = (*call_slot)(called, pos_args, named_args);
11398
11399 Py_DECREF(pos_args);
11400 Py_DECREF(named_args);
11401
11402 Py_LeaveRecursiveCall();
11403
11404 CHECK_OBJECT_X(result);
11405
11406 return Nuitka_CheckFunctionResult(tstate, called, result);
11407}
11408PyObject *CALL_FUNCTION_WITH_POS_ARGS10_KW_SPLIT(PyThreadState *tstate, PyObject *called, PyObject *pos_args,
11409 PyObject *const *kw_values, PyObject *kw_names) {
11410 assert(PyTuple_CheckExact(pos_args));
11411 PyObject *const *args = &PyTuple_GET_ITEM(pos_args, 0);
11412 CHECK_OBJECTS(args, 10);
11413 CHECK_OBJECT(kw_names);
11414 assert(PyTuple_CheckExact(kw_names));
11415 CHECK_OBJECT(called);
11416
11417 Py_ssize_t nkwargs = PyTuple_GET_SIZE(kw_names);
11418
11419 CHECK_OBJECTS(kw_values, PyTuple_GET_SIZE(kw_names));
11420
11421 if (Nuitka_Function_Check(called)) {
11422 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
11423 return NULL;
11424 }
11425
11426 struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called;
11427
11428 PyObject *result = Nuitka_CallFunctionPosArgsKwSplit(tstate, function, args, 10, kw_values, kw_names);
11429
11430 Py_LeaveRecursiveCall();
11431
11432 CHECK_OBJECT_X(result);
11433
11434 return result;
11435#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11436 } else if (PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL)) {
11437 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11438
11439 if (likely(func != NULL)) {
11440 NUITKA_DYNAMIC_ARRAY_DECL(vectorcall_args, PyObject *, 10 + nkwargs);
11441
11442 memcpy(vectorcall_args, args, 10 * sizeof(PyObject *));
11443 memcpy(&vectorcall_args[10], kw_values, nkwargs * sizeof(PyObject *));
11444
11445 PyObject *result = func(called, vectorcall_args, 10, kw_names);
11446
11447 CHECK_OBJECT_X(result);
11448
11449 return Nuitka_CheckFunctionResult(tstate, called, result);
11450 }
11451#endif
11452 }
11453
11454#if 0
11455 PRINT_STRING("FALLBACK");
11456 PRINT_ITEM(called);
11457 PRINT_NEW_LINE();
11458#endif
11459
11460 ternaryfunc call_slot = Py_TYPE(called)->tp_call;
11461
11462 if (unlikely(call_slot == NULL)) {
11463 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("'%s' object is not callable", called);
11464
11465 return NULL;
11466 }
11467
11468 if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) {
11469 return NULL;
11470 }
11471
11472 PyObject *named_args = _PyDict_NewPresized(nkwargs);
11473
11474 for (Py_ssize_t i = 0; i < nkwargs; i++) {
11475 PyObject *key = PyTuple_GET_ITEM(kw_names, i);
11476
11477 PyObject *value = kw_values[i];
11478
11479 CHECK_OBJECT(key);
11480 CHECK_OBJECT(value);
11481
11482 DICT_SET_ITEM(named_args, key, value);
11483 }
11484
11485 PyObject *result = (*call_slot)(called, pos_args, named_args);
11486
11487 Py_DECREF(named_args);
11488
11489 Py_LeaveRecursiveCall();
11490
11491 CHECK_OBJECT_X(result);
11492
11493 return Nuitka_CheckFunctionResult(tstate, called, result);
11494}
11495PyObject *CALL_METHODDESCR_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *called, PyObject *arg) {
11496 PyObject *const *args = &arg; // For easier code compatibility.
11497 CHECK_OBJECT(called);
11498 CHECK_OBJECTS(args, 1);
11499
11500#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11501 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11502 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11503 assert(func != NULL);
11504 PyObject *result = func(called, args, 1, NULL);
11505
11506#ifndef __NUITKA_NO_ASSERT__
11507 return Nuitka_CheckFunctionResult(tstate, called, result);
11508#else
11509 return result;
11510#endif
11511#else
11512 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11513 PyMethodDef *method_def = called_descr->d_method;
11514
11515 // Try to be fast about wrapping the arguments.
11516 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11517
11518 if (likely(flags & METH_NOARGS)) {
11519 PyCFunction method = method_def->ml_meth;
11520 PyObject *self = args[0];
11521
11522 PyObject *result = (*method)(self, NULL);
11523
11524#ifndef __NUITKA_NO_ASSERT__
11525 return Nuitka_CheckFunctionResult(tstate, called, result);
11526#else
11527 return result;
11528#endif
11529 } else if ((flags & METH_O)) {
11530 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (1 given)",
11531 method_def->ml_name);
11532 return NULL;
11533 } else if (flags & METH_VARARGS) {
11534 PyCFunction method = method_def->ml_meth;
11535 PyObject *self = args[0];
11536
11537 PyObject *result;
11538
11539#if PYTHON_VERSION < 0x360
11540 if (flags & METH_KEYWORDS) {
11541 result = (*(PyCFunctionWithKeywords)method)(self, const_tuple_empty, NULL);
11542 } else {
11543 result = (*method)(self, const_tuple_empty);
11544 }
11545#else
11546 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11547 result = (*(PyCFunctionWithKeywords)method)(self, const_tuple_empty, NULL);
11548 } else if (flags == METH_FASTCALL) {
11549#if PYTHON_VERSION < 0x370
11550 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 0, NULL);
11551#else
11552 result = (*(_PyCFunctionFast)method)(self, &const_tuple_empty, 1);
11553#endif
11554 } else {
11555 result = (*method)(self, const_tuple_empty);
11556 }
11557#endif
11558#ifndef __NUITKA_NO_ASSERT__
11559 return Nuitka_CheckFunctionResult(tstate, called, result);
11560#else
11561 return result;
11562#endif
11563 }
11564
11565#if 0
11566 PRINT_NEW_LINE();
11567 PRINT_STRING("FALLBACK");
11568 PRINT_ITEM(called);
11569 PRINT_NEW_LINE();
11570#endif
11571
11572 PyObject *pos_args = MAKE_TUPLE(tstate, args, 1);
11573
11574 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11575
11576 Py_DECREF(pos_args);
11577
11578 return result;
11579#endif
11580}
11581PyObject *CALL_METHODDESCR_WITH_ARGS2(PyThreadState *tstate, PyObject *called, PyObject *const *args) {
11582 CHECK_OBJECT(called);
11583 CHECK_OBJECTS(args, 2);
11584
11585#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11586 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11587 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11588 assert(func != NULL);
11589 PyObject *result = func(called, args, 2, NULL);
11590
11591#ifndef __NUITKA_NO_ASSERT__
11592 return Nuitka_CheckFunctionResult(tstate, called, result);
11593#else
11594 return result;
11595#endif
11596#else
11597 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11598 PyMethodDef *method_def = called_descr->d_method;
11599
11600 // Try to be fast about wrapping the arguments.
11601 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11602
11603 if (unlikely(flags & METH_NOARGS)) {
11604 PyCFunction method = method_def->ml_meth;
11605 PyObject *self = args[0];
11606
11607 PyObject *result = (*method)(self, NULL);
11608
11609#ifndef __NUITKA_NO_ASSERT__
11610 return Nuitka_CheckFunctionResult(tstate, called, result);
11611#else
11612 return result;
11613#endif
11614 } else if (unlikely(flags & METH_O)) {
11615 PyCFunction method = method_def->ml_meth;
11616 PyObject *self = args[0];
11617
11618 PyObject *result = (*method)(self, args[1]);
11619
11620#ifndef __NUITKA_NO_ASSERT__
11621 return Nuitka_CheckFunctionResult(tstate, called, result);
11622#else
11623 return result;
11624#endif
11625 } else if (flags & METH_VARARGS) {
11626 PyCFunction method = method_def->ml_meth;
11627 PyObject *self = args[0];
11628
11629 PyObject *result;
11630
11631#if PYTHON_VERSION < 0x360
11632 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11633
11634 if (flags & METH_KEYWORDS) {
11635 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11636 } else {
11637 result = (*method)(self, pos_args);
11638 }
11639
11640 Py_DECREF(pos_args);
11641#else
11642 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11643 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11644 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11645 Py_DECREF(pos_args);
11646 } else if (flags == METH_FASTCALL) {
11647#if PYTHON_VERSION < 0x370
11648 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 1, NULL);
11649#else
11650 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11651 result = (*(_PyCFunctionFast)method)(self, &pos_args, 2);
11652 Py_DECREF(pos_args);
11653#endif
11654 } else {
11655 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 1);
11656 result = (*method)(self, pos_args);
11657 Py_DECREF(pos_args);
11658 }
11659#endif
11660#ifndef __NUITKA_NO_ASSERT__
11661 return Nuitka_CheckFunctionResult(tstate, called, result);
11662#else
11663 return result;
11664#endif
11665 }
11666
11667#if 0
11668 PRINT_NEW_LINE();
11669 PRINT_STRING("FALLBACK");
11670 PRINT_ITEM(called);
11671 PRINT_NEW_LINE();
11672#endif
11673
11674 PyObject *pos_args = MAKE_TUPLE(tstate, args, 2);
11675
11676 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11677
11678 Py_DECREF(pos_args);
11679
11680 return result;
11681#endif
11682}
11683PyObject *CALL_METHODDESCR_WITH_ARGS3(PyThreadState *tstate, PyObject *called, PyObject *const *args) {
11684 CHECK_OBJECT(called);
11685 CHECK_OBJECTS(args, 3);
11686
11687#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11688 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11689 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11690 assert(func != NULL);
11691 PyObject *result = func(called, args, 3, NULL);
11692
11693#ifndef __NUITKA_NO_ASSERT__
11694 return Nuitka_CheckFunctionResult(tstate, called, result);
11695#else
11696 return result;
11697#endif
11698#else
11699 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11700 PyMethodDef *method_def = called_descr->d_method;
11701
11702 // Try to be fast about wrapping the arguments.
11703 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11704
11705 if (unlikely(flags & METH_NOARGS)) {
11706 PyCFunction method = method_def->ml_meth;
11707 PyObject *self = args[0];
11708
11709 PyObject *result = (*method)(self, NULL);
11710
11711#ifndef __NUITKA_NO_ASSERT__
11712 return Nuitka_CheckFunctionResult(tstate, called, result);
11713#else
11714 return result;
11715#endif
11716 } else if (unlikely(flags & METH_O)) {
11717 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (3 given)",
11718 method_def->ml_name);
11719 return NULL;
11720 } else if (flags & METH_VARARGS) {
11721 PyCFunction method = method_def->ml_meth;
11722 PyObject *self = args[0];
11723
11724 PyObject *result;
11725
11726#if PYTHON_VERSION < 0x360
11727 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11728
11729 if (flags & METH_KEYWORDS) {
11730 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11731 } else {
11732 result = (*method)(self, pos_args);
11733 }
11734
11735 Py_DECREF(pos_args);
11736#else
11737 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11738 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11739 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11740 Py_DECREF(pos_args);
11741 } else if (flags == METH_FASTCALL) {
11742#if PYTHON_VERSION < 0x370
11743 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 2, NULL);
11744#else
11745 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11746 result = (*(_PyCFunctionFast)method)(self, &pos_args, 3);
11747 Py_DECREF(pos_args);
11748#endif
11749 } else {
11750 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 2);
11751 result = (*method)(self, pos_args);
11752 Py_DECREF(pos_args);
11753 }
11754#endif
11755#ifndef __NUITKA_NO_ASSERT__
11756 return Nuitka_CheckFunctionResult(tstate, called, result);
11757#else
11758 return result;
11759#endif
11760 }
11761
11762#if 0
11763 PRINT_NEW_LINE();
11764 PRINT_STRING("FALLBACK");
11765 PRINT_ITEM(called);
11766 PRINT_NEW_LINE();
11767#endif
11768
11769 PyObject *pos_args = MAKE_TUPLE(tstate, args, 3);
11770
11771 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11772
11773 Py_DECREF(pos_args);
11774
11775 return result;
11776#endif
11777}
11778PyObject *CALL_METHODDESCR_WITH_ARGS4(PyThreadState *tstate, PyObject *called, PyObject *const *args) {
11779 CHECK_OBJECT(called);
11780 CHECK_OBJECTS(args, 4);
11781
11782#if PYTHON_VERSION >= 0x380 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_VECTORCALL_USAGE)
11783 assert(PyType_HasFeature(Py_TYPE(called), _Py_TPFLAGS_HAVE_VECTORCALL));
11784 vectorcallfunc func = *((vectorcallfunc *)(((char *)called) + Py_TYPE(called)->tp_vectorcall_offset));
11785 assert(func != NULL);
11786 PyObject *result = func(called, args, 4, NULL);
11787
11788#ifndef __NUITKA_NO_ASSERT__
11789 return Nuitka_CheckFunctionResult(tstate, called, result);
11790#else
11791 return result;
11792#endif
11793#else
11794 PyMethodDescrObject *called_descr = (PyMethodDescrObject *)called;
11795 PyMethodDef *method_def = called_descr->d_method;
11796
11797 // Try to be fast about wrapping the arguments.
11798 int flags = method_def->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
11799
11800 if (unlikely(flags & METH_NOARGS)) {
11801 PyCFunction method = method_def->ml_meth;
11802 PyObject *self = args[0];
11803
11804 PyObject *result = (*method)(self, NULL);
11805
11806#ifndef __NUITKA_NO_ASSERT__
11807 return Nuitka_CheckFunctionResult(tstate, called, result);
11808#else
11809 return result;
11810#endif
11811 } else if (unlikely(flags & METH_O)) {
11812 SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, "%s() takes exactly one argument (4 given)",
11813 method_def->ml_name);
11814 return NULL;
11815 } else if (flags & METH_VARARGS) {
11816 PyCFunction method = method_def->ml_meth;
11817 PyObject *self = args[0];
11818
11819 PyObject *result;
11820
11821#if PYTHON_VERSION < 0x360
11822 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11823
11824 if (flags & METH_KEYWORDS) {
11825 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11826 } else {
11827 result = (*method)(self, pos_args);
11828 }
11829
11830 Py_DECREF(pos_args);
11831#else
11832 if (flags == (METH_VARARGS | METH_KEYWORDS)) {
11833 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11834 result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL);
11835 Py_DECREF(pos_args);
11836 } else if (flags == METH_FASTCALL) {
11837#if PYTHON_VERSION < 0x370
11838 result = (*(_PyCFunctionFast)method)(self, (PyObject **)args + 1, 3, NULL);
11839#else
11840 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11841 result = (*(_PyCFunctionFast)method)(self, &pos_args, 4);
11842 Py_DECREF(pos_args);
11843#endif
11844 } else {
11845 PyObject *pos_args = MAKE_TUPLE(tstate, args + 1, 3);
11846 result = (*method)(self, pos_args);
11847 Py_DECREF(pos_args);
11848 }
11849#endif
11850#ifndef __NUITKA_NO_ASSERT__
11851 return Nuitka_CheckFunctionResult(tstate, called, result);
11852#else
11853 return result;
11854#endif
11855 }
11856
11857#if 0
11858 PRINT_NEW_LINE();
11859 PRINT_STRING("FALLBACK");
11860 PRINT_ITEM(called);
11861 PRINT_NEW_LINE();
11862#endif
11863
11864 PyObject *pos_args = MAKE_TUPLE(tstate, args, 4);
11865
11866 PyObject *result = CALL_FUNCTION(tstate, called, pos_args, NULL);
11867
11868 Py_DECREF(pos_args);
11869
11870 return result;
11871#endif
11872}
11873PyObject *CALL_METHOD_NO_ARGS(PyThreadState *tstate, PyObject *source, PyObject *attr_name) {
11874 CHECK_OBJECT(source);
11875 CHECK_OBJECT(attr_name);
11876
11877 PyTypeObject *type = Py_TYPE(source);
11878
11879 if (hasTypeGenericGetAttr(type)) {
11880 // Unfortunately this is required, although of cause rarely necessary.
11881 if (unlikely(type->tp_dict == NULL)) {
11882 if (unlikely(PyType_Ready(type) < 0)) {
11883 return NULL;
11884 }
11885 }
11886
11887 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
11888 descrgetfunc func = NULL;
11889
11890 if (descr != NULL) {
11891 Py_INCREF(descr);
11892
11893 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
11894 func = Py_TYPE(descr)->tp_descr_get;
11895
11896 if (func != NULL && Nuitka_Descr_IsData(descr)) {
11897 PyObject *called_object = func(descr, source, (PyObject *)type);
11898 Py_DECREF(descr);
11899
11900 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
11901 Py_DECREF(called_object);
11902 return result;
11903 }
11904 }
11905 }
11906
11907 Py_ssize_t dictoffset = type->tp_dictoffset;
11908 PyObject *dict = NULL;
11909
11910 if (dictoffset != 0) {
11911 // Negative dictionary offsets have special meaning.
11912 if (dictoffset < 0) {
11913 Py_ssize_t tsize;
11914 size_t size;
11915
11916 tsize = ((PyVarObject *)source)->ob_size;
11917 if (tsize < 0) {
11918 tsize = -tsize;
11919 }
11920 size = _PyObject_VAR_SIZE(type, tsize);
11921
11922 dictoffset += (long)size;
11923 }
11924
11925 PyObject **dictptr = (PyObject **)((char *)source + dictoffset);
11926 dict = *dictptr;
11927 }
11928
11929 if (dict != NULL) {
11930 CHECK_OBJECT(dict);
11931
11932 Py_INCREF(dict);
11933
11934 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
11935
11936 if (called_object != NULL) {
11937 Py_XDECREF(descr);
11938 Py_DECREF(dict);
11939
11940 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
11941 Py_DECREF(called_object);
11942 return result;
11943 }
11944
11945 Py_DECREF(dict);
11946 }
11947
11948 if (func != NULL) {
11949 if (func == Nuitka_Function_Type.tp_descr_get) {
11950 PyObject *result =
11951 Nuitka_CallMethodFunctionNoArgs(tstate, (struct Nuitka_FunctionObject const *)descr, source);
11952 Py_DECREF(descr);
11953
11954 return result;
11955 } else {
11956 PyObject *called_object = func(descr, source, (PyObject *)type);
11957 CHECK_OBJECT(called_object);
11958
11959 Py_DECREF(descr);
11960
11961 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
11962 Py_DECREF(called_object);
11963 return result;
11964 }
11965 }
11966
11967 if (descr != NULL) {
11968 CHECK_OBJECT(descr);
11969
11970 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, descr);
11971 Py_DECREF(descr);
11972 return result;
11973 }
11974
11975#if PYTHON_VERSION < 0x300
11976 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
11977 PyString_AS_STRING(attr_name));
11978#else
11979 PyErr_Format(PyExc_AttributeError, "'%s' object has no attribute '%U'", type->tp_name, attr_name);
11980#endif
11981 return NULL;
11982 }
11983#if PYTHON_VERSION < 0x300
11984 else if (type == &PyInstance_Type) {
11985 PyInstanceObject *source_instance = (PyInstanceObject *)source;
11986
11987 // The special cases have their own variant on the code generation level
11988 // as we are called with constants only.
11989 assert(attr_name != const_str_plain___dict__);
11990 assert(attr_name != const_str_plain___class__);
11991
11992 // Try the instance dict first.
11993 PyObject *called_object =
11994 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
11995
11996 // Note: The "called_object" was found without taking a reference,
11997 // so we need not release it in this branch.
11998 if (called_object != NULL) {
11999 return CALL_FUNCTION_NO_ARGS(tstate, called_object);
12000 }
12001
12002 // Then check the class dictionaries.
12003 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12004
12005 // Note: The "called_object" was found without taking a reference,
12006 // so we need not release it in this branch.
12007 if (called_object != NULL) {
12008 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12009
12010 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12011 return Nuitka_CallMethodFunctionNoArgs(tstate, (struct Nuitka_FunctionObject const *)called_object,
12012 source);
12013 } else if (descr_get != NULL) {
12014 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12015
12016 if (unlikely(method == NULL)) {
12017 return NULL;
12018 }
12019
12020 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, method);
12021 Py_DECREF(method);
12022 return result;
12023 } else {
12024 return CALL_FUNCTION_NO_ARGS(tstate, called_object);
12025 }
12026
12027 } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12028 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "%s instance has no attribute '%s'",
12029 PyString_AS_STRING(source_instance->in_class->cl_name),
12030 PyString_AS_STRING(attr_name));
12031
12032 return NULL;
12033 } else {
12034 // Finally allow the "__getattr__" override to provide it or else
12035 // it's an error.
12036
12037 PyObject *args2[] = {source, attr_name};
12038
12039 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12040
12041 if (unlikely(called_object == NULL)) {
12042 return NULL;
12043 }
12044
12045 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
12046 Py_DECREF(called_object);
12047 return result;
12048 }
12049 }
12050#endif
12051 else if (type->tp_getattro != NULL) {
12052 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12053
12054 if (unlikely(descr == NULL)) {
12055 return NULL;
12056 }
12057
12058 descrgetfunc func = NULL;
12059 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12060 func = Py_TYPE(descr)->tp_descr_get;
12061
12062 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12063 PyObject *called_object = func(descr, source, (PyObject *)type);
12064 Py_DECREF(descr);
12065
12066 if (unlikely(called_object == NULL)) {
12067 return NULL;
12068 }
12069
12070 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
12071 Py_DECREF(called_object);
12072 return result;
12073 }
12074 }
12075
12076 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, descr);
12077 Py_DECREF(descr);
12078 return result;
12079 } else if (type->tp_getattr != NULL) {
12080 PyObject *called_object = (*type->tp_getattr)(source, (char *)Nuitka_String_AsString_Unchecked(attr_name));
12081
12082 if (unlikely(called_object == NULL)) {
12083 return NULL;
12084 }
12085
12086 PyObject *result = CALL_FUNCTION_NO_ARGS(tstate, called_object);
12087 Py_DECREF(called_object);
12088 return result;
12089 } else {
12090 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
12091 Nuitka_String_AsString_Unchecked(attr_name));
12092
12093 return NULL;
12094 }
12095}
12096PyObject *CALL_METHOD_WITH_SINGLE_ARG(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *arg) {
12097 PyObject *const *args = &arg; // For easier code compatibility.
12098 CHECK_OBJECT(source);
12099 CHECK_OBJECT(attr_name);
12100
12101 CHECK_OBJECTS(args, 1);
12102
12103 PyTypeObject *type = Py_TYPE(source);
12104
12105 if (hasTypeGenericGetAttr(type)) {
12106 // Unfortunately this is required, although of cause rarely necessary.
12107 if (unlikely(type->tp_dict == NULL)) {
12108 if (unlikely(PyType_Ready(type) < 0)) {
12109 return NULL;
12110 }
12111 }
12112
12113 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12114 descrgetfunc func = NULL;
12115
12116 if (descr != NULL) {
12117 Py_INCREF(descr);
12118
12119 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12120 func = Py_TYPE(descr)->tp_descr_get;
12121
12122 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12123 PyObject *called_object = func(descr, source, (PyObject *)type);
12124 Py_DECREF(descr);
12125
12126 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12127 Py_DECREF(called_object);
12128 return result;
12129 }
12130 }
12131 }
12132
12133 Py_ssize_t dictoffset = type->tp_dictoffset;
12134 PyObject *dict = NULL;
12135
12136 if (dictoffset != 0) {
12137 // Negative dictionary offsets have special meaning.
12138 if (dictoffset < 0) {
12139 Py_ssize_t tsize;
12140 size_t size;
12141
12142 tsize = ((PyVarObject *)source)->ob_size;
12143 if (tsize < 0) {
12144 tsize = -tsize;
12145 }
12146 size = _PyObject_VAR_SIZE(type, tsize);
12147
12148 dictoffset += (long)size;
12149 }
12150
12151 PyObject **dictptr = (PyObject **)((char *)source + dictoffset);
12152 dict = *dictptr;
12153 }
12154
12155 if (dict != NULL) {
12156 CHECK_OBJECT(dict);
12157
12158 Py_INCREF(dict);
12159
12160 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12161
12162 if (called_object != NULL) {
12163 Py_XDECREF(descr);
12164 Py_DECREF(dict);
12165
12166 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12167 Py_DECREF(called_object);
12168 return result;
12169 }
12170
12171 Py_DECREF(dict);
12172 }
12173
12174 if (func != NULL) {
12175 if (func == Nuitka_Function_Type.tp_descr_get) {
12176 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)descr,
12177 source, args, 1);
12178 Py_DECREF(descr);
12179
12180 return result;
12181 } else {
12182 PyObject *called_object = func(descr, source, (PyObject *)type);
12183 CHECK_OBJECT(called_object);
12184
12185 Py_DECREF(descr);
12186
12187 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12188 Py_DECREF(called_object);
12189 return result;
12190 }
12191 }
12192
12193 if (descr != NULL) {
12194 CHECK_OBJECT(descr);
12195
12196 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, descr, args[0]);
12197 Py_DECREF(descr);
12198 return result;
12199 }
12200
12201#if PYTHON_VERSION < 0x300
12202 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
12203 PyString_AS_STRING(attr_name));
12204#else
12205 PyErr_Format(PyExc_AttributeError, "'%s' object has no attribute '%U'", type->tp_name, attr_name);
12206#endif
12207 return NULL;
12208 }
12209#if PYTHON_VERSION < 0x300
12210 else if (type == &PyInstance_Type) {
12211 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12212
12213 // The special cases have their own variant on the code generation level
12214 // as we are called with constants only.
12215 assert(attr_name != const_str_plain___dict__);
12216 assert(attr_name != const_str_plain___class__);
12217
12218 // Try the instance dict first.
12219 PyObject *called_object =
12220 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12221
12222 // Note: The "called_object" was found without taking a reference,
12223 // so we need not release it in this branch.
12224 if (called_object != NULL) {
12225 return CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12226 }
12227
12228 // Then check the class dictionaries.
12229 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12230
12231 // Note: The "called_object" was found without taking a reference,
12232 // so we need not release it in this branch.
12233 if (called_object != NULL) {
12234 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12235
12236 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12237 return Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)called_object,
12238 source, args, 1);
12239 } else if (descr_get != NULL) {
12240 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12241
12242 if (unlikely(method == NULL)) {
12243 return NULL;
12244 }
12245
12246 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, method, args[0]);
12247 Py_DECREF(method);
12248 return result;
12249 } else {
12250 return CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12251 }
12252
12253 } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12254 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "%s instance has no attribute '%s'",
12255 PyString_AS_STRING(source_instance->in_class->cl_name),
12256 PyString_AS_STRING(attr_name));
12257
12258 return NULL;
12259 } else {
12260 // Finally allow the "__getattr__" override to provide it or else
12261 // it's an error.
12262
12263 PyObject *args2[] = {source, attr_name};
12264
12265 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12266
12267 if (unlikely(called_object == NULL)) {
12268 return NULL;
12269 }
12270
12271 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12272 Py_DECREF(called_object);
12273 return result;
12274 }
12275 }
12276#endif
12277 else if (type->tp_getattro != NULL) {
12278 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12279
12280 if (unlikely(descr == NULL)) {
12281 return NULL;
12282 }
12283
12284 descrgetfunc func = NULL;
12285 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12286 func = Py_TYPE(descr)->tp_descr_get;
12287
12288 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12289 PyObject *called_object = func(descr, source, (PyObject *)type);
12290 Py_DECREF(descr);
12291
12292 if (unlikely(called_object == NULL)) {
12293 return NULL;
12294 }
12295
12296 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12297 Py_DECREF(called_object);
12298 return result;
12299 }
12300 }
12301
12302 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, descr, args[0]);
12303 Py_DECREF(descr);
12304 return result;
12305 } else if (type->tp_getattr != NULL) {
12306 PyObject *called_object = (*type->tp_getattr)(source, (char *)Nuitka_String_AsString_Unchecked(attr_name));
12307
12308 if (unlikely(called_object == NULL)) {
12309 return NULL;
12310 }
12311
12312 PyObject *result = CALL_FUNCTION_WITH_SINGLE_ARG(tstate, called_object, args[0]);
12313 Py_DECREF(called_object);
12314 return result;
12315 } else {
12316 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
12317 Nuitka_String_AsString_Unchecked(attr_name));
12318
12319 return NULL;
12320 }
12321}
12322PyObject *CALL_METHOD_WITH_ARGS2(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *const *args) {
12323 CHECK_OBJECT(source);
12324 CHECK_OBJECT(attr_name);
12325
12326 CHECK_OBJECTS(args, 2);
12327
12328 PyTypeObject *type = Py_TYPE(source);
12329
12330 if (hasTypeGenericGetAttr(type)) {
12331 // Unfortunately this is required, although of cause rarely necessary.
12332 if (unlikely(type->tp_dict == NULL)) {
12333 if (unlikely(PyType_Ready(type) < 0)) {
12334 return NULL;
12335 }
12336 }
12337
12338 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12339 descrgetfunc func = NULL;
12340
12341 if (descr != NULL) {
12342 Py_INCREF(descr);
12343
12344 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12345 func = Py_TYPE(descr)->tp_descr_get;
12346
12347 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12348 PyObject *called_object = func(descr, source, (PyObject *)type);
12349 Py_DECREF(descr);
12350
12351 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12352 Py_DECREF(called_object);
12353 return result;
12354 }
12355 }
12356 }
12357
12358 Py_ssize_t dictoffset = type->tp_dictoffset;
12359 PyObject *dict = NULL;
12360
12361 if (dictoffset != 0) {
12362 // Negative dictionary offsets have special meaning.
12363 if (dictoffset < 0) {
12364 Py_ssize_t tsize;
12365 size_t size;
12366
12367 tsize = ((PyVarObject *)source)->ob_size;
12368 if (tsize < 0) {
12369 tsize = -tsize;
12370 }
12371 size = _PyObject_VAR_SIZE(type, tsize);
12372
12373 dictoffset += (long)size;
12374 }
12375
12376 PyObject **dictptr = (PyObject **)((char *)source + dictoffset);
12377 dict = *dictptr;
12378 }
12379
12380 if (dict != NULL) {
12381 CHECK_OBJECT(dict);
12382
12383 Py_INCREF(dict);
12384
12385 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12386
12387 if (called_object != NULL) {
12388 Py_XDECREF(descr);
12389 Py_DECREF(dict);
12390
12391 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12392 Py_DECREF(called_object);
12393 return result;
12394 }
12395
12396 Py_DECREF(dict);
12397 }
12398
12399 if (func != NULL) {
12400 if (func == Nuitka_Function_Type.tp_descr_get) {
12401 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)descr,
12402 source, args, 2);
12403 Py_DECREF(descr);
12404
12405 return result;
12406 } else {
12407 PyObject *called_object = func(descr, source, (PyObject *)type);
12408 CHECK_OBJECT(called_object);
12409
12410 Py_DECREF(descr);
12411
12412 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12413 Py_DECREF(called_object);
12414 return result;
12415 }
12416 }
12417
12418 if (descr != NULL) {
12419 CHECK_OBJECT(descr);
12420
12421 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, descr, args);
12422 Py_DECREF(descr);
12423 return result;
12424 }
12425
12426#if PYTHON_VERSION < 0x300
12427 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
12428 PyString_AS_STRING(attr_name));
12429#else
12430 PyErr_Format(PyExc_AttributeError, "'%s' object has no attribute '%U'", type->tp_name, attr_name);
12431#endif
12432 return NULL;
12433 }
12434#if PYTHON_VERSION < 0x300
12435 else if (type == &PyInstance_Type) {
12436 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12437
12438 // The special cases have their own variant on the code generation level
12439 // as we are called with constants only.
12440 assert(attr_name != const_str_plain___dict__);
12441 assert(attr_name != const_str_plain___class__);
12442
12443 // Try the instance dict first.
12444 PyObject *called_object =
12445 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12446
12447 // Note: The "called_object" was found without taking a reference,
12448 // so we need not release it in this branch.
12449 if (called_object != NULL) {
12450 return CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12451 }
12452
12453 // Then check the class dictionaries.
12454 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12455
12456 // Note: The "called_object" was found without taking a reference,
12457 // so we need not release it in this branch.
12458 if (called_object != NULL) {
12459 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12460
12461 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12462 return Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)called_object,
12463 source, args, 2);
12464 } else if (descr_get != NULL) {
12465 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12466
12467 if (unlikely(method == NULL)) {
12468 return NULL;
12469 }
12470
12471 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, method, args);
12472 Py_DECREF(method);
12473 return result;
12474 } else {
12475 return CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12476 }
12477
12478 } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12479 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "%s instance has no attribute '%s'",
12480 PyString_AS_STRING(source_instance->in_class->cl_name),
12481 PyString_AS_STRING(attr_name));
12482
12483 return NULL;
12484 } else {
12485 // Finally allow the "__getattr__" override to provide it or else
12486 // it's an error.
12487
12488 PyObject *args2[] = {source, attr_name};
12489
12490 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12491
12492 if (unlikely(called_object == NULL)) {
12493 return NULL;
12494 }
12495
12496 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12497 Py_DECREF(called_object);
12498 return result;
12499 }
12500 }
12501#endif
12502 else if (type->tp_getattro != NULL) {
12503 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12504
12505 if (unlikely(descr == NULL)) {
12506 return NULL;
12507 }
12508
12509 descrgetfunc func = NULL;
12510 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12511 func = Py_TYPE(descr)->tp_descr_get;
12512
12513 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12514 PyObject *called_object = func(descr, source, (PyObject *)type);
12515 Py_DECREF(descr);
12516
12517 if (unlikely(called_object == NULL)) {
12518 return NULL;
12519 }
12520
12521 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12522 Py_DECREF(called_object);
12523 return result;
12524 }
12525 }
12526
12527 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, descr, args);
12528 Py_DECREF(descr);
12529 return result;
12530 } else if (type->tp_getattr != NULL) {
12531 PyObject *called_object = (*type->tp_getattr)(source, (char *)Nuitka_String_AsString_Unchecked(attr_name));
12532
12533 if (unlikely(called_object == NULL)) {
12534 return NULL;
12535 }
12536
12537 PyObject *result = CALL_FUNCTION_WITH_ARGS2(tstate, called_object, args);
12538 Py_DECREF(called_object);
12539 return result;
12540 } else {
12541 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
12542 Nuitka_String_AsString_Unchecked(attr_name));
12543
12544 return NULL;
12545 }
12546}
12547PyObject *CALL_METHOD_WITH_ARGS3(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *const *args) {
12548 CHECK_OBJECT(source);
12549 CHECK_OBJECT(attr_name);
12550
12551 CHECK_OBJECTS(args, 3);
12552
12553 PyTypeObject *type = Py_TYPE(source);
12554
12555 if (hasTypeGenericGetAttr(type)) {
12556 // Unfortunately this is required, although of cause rarely necessary.
12557 if (unlikely(type->tp_dict == NULL)) {
12558 if (unlikely(PyType_Ready(type) < 0)) {
12559 return NULL;
12560 }
12561 }
12562
12563 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12564 descrgetfunc func = NULL;
12565
12566 if (descr != NULL) {
12567 Py_INCREF(descr);
12568
12569 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12570 func = Py_TYPE(descr)->tp_descr_get;
12571
12572 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12573 PyObject *called_object = func(descr, source, (PyObject *)type);
12574 Py_DECREF(descr);
12575
12576 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12577 Py_DECREF(called_object);
12578 return result;
12579 }
12580 }
12581 }
12582
12583 Py_ssize_t dictoffset = type->tp_dictoffset;
12584 PyObject *dict = NULL;
12585
12586 if (dictoffset != 0) {
12587 // Negative dictionary offsets have special meaning.
12588 if (dictoffset < 0) {
12589 Py_ssize_t tsize;
12590 size_t size;
12591
12592 tsize = ((PyVarObject *)source)->ob_size;
12593 if (tsize < 0) {
12594 tsize = -tsize;
12595 }
12596 size = _PyObject_VAR_SIZE(type, tsize);
12597
12598 dictoffset += (long)size;
12599 }
12600
12601 PyObject **dictptr = (PyObject **)((char *)source + dictoffset);
12602 dict = *dictptr;
12603 }
12604
12605 if (dict != NULL) {
12606 CHECK_OBJECT(dict);
12607
12608 Py_INCREF(dict);
12609
12610 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12611
12612 if (called_object != NULL) {
12613 Py_XDECREF(descr);
12614 Py_DECREF(dict);
12615
12616 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12617 Py_DECREF(called_object);
12618 return result;
12619 }
12620
12621 Py_DECREF(dict);
12622 }
12623
12624 if (func != NULL) {
12625 if (func == Nuitka_Function_Type.tp_descr_get) {
12626 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)descr,
12627 source, args, 3);
12628 Py_DECREF(descr);
12629
12630 return result;
12631 } else {
12632 PyObject *called_object = func(descr, source, (PyObject *)type);
12633 CHECK_OBJECT(called_object);
12634
12635 Py_DECREF(descr);
12636
12637 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12638 Py_DECREF(called_object);
12639 return result;
12640 }
12641 }
12642
12643 if (descr != NULL) {
12644 CHECK_OBJECT(descr);
12645
12646 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, descr, args);
12647 Py_DECREF(descr);
12648 return result;
12649 }
12650
12651#if PYTHON_VERSION < 0x300
12652 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
12653 PyString_AS_STRING(attr_name));
12654#else
12655 PyErr_Format(PyExc_AttributeError, "'%s' object has no attribute '%U'", type->tp_name, attr_name);
12656#endif
12657 return NULL;
12658 }
12659#if PYTHON_VERSION < 0x300
12660 else if (type == &PyInstance_Type) {
12661 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12662
12663 // The special cases have their own variant on the code generation level
12664 // as we are called with constants only.
12665 assert(attr_name != const_str_plain___dict__);
12666 assert(attr_name != const_str_plain___class__);
12667
12668 // Try the instance dict first.
12669 PyObject *called_object =
12670 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12671
12672 // Note: The "called_object" was found without taking a reference,
12673 // so we need not release it in this branch.
12674 if (called_object != NULL) {
12675 return CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12676 }
12677
12678 // Then check the class dictionaries.
12679 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12680
12681 // Note: The "called_object" was found without taking a reference,
12682 // so we need not release it in this branch.
12683 if (called_object != NULL) {
12684 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12685
12686 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12687 return Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)called_object,
12688 source, args, 3);
12689 } else if (descr_get != NULL) {
12690 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12691
12692 if (unlikely(method == NULL)) {
12693 return NULL;
12694 }
12695
12696 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, method, args);
12697 Py_DECREF(method);
12698 return result;
12699 } else {
12700 return CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12701 }
12702
12703 } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12704 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "%s instance has no attribute '%s'",
12705 PyString_AS_STRING(source_instance->in_class->cl_name),
12706 PyString_AS_STRING(attr_name));
12707
12708 return NULL;
12709 } else {
12710 // Finally allow the "__getattr__" override to provide it or else
12711 // it's an error.
12712
12713 PyObject *args2[] = {source, attr_name};
12714
12715 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12716
12717 if (unlikely(called_object == NULL)) {
12718 return NULL;
12719 }
12720
12721 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12722 Py_DECREF(called_object);
12723 return result;
12724 }
12725 }
12726#endif
12727 else if (type->tp_getattro != NULL) {
12728 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12729
12730 if (unlikely(descr == NULL)) {
12731 return NULL;
12732 }
12733
12734 descrgetfunc func = NULL;
12735 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12736 func = Py_TYPE(descr)->tp_descr_get;
12737
12738 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12739 PyObject *called_object = func(descr, source, (PyObject *)type);
12740 Py_DECREF(descr);
12741
12742 if (unlikely(called_object == NULL)) {
12743 return NULL;
12744 }
12745
12746 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12747 Py_DECREF(called_object);
12748 return result;
12749 }
12750 }
12751
12752 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, descr, args);
12753 Py_DECREF(descr);
12754 return result;
12755 } else if (type->tp_getattr != NULL) {
12756 PyObject *called_object = (*type->tp_getattr)(source, (char *)Nuitka_String_AsString_Unchecked(attr_name));
12757
12758 if (unlikely(called_object == NULL)) {
12759 return NULL;
12760 }
12761
12762 PyObject *result = CALL_FUNCTION_WITH_ARGS3(tstate, called_object, args);
12763 Py_DECREF(called_object);
12764 return result;
12765 } else {
12766 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
12767 Nuitka_String_AsString_Unchecked(attr_name));
12768
12769 return NULL;
12770 }
12771}
12772PyObject *CALL_METHOD_WITH_ARGS4(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *const *args) {
12773 CHECK_OBJECT(source);
12774 CHECK_OBJECT(attr_name);
12775
12776 CHECK_OBJECTS(args, 4);
12777
12778 PyTypeObject *type = Py_TYPE(source);
12779
12780 if (hasTypeGenericGetAttr(type)) {
12781 // Unfortunately this is required, although of cause rarely necessary.
12782 if (unlikely(type->tp_dict == NULL)) {
12783 if (unlikely(PyType_Ready(type) < 0)) {
12784 return NULL;
12785 }
12786 }
12787
12788 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
12789 descrgetfunc func = NULL;
12790
12791 if (descr != NULL) {
12792 Py_INCREF(descr);
12793
12794 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12795 func = Py_TYPE(descr)->tp_descr_get;
12796
12797 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12798 PyObject *called_object = func(descr, source, (PyObject *)type);
12799 Py_DECREF(descr);
12800
12801 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12802 Py_DECREF(called_object);
12803 return result;
12804 }
12805 }
12806 }
12807
12808 Py_ssize_t dictoffset = type->tp_dictoffset;
12809 PyObject *dict = NULL;
12810
12811 if (dictoffset != 0) {
12812 // Negative dictionary offsets have special meaning.
12813 if (dictoffset < 0) {
12814 Py_ssize_t tsize;
12815 size_t size;
12816
12817 tsize = ((PyVarObject *)source)->ob_size;
12818 if (tsize < 0) {
12819 tsize = -tsize;
12820 }
12821 size = _PyObject_VAR_SIZE(type, tsize);
12822
12823 dictoffset += (long)size;
12824 }
12825
12826 PyObject **dictptr = (PyObject **)((char *)source + dictoffset);
12827 dict = *dictptr;
12828 }
12829
12830 if (dict != NULL) {
12831 CHECK_OBJECT(dict);
12832
12833 Py_INCREF(dict);
12834
12835 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
12836
12837 if (called_object != NULL) {
12838 Py_XDECREF(descr);
12839 Py_DECREF(dict);
12840
12841 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12842 Py_DECREF(called_object);
12843 return result;
12844 }
12845
12846 Py_DECREF(dict);
12847 }
12848
12849 if (func != NULL) {
12850 if (func == Nuitka_Function_Type.tp_descr_get) {
12851 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)descr,
12852 source, args, 4);
12853 Py_DECREF(descr);
12854
12855 return result;
12856 } else {
12857 PyObject *called_object = func(descr, source, (PyObject *)type);
12858 CHECK_OBJECT(called_object);
12859
12860 Py_DECREF(descr);
12861
12862 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12863 Py_DECREF(called_object);
12864 return result;
12865 }
12866 }
12867
12868 if (descr != NULL) {
12869 CHECK_OBJECT(descr);
12870
12871 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, descr, args);
12872 Py_DECREF(descr);
12873 return result;
12874 }
12875
12876#if PYTHON_VERSION < 0x300
12877 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
12878 PyString_AS_STRING(attr_name));
12879#else
12880 PyErr_Format(PyExc_AttributeError, "'%s' object has no attribute '%U'", type->tp_name, attr_name);
12881#endif
12882 return NULL;
12883 }
12884#if PYTHON_VERSION < 0x300
12885 else if (type == &PyInstance_Type) {
12886 PyInstanceObject *source_instance = (PyInstanceObject *)source;
12887
12888 // The special cases have their own variant on the code generation level
12889 // as we are called with constants only.
12890 assert(attr_name != const_str_plain___dict__);
12891 assert(attr_name != const_str_plain___class__);
12892
12893 // Try the instance dict first.
12894 PyObject *called_object =
12895 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
12896
12897 // Note: The "called_object" was found without taking a reference,
12898 // so we need not release it in this branch.
12899 if (called_object != NULL) {
12900 return CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12901 }
12902
12903 // Then check the class dictionaries.
12904 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
12905
12906 // Note: The "called_object" was found without taking a reference,
12907 // so we need not release it in this branch.
12908 if (called_object != NULL) {
12909 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
12910
12911 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
12912 return Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)called_object,
12913 source, args, 4);
12914 } else if (descr_get != NULL) {
12915 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
12916
12917 if (unlikely(method == NULL)) {
12918 return NULL;
12919 }
12920
12921 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, method, args);
12922 Py_DECREF(method);
12923 return result;
12924 } else {
12925 return CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12926 }
12927
12928 } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
12929 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "%s instance has no attribute '%s'",
12930 PyString_AS_STRING(source_instance->in_class->cl_name),
12931 PyString_AS_STRING(attr_name));
12932
12933 return NULL;
12934 } else {
12935 // Finally allow the "__getattr__" override to provide it or else
12936 // it's an error.
12937
12938 PyObject *args2[] = {source, attr_name};
12939
12940 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
12941
12942 if (unlikely(called_object == NULL)) {
12943 return NULL;
12944 }
12945
12946 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12947 Py_DECREF(called_object);
12948 return result;
12949 }
12950 }
12951#endif
12952 else if (type->tp_getattro != NULL) {
12953 PyObject *descr = (*type->tp_getattro)(source, attr_name);
12954
12955 if (unlikely(descr == NULL)) {
12956 return NULL;
12957 }
12958
12959 descrgetfunc func = NULL;
12960 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
12961 func = Py_TYPE(descr)->tp_descr_get;
12962
12963 if (func != NULL && Nuitka_Descr_IsData(descr)) {
12964 PyObject *called_object = func(descr, source, (PyObject *)type);
12965 Py_DECREF(descr);
12966
12967 if (unlikely(called_object == NULL)) {
12968 return NULL;
12969 }
12970
12971 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12972 Py_DECREF(called_object);
12973 return result;
12974 }
12975 }
12976
12977 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, descr, args);
12978 Py_DECREF(descr);
12979 return result;
12980 } else if (type->tp_getattr != NULL) {
12981 PyObject *called_object = (*type->tp_getattr)(source, (char *)Nuitka_String_AsString_Unchecked(attr_name));
12982
12983 if (unlikely(called_object == NULL)) {
12984 return NULL;
12985 }
12986
12987 PyObject *result = CALL_FUNCTION_WITH_ARGS4(tstate, called_object, args);
12988 Py_DECREF(called_object);
12989 return result;
12990 } else {
12991 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
12992 Nuitka_String_AsString_Unchecked(attr_name));
12993
12994 return NULL;
12995 }
12996}
12997PyObject *CALL_METHOD_WITH_ARGS5(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *const *args) {
12998 CHECK_OBJECT(source);
12999 CHECK_OBJECT(attr_name);
13000
13001 CHECK_OBJECTS(args, 5);
13002
13003 PyTypeObject *type = Py_TYPE(source);
13004
13005 if (hasTypeGenericGetAttr(type)) {
13006 // Unfortunately this is required, although of cause rarely necessary.
13007 if (unlikely(type->tp_dict == NULL)) {
13008 if (unlikely(PyType_Ready(type) < 0)) {
13009 return NULL;
13010 }
13011 }
13012
13013 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13014 descrgetfunc func = NULL;
13015
13016 if (descr != NULL) {
13017 Py_INCREF(descr);
13018
13019 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13020 func = Py_TYPE(descr)->tp_descr_get;
13021
13022 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13023 PyObject *called_object = func(descr, source, (PyObject *)type);
13024 Py_DECREF(descr);
13025
13026 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13027 Py_DECREF(called_object);
13028 return result;
13029 }
13030 }
13031 }
13032
13033 Py_ssize_t dictoffset = type->tp_dictoffset;
13034 PyObject *dict = NULL;
13035
13036 if (dictoffset != 0) {
13037 // Negative dictionary offsets have special meaning.
13038 if (dictoffset < 0) {
13039 Py_ssize_t tsize;
13040 size_t size;
13041
13042 tsize = ((PyVarObject *)source)->ob_size;
13043 if (tsize < 0) {
13044 tsize = -tsize;
13045 }
13046 size = _PyObject_VAR_SIZE(type, tsize);
13047
13048 dictoffset += (long)size;
13049 }
13050
13051 PyObject **dictptr = (PyObject **)((char *)source + dictoffset);
13052 dict = *dictptr;
13053 }
13054
13055 if (dict != NULL) {
13056 CHECK_OBJECT(dict);
13057
13058 Py_INCREF(dict);
13059
13060 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13061
13062 if (called_object != NULL) {
13063 Py_XDECREF(descr);
13064 Py_DECREF(dict);
13065
13066 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13067 Py_DECREF(called_object);
13068 return result;
13069 }
13070
13071 Py_DECREF(dict);
13072 }
13073
13074 if (func != NULL) {
13075 if (func == Nuitka_Function_Type.tp_descr_get) {
13076 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)descr,
13077 source, args, 5);
13078 Py_DECREF(descr);
13079
13080 return result;
13081 } else {
13082 PyObject *called_object = func(descr, source, (PyObject *)type);
13083 CHECK_OBJECT(called_object);
13084
13085 Py_DECREF(descr);
13086
13087 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13088 Py_DECREF(called_object);
13089 return result;
13090 }
13091 }
13092
13093 if (descr != NULL) {
13094 CHECK_OBJECT(descr);
13095
13096 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, descr, args);
13097 Py_DECREF(descr);
13098 return result;
13099 }
13100
13101#if PYTHON_VERSION < 0x300
13102 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
13103 PyString_AS_STRING(attr_name));
13104#else
13105 PyErr_Format(PyExc_AttributeError, "'%s' object has no attribute '%U'", type->tp_name, attr_name);
13106#endif
13107 return NULL;
13108 }
13109#if PYTHON_VERSION < 0x300
13110 else if (type == &PyInstance_Type) {
13111 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13112
13113 // The special cases have their own variant on the code generation level
13114 // as we are called with constants only.
13115 assert(attr_name != const_str_plain___dict__);
13116 assert(attr_name != const_str_plain___class__);
13117
13118 // Try the instance dict first.
13119 PyObject *called_object =
13120 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13121
13122 // Note: The "called_object" was found without taking a reference,
13123 // so we need not release it in this branch.
13124 if (called_object != NULL) {
13125 return CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13126 }
13127
13128 // Then check the class dictionaries.
13129 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13130
13131 // Note: The "called_object" was found without taking a reference,
13132 // so we need not release it in this branch.
13133 if (called_object != NULL) {
13134 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13135
13136 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13137 return Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)called_object,
13138 source, args, 5);
13139 } else if (descr_get != NULL) {
13140 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13141
13142 if (unlikely(method == NULL)) {
13143 return NULL;
13144 }
13145
13146 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, method, args);
13147 Py_DECREF(method);
13148 return result;
13149 } else {
13150 return CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13151 }
13152
13153 } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13154 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "%s instance has no attribute '%s'",
13155 PyString_AS_STRING(source_instance->in_class->cl_name),
13156 PyString_AS_STRING(attr_name));
13157
13158 return NULL;
13159 } else {
13160 // Finally allow the "__getattr__" override to provide it or else
13161 // it's an error.
13162
13163 PyObject *args2[] = {source, attr_name};
13164
13165 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13166
13167 if (unlikely(called_object == NULL)) {
13168 return NULL;
13169 }
13170
13171 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13172 Py_DECREF(called_object);
13173 return result;
13174 }
13175 }
13176#endif
13177 else if (type->tp_getattro != NULL) {
13178 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13179
13180 if (unlikely(descr == NULL)) {
13181 return NULL;
13182 }
13183
13184 descrgetfunc func = NULL;
13185 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13186 func = Py_TYPE(descr)->tp_descr_get;
13187
13188 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13189 PyObject *called_object = func(descr, source, (PyObject *)type);
13190 Py_DECREF(descr);
13191
13192 if (unlikely(called_object == NULL)) {
13193 return NULL;
13194 }
13195
13196 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13197 Py_DECREF(called_object);
13198 return result;
13199 }
13200 }
13201
13202 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, descr, args);
13203 Py_DECREF(descr);
13204 return result;
13205 } else if (type->tp_getattr != NULL) {
13206 PyObject *called_object = (*type->tp_getattr)(source, (char *)Nuitka_String_AsString_Unchecked(attr_name));
13207
13208 if (unlikely(called_object == NULL)) {
13209 return NULL;
13210 }
13211
13212 PyObject *result = CALL_FUNCTION_WITH_ARGS5(tstate, called_object, args);
13213 Py_DECREF(called_object);
13214 return result;
13215 } else {
13216 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
13217 Nuitka_String_AsString_Unchecked(attr_name));
13218
13219 return NULL;
13220 }
13221}
13222PyObject *CALL_METHOD_WITH_ARGS6(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *const *args) {
13223 CHECK_OBJECT(source);
13224 CHECK_OBJECT(attr_name);
13225
13226 CHECK_OBJECTS(args, 6);
13227
13228 PyTypeObject *type = Py_TYPE(source);
13229
13230 if (hasTypeGenericGetAttr(type)) {
13231 // Unfortunately this is required, although of cause rarely necessary.
13232 if (unlikely(type->tp_dict == NULL)) {
13233 if (unlikely(PyType_Ready(type) < 0)) {
13234 return NULL;
13235 }
13236 }
13237
13238 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13239 descrgetfunc func = NULL;
13240
13241 if (descr != NULL) {
13242 Py_INCREF(descr);
13243
13244 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13245 func = Py_TYPE(descr)->tp_descr_get;
13246
13247 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13248 PyObject *called_object = func(descr, source, (PyObject *)type);
13249 Py_DECREF(descr);
13250
13251 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13252 Py_DECREF(called_object);
13253 return result;
13254 }
13255 }
13256 }
13257
13258 Py_ssize_t dictoffset = type->tp_dictoffset;
13259 PyObject *dict = NULL;
13260
13261 if (dictoffset != 0) {
13262 // Negative dictionary offsets have special meaning.
13263 if (dictoffset < 0) {
13264 Py_ssize_t tsize;
13265 size_t size;
13266
13267 tsize = ((PyVarObject *)source)->ob_size;
13268 if (tsize < 0) {
13269 tsize = -tsize;
13270 }
13271 size = _PyObject_VAR_SIZE(type, tsize);
13272
13273 dictoffset += (long)size;
13274 }
13275
13276 PyObject **dictptr = (PyObject **)((char *)source + dictoffset);
13277 dict = *dictptr;
13278 }
13279
13280 if (dict != NULL) {
13281 CHECK_OBJECT(dict);
13282
13283 Py_INCREF(dict);
13284
13285 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13286
13287 if (called_object != NULL) {
13288 Py_XDECREF(descr);
13289 Py_DECREF(dict);
13290
13291 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13292 Py_DECREF(called_object);
13293 return result;
13294 }
13295
13296 Py_DECREF(dict);
13297 }
13298
13299 if (func != NULL) {
13300 if (func == Nuitka_Function_Type.tp_descr_get) {
13301 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)descr,
13302 source, args, 6);
13303 Py_DECREF(descr);
13304
13305 return result;
13306 } else {
13307 PyObject *called_object = func(descr, source, (PyObject *)type);
13308 CHECK_OBJECT(called_object);
13309
13310 Py_DECREF(descr);
13311
13312 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13313 Py_DECREF(called_object);
13314 return result;
13315 }
13316 }
13317
13318 if (descr != NULL) {
13319 CHECK_OBJECT(descr);
13320
13321 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, descr, args);
13322 Py_DECREF(descr);
13323 return result;
13324 }
13325
13326#if PYTHON_VERSION < 0x300
13327 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
13328 PyString_AS_STRING(attr_name));
13329#else
13330 PyErr_Format(PyExc_AttributeError, "'%s' object has no attribute '%U'", type->tp_name, attr_name);
13331#endif
13332 return NULL;
13333 }
13334#if PYTHON_VERSION < 0x300
13335 else if (type == &PyInstance_Type) {
13336 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13337
13338 // The special cases have their own variant on the code generation level
13339 // as we are called with constants only.
13340 assert(attr_name != const_str_plain___dict__);
13341 assert(attr_name != const_str_plain___class__);
13342
13343 // Try the instance dict first.
13344 PyObject *called_object =
13345 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13346
13347 // Note: The "called_object" was found without taking a reference,
13348 // so we need not release it in this branch.
13349 if (called_object != NULL) {
13350 return CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13351 }
13352
13353 // Then check the class dictionaries.
13354 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13355
13356 // Note: The "called_object" was found without taking a reference,
13357 // so we need not release it in this branch.
13358 if (called_object != NULL) {
13359 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13360
13361 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13362 return Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)called_object,
13363 source, args, 6);
13364 } else if (descr_get != NULL) {
13365 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13366
13367 if (unlikely(method == NULL)) {
13368 return NULL;
13369 }
13370
13371 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, method, args);
13372 Py_DECREF(method);
13373 return result;
13374 } else {
13375 return CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13376 }
13377
13378 } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13379 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "%s instance has no attribute '%s'",
13380 PyString_AS_STRING(source_instance->in_class->cl_name),
13381 PyString_AS_STRING(attr_name));
13382
13383 return NULL;
13384 } else {
13385 // Finally allow the "__getattr__" override to provide it or else
13386 // it's an error.
13387
13388 PyObject *args2[] = {source, attr_name};
13389
13390 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13391
13392 if (unlikely(called_object == NULL)) {
13393 return NULL;
13394 }
13395
13396 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13397 Py_DECREF(called_object);
13398 return result;
13399 }
13400 }
13401#endif
13402 else if (type->tp_getattro != NULL) {
13403 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13404
13405 if (unlikely(descr == NULL)) {
13406 return NULL;
13407 }
13408
13409 descrgetfunc func = NULL;
13410 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13411 func = Py_TYPE(descr)->tp_descr_get;
13412
13413 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13414 PyObject *called_object = func(descr, source, (PyObject *)type);
13415 Py_DECREF(descr);
13416
13417 if (unlikely(called_object == NULL)) {
13418 return NULL;
13419 }
13420
13421 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13422 Py_DECREF(called_object);
13423 return result;
13424 }
13425 }
13426
13427 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, descr, args);
13428 Py_DECREF(descr);
13429 return result;
13430 } else if (type->tp_getattr != NULL) {
13431 PyObject *called_object = (*type->tp_getattr)(source, (char *)Nuitka_String_AsString_Unchecked(attr_name));
13432
13433 if (unlikely(called_object == NULL)) {
13434 return NULL;
13435 }
13436
13437 PyObject *result = CALL_FUNCTION_WITH_ARGS6(tstate, called_object, args);
13438 Py_DECREF(called_object);
13439 return result;
13440 } else {
13441 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
13442 Nuitka_String_AsString_Unchecked(attr_name));
13443
13444 return NULL;
13445 }
13446}
13447PyObject *CALL_METHOD_WITH_ARGS7(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *const *args) {
13448 CHECK_OBJECT(source);
13449 CHECK_OBJECT(attr_name);
13450
13451 CHECK_OBJECTS(args, 7);
13452
13453 PyTypeObject *type = Py_TYPE(source);
13454
13455 if (hasTypeGenericGetAttr(type)) {
13456 // Unfortunately this is required, although of cause rarely necessary.
13457 if (unlikely(type->tp_dict == NULL)) {
13458 if (unlikely(PyType_Ready(type) < 0)) {
13459 return NULL;
13460 }
13461 }
13462
13463 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13464 descrgetfunc func = NULL;
13465
13466 if (descr != NULL) {
13467 Py_INCREF(descr);
13468
13469 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13470 func = Py_TYPE(descr)->tp_descr_get;
13471
13472 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13473 PyObject *called_object = func(descr, source, (PyObject *)type);
13474 Py_DECREF(descr);
13475
13476 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13477 Py_DECREF(called_object);
13478 return result;
13479 }
13480 }
13481 }
13482
13483 Py_ssize_t dictoffset = type->tp_dictoffset;
13484 PyObject *dict = NULL;
13485
13486 if (dictoffset != 0) {
13487 // Negative dictionary offsets have special meaning.
13488 if (dictoffset < 0) {
13489 Py_ssize_t tsize;
13490 size_t size;
13491
13492 tsize = ((PyVarObject *)source)->ob_size;
13493 if (tsize < 0) {
13494 tsize = -tsize;
13495 }
13496 size = _PyObject_VAR_SIZE(type, tsize);
13497
13498 dictoffset += (long)size;
13499 }
13500
13501 PyObject **dictptr = (PyObject **)((char *)source + dictoffset);
13502 dict = *dictptr;
13503 }
13504
13505 if (dict != NULL) {
13506 CHECK_OBJECT(dict);
13507
13508 Py_INCREF(dict);
13509
13510 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13511
13512 if (called_object != NULL) {
13513 Py_XDECREF(descr);
13514 Py_DECREF(dict);
13515
13516 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13517 Py_DECREF(called_object);
13518 return result;
13519 }
13520
13521 Py_DECREF(dict);
13522 }
13523
13524 if (func != NULL) {
13525 if (func == Nuitka_Function_Type.tp_descr_get) {
13526 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)descr,
13527 source, args, 7);
13528 Py_DECREF(descr);
13529
13530 return result;
13531 } else {
13532 PyObject *called_object = func(descr, source, (PyObject *)type);
13533 CHECK_OBJECT(called_object);
13534
13535 Py_DECREF(descr);
13536
13537 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13538 Py_DECREF(called_object);
13539 return result;
13540 }
13541 }
13542
13543 if (descr != NULL) {
13544 CHECK_OBJECT(descr);
13545
13546 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, descr, args);
13547 Py_DECREF(descr);
13548 return result;
13549 }
13550
13551#if PYTHON_VERSION < 0x300
13552 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
13553 PyString_AS_STRING(attr_name));
13554#else
13555 PyErr_Format(PyExc_AttributeError, "'%s' object has no attribute '%U'", type->tp_name, attr_name);
13556#endif
13557 return NULL;
13558 }
13559#if PYTHON_VERSION < 0x300
13560 else if (type == &PyInstance_Type) {
13561 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13562
13563 // The special cases have their own variant on the code generation level
13564 // as we are called with constants only.
13565 assert(attr_name != const_str_plain___dict__);
13566 assert(attr_name != const_str_plain___class__);
13567
13568 // Try the instance dict first.
13569 PyObject *called_object =
13570 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13571
13572 // Note: The "called_object" was found without taking a reference,
13573 // so we need not release it in this branch.
13574 if (called_object != NULL) {
13575 return CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13576 }
13577
13578 // Then check the class dictionaries.
13579 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13580
13581 // Note: The "called_object" was found without taking a reference,
13582 // so we need not release it in this branch.
13583 if (called_object != NULL) {
13584 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13585
13586 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13587 return Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)called_object,
13588 source, args, 7);
13589 } else if (descr_get != NULL) {
13590 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13591
13592 if (unlikely(method == NULL)) {
13593 return NULL;
13594 }
13595
13596 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, method, args);
13597 Py_DECREF(method);
13598 return result;
13599 } else {
13600 return CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13601 }
13602
13603 } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13604 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "%s instance has no attribute '%s'",
13605 PyString_AS_STRING(source_instance->in_class->cl_name),
13606 PyString_AS_STRING(attr_name));
13607
13608 return NULL;
13609 } else {
13610 // Finally allow the "__getattr__" override to provide it or else
13611 // it's an error.
13612
13613 PyObject *args2[] = {source, attr_name};
13614
13615 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13616
13617 if (unlikely(called_object == NULL)) {
13618 return NULL;
13619 }
13620
13621 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13622 Py_DECREF(called_object);
13623 return result;
13624 }
13625 }
13626#endif
13627 else if (type->tp_getattro != NULL) {
13628 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13629
13630 if (unlikely(descr == NULL)) {
13631 return NULL;
13632 }
13633
13634 descrgetfunc func = NULL;
13635 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13636 func = Py_TYPE(descr)->tp_descr_get;
13637
13638 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13639 PyObject *called_object = func(descr, source, (PyObject *)type);
13640 Py_DECREF(descr);
13641
13642 if (unlikely(called_object == NULL)) {
13643 return NULL;
13644 }
13645
13646 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13647 Py_DECREF(called_object);
13648 return result;
13649 }
13650 }
13651
13652 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, descr, args);
13653 Py_DECREF(descr);
13654 return result;
13655 } else if (type->tp_getattr != NULL) {
13656 PyObject *called_object = (*type->tp_getattr)(source, (char *)Nuitka_String_AsString_Unchecked(attr_name));
13657
13658 if (unlikely(called_object == NULL)) {
13659 return NULL;
13660 }
13661
13662 PyObject *result = CALL_FUNCTION_WITH_ARGS7(tstate, called_object, args);
13663 Py_DECREF(called_object);
13664 return result;
13665 } else {
13666 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
13667 Nuitka_String_AsString_Unchecked(attr_name));
13668
13669 return NULL;
13670 }
13671}
13672PyObject *CALL_METHOD_WITH_ARGS8(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *const *args) {
13673 CHECK_OBJECT(source);
13674 CHECK_OBJECT(attr_name);
13675
13676 CHECK_OBJECTS(args, 8);
13677
13678 PyTypeObject *type = Py_TYPE(source);
13679
13680 if (hasTypeGenericGetAttr(type)) {
13681 // Unfortunately this is required, although of cause rarely necessary.
13682 if (unlikely(type->tp_dict == NULL)) {
13683 if (unlikely(PyType_Ready(type) < 0)) {
13684 return NULL;
13685 }
13686 }
13687
13688 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13689 descrgetfunc func = NULL;
13690
13691 if (descr != NULL) {
13692 Py_INCREF(descr);
13693
13694 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13695 func = Py_TYPE(descr)->tp_descr_get;
13696
13697 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13698 PyObject *called_object = func(descr, source, (PyObject *)type);
13699 Py_DECREF(descr);
13700
13701 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13702 Py_DECREF(called_object);
13703 return result;
13704 }
13705 }
13706 }
13707
13708 Py_ssize_t dictoffset = type->tp_dictoffset;
13709 PyObject *dict = NULL;
13710
13711 if (dictoffset != 0) {
13712 // Negative dictionary offsets have special meaning.
13713 if (dictoffset < 0) {
13714 Py_ssize_t tsize;
13715 size_t size;
13716
13717 tsize = ((PyVarObject *)source)->ob_size;
13718 if (tsize < 0) {
13719 tsize = -tsize;
13720 }
13721 size = _PyObject_VAR_SIZE(type, tsize);
13722
13723 dictoffset += (long)size;
13724 }
13725
13726 PyObject **dictptr = (PyObject **)((char *)source + dictoffset);
13727 dict = *dictptr;
13728 }
13729
13730 if (dict != NULL) {
13731 CHECK_OBJECT(dict);
13732
13733 Py_INCREF(dict);
13734
13735 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13736
13737 if (called_object != NULL) {
13738 Py_XDECREF(descr);
13739 Py_DECREF(dict);
13740
13741 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13742 Py_DECREF(called_object);
13743 return result;
13744 }
13745
13746 Py_DECREF(dict);
13747 }
13748
13749 if (func != NULL) {
13750 if (func == Nuitka_Function_Type.tp_descr_get) {
13751 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)descr,
13752 source, args, 8);
13753 Py_DECREF(descr);
13754
13755 return result;
13756 } else {
13757 PyObject *called_object = func(descr, source, (PyObject *)type);
13758 CHECK_OBJECT(called_object);
13759
13760 Py_DECREF(descr);
13761
13762 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13763 Py_DECREF(called_object);
13764 return result;
13765 }
13766 }
13767
13768 if (descr != NULL) {
13769 CHECK_OBJECT(descr);
13770
13771 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, descr, args);
13772 Py_DECREF(descr);
13773 return result;
13774 }
13775
13776#if PYTHON_VERSION < 0x300
13777 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
13778 PyString_AS_STRING(attr_name));
13779#else
13780 PyErr_Format(PyExc_AttributeError, "'%s' object has no attribute '%U'", type->tp_name, attr_name);
13781#endif
13782 return NULL;
13783 }
13784#if PYTHON_VERSION < 0x300
13785 else if (type == &PyInstance_Type) {
13786 PyInstanceObject *source_instance = (PyInstanceObject *)source;
13787
13788 // The special cases have their own variant on the code generation level
13789 // as we are called with constants only.
13790 assert(attr_name != const_str_plain___dict__);
13791 assert(attr_name != const_str_plain___class__);
13792
13793 // Try the instance dict first.
13794 PyObject *called_object =
13795 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
13796
13797 // Note: The "called_object" was found without taking a reference,
13798 // so we need not release it in this branch.
13799 if (called_object != NULL) {
13800 return CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13801 }
13802
13803 // Then check the class dictionaries.
13804 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
13805
13806 // Note: The "called_object" was found without taking a reference,
13807 // so we need not release it in this branch.
13808 if (called_object != NULL) {
13809 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
13810
13811 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
13812 return Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)called_object,
13813 source, args, 8);
13814 } else if (descr_get != NULL) {
13815 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
13816
13817 if (unlikely(method == NULL)) {
13818 return NULL;
13819 }
13820
13821 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, method, args);
13822 Py_DECREF(method);
13823 return result;
13824 } else {
13825 return CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13826 }
13827
13828 } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
13829 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "%s instance has no attribute '%s'",
13830 PyString_AS_STRING(source_instance->in_class->cl_name),
13831 PyString_AS_STRING(attr_name));
13832
13833 return NULL;
13834 } else {
13835 // Finally allow the "__getattr__" override to provide it or else
13836 // it's an error.
13837
13838 PyObject *args2[] = {source, attr_name};
13839
13840 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
13841
13842 if (unlikely(called_object == NULL)) {
13843 return NULL;
13844 }
13845
13846 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13847 Py_DECREF(called_object);
13848 return result;
13849 }
13850 }
13851#endif
13852 else if (type->tp_getattro != NULL) {
13853 PyObject *descr = (*type->tp_getattro)(source, attr_name);
13854
13855 if (unlikely(descr == NULL)) {
13856 return NULL;
13857 }
13858
13859 descrgetfunc func = NULL;
13860 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13861 func = Py_TYPE(descr)->tp_descr_get;
13862
13863 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13864 PyObject *called_object = func(descr, source, (PyObject *)type);
13865 Py_DECREF(descr);
13866
13867 if (unlikely(called_object == NULL)) {
13868 return NULL;
13869 }
13870
13871 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13872 Py_DECREF(called_object);
13873 return result;
13874 }
13875 }
13876
13877 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, descr, args);
13878 Py_DECREF(descr);
13879 return result;
13880 } else if (type->tp_getattr != NULL) {
13881 PyObject *called_object = (*type->tp_getattr)(source, (char *)Nuitka_String_AsString_Unchecked(attr_name));
13882
13883 if (unlikely(called_object == NULL)) {
13884 return NULL;
13885 }
13886
13887 PyObject *result = CALL_FUNCTION_WITH_ARGS8(tstate, called_object, args);
13888 Py_DECREF(called_object);
13889 return result;
13890 } else {
13891 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
13892 Nuitka_String_AsString_Unchecked(attr_name));
13893
13894 return NULL;
13895 }
13896}
13897PyObject *CALL_METHOD_WITH_ARGS9(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *const *args) {
13898 CHECK_OBJECT(source);
13899 CHECK_OBJECT(attr_name);
13900
13901 CHECK_OBJECTS(args, 9);
13902
13903 PyTypeObject *type = Py_TYPE(source);
13904
13905 if (hasTypeGenericGetAttr(type)) {
13906 // Unfortunately this is required, although of cause rarely necessary.
13907 if (unlikely(type->tp_dict == NULL)) {
13908 if (unlikely(PyType_Ready(type) < 0)) {
13909 return NULL;
13910 }
13911 }
13912
13913 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
13914 descrgetfunc func = NULL;
13915
13916 if (descr != NULL) {
13917 Py_INCREF(descr);
13918
13919 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
13920 func = Py_TYPE(descr)->tp_descr_get;
13921
13922 if (func != NULL && Nuitka_Descr_IsData(descr)) {
13923 PyObject *called_object = func(descr, source, (PyObject *)type);
13924 Py_DECREF(descr);
13925
13926 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
13927 Py_DECREF(called_object);
13928 return result;
13929 }
13930 }
13931 }
13932
13933 Py_ssize_t dictoffset = type->tp_dictoffset;
13934 PyObject *dict = NULL;
13935
13936 if (dictoffset != 0) {
13937 // Negative dictionary offsets have special meaning.
13938 if (dictoffset < 0) {
13939 Py_ssize_t tsize;
13940 size_t size;
13941
13942 tsize = ((PyVarObject *)source)->ob_size;
13943 if (tsize < 0) {
13944 tsize = -tsize;
13945 }
13946 size = _PyObject_VAR_SIZE(type, tsize);
13947
13948 dictoffset += (long)size;
13949 }
13950
13951 PyObject **dictptr = (PyObject **)((char *)source + dictoffset);
13952 dict = *dictptr;
13953 }
13954
13955 if (dict != NULL) {
13956 CHECK_OBJECT(dict);
13957
13958 Py_INCREF(dict);
13959
13960 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
13961
13962 if (called_object != NULL) {
13963 Py_XDECREF(descr);
13964 Py_DECREF(dict);
13965
13966 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
13967 Py_DECREF(called_object);
13968 return result;
13969 }
13970
13971 Py_DECREF(dict);
13972 }
13973
13974 if (func != NULL) {
13975 if (func == Nuitka_Function_Type.tp_descr_get) {
13976 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)descr,
13977 source, args, 9);
13978 Py_DECREF(descr);
13979
13980 return result;
13981 } else {
13982 PyObject *called_object = func(descr, source, (PyObject *)type);
13983 CHECK_OBJECT(called_object);
13984
13985 Py_DECREF(descr);
13986
13987 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
13988 Py_DECREF(called_object);
13989 return result;
13990 }
13991 }
13992
13993 if (descr != NULL) {
13994 CHECK_OBJECT(descr);
13995
13996 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, descr, args);
13997 Py_DECREF(descr);
13998 return result;
13999 }
14000
14001#if PYTHON_VERSION < 0x300
14002 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
14003 PyString_AS_STRING(attr_name));
14004#else
14005 PyErr_Format(PyExc_AttributeError, "'%s' object has no attribute '%U'", type->tp_name, attr_name);
14006#endif
14007 return NULL;
14008 }
14009#if PYTHON_VERSION < 0x300
14010 else if (type == &PyInstance_Type) {
14011 PyInstanceObject *source_instance = (PyInstanceObject *)source;
14012
14013 // The special cases have their own variant on the code generation level
14014 // as we are called with constants only.
14015 assert(attr_name != const_str_plain___dict__);
14016 assert(attr_name != const_str_plain___class__);
14017
14018 // Try the instance dict first.
14019 PyObject *called_object =
14020 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
14021
14022 // Note: The "called_object" was found without taking a reference,
14023 // so we need not release it in this branch.
14024 if (called_object != NULL) {
14025 return CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14026 }
14027
14028 // Then check the class dictionaries.
14029 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
14030
14031 // Note: The "called_object" was found without taking a reference,
14032 // so we need not release it in this branch.
14033 if (called_object != NULL) {
14034 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
14035
14036 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
14037 return Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)called_object,
14038 source, args, 9);
14039 } else if (descr_get != NULL) {
14040 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
14041
14042 if (unlikely(method == NULL)) {
14043 return NULL;
14044 }
14045
14046 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, method, args);
14047 Py_DECREF(method);
14048 return result;
14049 } else {
14050 return CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14051 }
14052
14053 } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
14054 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "%s instance has no attribute '%s'",
14055 PyString_AS_STRING(source_instance->in_class->cl_name),
14056 PyString_AS_STRING(attr_name));
14057
14058 return NULL;
14059 } else {
14060 // Finally allow the "__getattr__" override to provide it or else
14061 // it's an error.
14062
14063 PyObject *args2[] = {source, attr_name};
14064
14065 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
14066
14067 if (unlikely(called_object == NULL)) {
14068 return NULL;
14069 }
14070
14071 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14072 Py_DECREF(called_object);
14073 return result;
14074 }
14075 }
14076#endif
14077 else if (type->tp_getattro != NULL) {
14078 PyObject *descr = (*type->tp_getattro)(source, attr_name);
14079
14080 if (unlikely(descr == NULL)) {
14081 return NULL;
14082 }
14083
14084 descrgetfunc func = NULL;
14085 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
14086 func = Py_TYPE(descr)->tp_descr_get;
14087
14088 if (func != NULL && Nuitka_Descr_IsData(descr)) {
14089 PyObject *called_object = func(descr, source, (PyObject *)type);
14090 Py_DECREF(descr);
14091
14092 if (unlikely(called_object == NULL)) {
14093 return NULL;
14094 }
14095
14096 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14097 Py_DECREF(called_object);
14098 return result;
14099 }
14100 }
14101
14102 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, descr, args);
14103 Py_DECREF(descr);
14104 return result;
14105 } else if (type->tp_getattr != NULL) {
14106 PyObject *called_object = (*type->tp_getattr)(source, (char *)Nuitka_String_AsString_Unchecked(attr_name));
14107
14108 if (unlikely(called_object == NULL)) {
14109 return NULL;
14110 }
14111
14112 PyObject *result = CALL_FUNCTION_WITH_ARGS9(tstate, called_object, args);
14113 Py_DECREF(called_object);
14114 return result;
14115 } else {
14116 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
14117 Nuitka_String_AsString_Unchecked(attr_name));
14118
14119 return NULL;
14120 }
14121}
14122PyObject *CALL_METHOD_WITH_ARGS10(PyThreadState *tstate, PyObject *source, PyObject *attr_name, PyObject *const *args) {
14123 CHECK_OBJECT(source);
14124 CHECK_OBJECT(attr_name);
14125
14126 CHECK_OBJECTS(args, 10);
14127
14128 PyTypeObject *type = Py_TYPE(source);
14129
14130 if (hasTypeGenericGetAttr(type)) {
14131 // Unfortunately this is required, although of cause rarely necessary.
14132 if (unlikely(type->tp_dict == NULL)) {
14133 if (unlikely(PyType_Ready(type) < 0)) {
14134 return NULL;
14135 }
14136 }
14137
14138 PyObject *descr = Nuitka_TypeLookup(type, attr_name);
14139 descrgetfunc func = NULL;
14140
14141 if (descr != NULL) {
14142 Py_INCREF(descr);
14143
14144 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
14145 func = Py_TYPE(descr)->tp_descr_get;
14146
14147 if (func != NULL && Nuitka_Descr_IsData(descr)) {
14148 PyObject *called_object = func(descr, source, (PyObject *)type);
14149 Py_DECREF(descr);
14150
14151 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14152 Py_DECREF(called_object);
14153 return result;
14154 }
14155 }
14156 }
14157
14158 Py_ssize_t dictoffset = type->tp_dictoffset;
14159 PyObject *dict = NULL;
14160
14161 if (dictoffset != 0) {
14162 // Negative dictionary offsets have special meaning.
14163 if (dictoffset < 0) {
14164 Py_ssize_t tsize;
14165 size_t size;
14166
14167 tsize = ((PyVarObject *)source)->ob_size;
14168 if (tsize < 0) {
14169 tsize = -tsize;
14170 }
14171 size = _PyObject_VAR_SIZE(type, tsize);
14172
14173 dictoffset += (long)size;
14174 }
14175
14176 PyObject **dictptr = (PyObject **)((char *)source + dictoffset);
14177 dict = *dictptr;
14178 }
14179
14180 if (dict != NULL) {
14181 CHECK_OBJECT(dict);
14182
14183 Py_INCREF(dict);
14184
14185 PyObject *called_object = DICT_GET_ITEM1(tstate, dict, attr_name);
14186
14187 if (called_object != NULL) {
14188 Py_XDECREF(descr);
14189 Py_DECREF(dict);
14190
14191 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14192 Py_DECREF(called_object);
14193 return result;
14194 }
14195
14196 Py_DECREF(dict);
14197 }
14198
14199 if (func != NULL) {
14200 if (func == Nuitka_Function_Type.tp_descr_get) {
14201 PyObject *result = Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)descr,
14202 source, args, 10);
14203 Py_DECREF(descr);
14204
14205 return result;
14206 } else {
14207 PyObject *called_object = func(descr, source, (PyObject *)type);
14208 CHECK_OBJECT(called_object);
14209
14210 Py_DECREF(descr);
14211
14212 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14213 Py_DECREF(called_object);
14214 return result;
14215 }
14216 }
14217
14218 if (descr != NULL) {
14219 CHECK_OBJECT(descr);
14220
14221 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, descr, args);
14222 Py_DECREF(descr);
14223 return result;
14224 }
14225
14226#if PYTHON_VERSION < 0x300
14227 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
14228 PyString_AS_STRING(attr_name));
14229#else
14230 PyErr_Format(PyExc_AttributeError, "'%s' object has no attribute '%U'", type->tp_name, attr_name);
14231#endif
14232 return NULL;
14233 }
14234#if PYTHON_VERSION < 0x300
14235 else if (type == &PyInstance_Type) {
14236 PyInstanceObject *source_instance = (PyInstanceObject *)source;
14237
14238 // The special cases have their own variant on the code generation level
14239 // as we are called with constants only.
14240 assert(attr_name != const_str_plain___dict__);
14241 assert(attr_name != const_str_plain___class__);
14242
14243 // Try the instance dict first.
14244 PyObject *called_object =
14245 GET_STRING_DICT_VALUE((PyDictObject *)source_instance->in_dict, (PyStringObject *)attr_name);
14246
14247 // Note: The "called_object" was found without taking a reference,
14248 // so we need not release it in this branch.
14249 if (called_object != NULL) {
14250 return CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14251 }
14252
14253 // Then check the class dictionaries.
14254 called_object = FIND_ATTRIBUTE_IN_CLASS(source_instance->in_class, attr_name);
14255
14256 // Note: The "called_object" was found without taking a reference,
14257 // so we need not release it in this branch.
14258 if (called_object != NULL) {
14259 descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get;
14260
14261 if (descr_get == Nuitka_Function_Type.tp_descr_get) {
14262 return Nuitka_CallMethodFunctionPosArgs(tstate, (struct Nuitka_FunctionObject const *)called_object,
14263 source, args, 10);
14264 } else if (descr_get != NULL) {
14265 PyObject *method = descr_get(called_object, source, (PyObject *)source_instance->in_class);
14266
14267 if (unlikely(method == NULL)) {
14268 return NULL;
14269 }
14270
14271 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, method, args);
14272 Py_DECREF(method);
14273 return result;
14274 } else {
14275 return CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14276 }
14277
14278 } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) {
14279 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "%s instance has no attribute '%s'",
14280 PyString_AS_STRING(source_instance->in_class->cl_name),
14281 PyString_AS_STRING(attr_name));
14282
14283 return NULL;
14284 } else {
14285 // Finally allow the "__getattr__" override to provide it or else
14286 // it's an error.
14287
14288 PyObject *args2[] = {source, attr_name};
14289
14290 called_object = CALL_FUNCTION_WITH_ARGS2(tstate, source_instance->in_class->cl_getattr, args2);
14291
14292 if (unlikely(called_object == NULL)) {
14293 return NULL;
14294 }
14295
14296 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14297 Py_DECREF(called_object);
14298 return result;
14299 }
14300 }
14301#endif
14302 else if (type->tp_getattro != NULL) {
14303 PyObject *descr = (*type->tp_getattro)(source, attr_name);
14304
14305 if (unlikely(descr == NULL)) {
14306 return NULL;
14307 }
14308
14309 descrgetfunc func = NULL;
14310 if (NuitkaType_HasFeatureClass(Py_TYPE(descr))) {
14311 func = Py_TYPE(descr)->tp_descr_get;
14312
14313 if (func != NULL && Nuitka_Descr_IsData(descr)) {
14314 PyObject *called_object = func(descr, source, (PyObject *)type);
14315 Py_DECREF(descr);
14316
14317 if (unlikely(called_object == NULL)) {
14318 return NULL;
14319 }
14320
14321 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14322 Py_DECREF(called_object);
14323 return result;
14324 }
14325 }
14326
14327 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, descr, args);
14328 Py_DECREF(descr);
14329 return result;
14330 } else if (type->tp_getattr != NULL) {
14331 PyObject *called_object = (*type->tp_getattr)(source, (char *)Nuitka_String_AsString_Unchecked(attr_name));
14332
14333 if (unlikely(called_object == NULL)) {
14334 return NULL;
14335 }
14336
14337 PyObject *result = CALL_FUNCTION_WITH_ARGS10(tstate, called_object, args);
14338 Py_DECREF(called_object);
14339 return result;
14340 } else {
14341 SET_CURRENT_EXCEPTION_TYPE0_FORMAT2(PyExc_AttributeError, "'%s' object has no attribute '%s'", type->tp_name,
14342 Nuitka_String_AsString_Unchecked(attr_name));
14343
14344 return NULL;
14345 }
14346}
14347
14348// Part of "Nuitka", an optimizing Python compiler that is compatible and
14349// integrates with CPython, but also works on its own.
14350//
14351// Licensed under the Apache License, Version 2.0 (the "License");
14352// you may not use this file except in compliance with the License.
14353// You may obtain a copy of the License at
14354//
14355// http://www.apache.org/licenses/LICENSE-2.0
14356//
14357// Unless required by applicable law or agreed to in writing, software
14358// distributed under the License is distributed on an "AS IS" BASIS,
14359// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14360// See the License for the specific language governing permissions and
14361// limitations under the License.
Definition compiled_function.h:22
Definition compiled_method.h:16