diff --git "a/medomni/models.build/__helpers.cpp" "b/medomni/models.build/__helpers.cpp" deleted file mode 100644--- "a/medomni/models.build/__helpers.cpp" +++ /dev/null @@ -1,4343 +0,0 @@ -// This file contains helper functions that are automatically created from -// templates. - -#include "nuitka/prelude.h" - -extern PyObject *callPythonFunction( PyObject *func, PyObject **args, int count ); - - -PyObject *CALL_FUNCTION_WITH_ARGS1(PyObject *called, PyObject **args) { - CHECK_OBJECT(called); - - // Check if arguments are valid objects in debug mode. -#ifndef __NUITKA_NO_ASSERT__ - for (size_t i = 0; i < 1; i++) { - CHECK_OBJECT(args[i]); - } -#endif - - if (Nuitka_Function_Check(called)) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called; - PyObject *result; - - if (function->m_args_simple && 1 == function->m_args_positional_count){ - for (Py_ssize_t i = 0; i < 1; i++) { - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, args); - } else if (function->m_args_simple && 1 + function->m_defaults_given == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - memcpy(python_pars, args, 1 * sizeof(PyObject *)); - memcpy(python_pars + 1, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsPos(function, python_pars, args, 1)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } else if (Nuitka_Method_Check(called)) { - struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called; - - // Unbound method without arguments, let the error path be slow. - if (method->m_object != NULL) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = method->m_function; - - PyObject *result; - - if (function->m_args_simple && 1 + 1 == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - for (Py_ssize_t i = 0; i < 1; i++) { - python_pars[i + 1] = args[i]; - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, python_pars); - } else if ( function->m_args_simple && 1 + 1 + function->m_defaults_given == function->m_args_positional_count ) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - memcpy(python_pars+1, args, 1 * sizeof(PyObject *)); - memcpy(python_pars+1 + 1, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsMethodPos(function, python_pars, method->m_object, args, 1)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } - } else if (PyCFunction_Check(called)) { - // Try to be fast about wrapping the arguments. - int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST); - - if (flags & METH_NOARGS) { -#if 1 == 0 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, NULL ); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1( - PyExc_TypeError, - "%s() takes no arguments (1 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_O) { -#if 1 == 1 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, args[0]); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, - "%s() takes exactly one argument (1 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_VARARGS) { - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - PyObject *pos_args = MAKE_TUPLE(args, 1); - - PyObject *result; - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - -#if PYTHON_VERSION < 0x360 - if (flags & METH_KEYWORDS) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else { - result = (*method)(self, pos_args); - } -#else - if (flags == (METH_VARARGS|METH_KEYWORDS)) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else if (flags == METH_FASTCALL) { -#if PYTHON_VERSION < 0x370 - result = (*(_PyCFunctionFast)method)(self, &PyTuple_GET_ITEM(pos_args, 0), 1, NULL); -#else - result = (*(_PyCFunctionFast)method)(self, &pos_args, 1); -#endif - } else { - result = (*method)(self, pos_args); - } -#endif - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - Py_DECREF(pos_args); - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - Py_DECREF(pos_args); - return NULL; - } - } - } else if (PyFunction_Check(called)) { - return callPythonFunction( - called, - args, - 1 - ); - } - - PyObject *pos_args = MAKE_TUPLE(args, 1); - - PyObject *result = CALL_FUNCTION(called, pos_args, NULL); - - Py_DECREF(pos_args); - - return result; -} - -PyObject *CALL_FUNCTION_WITH_ARGS2(PyObject *called, PyObject **args) { - CHECK_OBJECT(called); - - // Check if arguments are valid objects in debug mode. -#ifndef __NUITKA_NO_ASSERT__ - for (size_t i = 0; i < 2; i++) { - CHECK_OBJECT(args[i]); - } -#endif - - if (Nuitka_Function_Check(called)) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called; - PyObject *result; - - if (function->m_args_simple && 2 == function->m_args_positional_count){ - for (Py_ssize_t i = 0; i < 2; i++) { - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, args); - } else if (function->m_args_simple && 2 + function->m_defaults_given == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - memcpy(python_pars, args, 2 * sizeof(PyObject *)); - memcpy(python_pars + 2, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsPos(function, python_pars, args, 2)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } else if (Nuitka_Method_Check(called)) { - struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called; - - // Unbound method without arguments, let the error path be slow. - if (method->m_object != NULL) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = method->m_function; - - PyObject *result; - - if (function->m_args_simple && 2 + 1 == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - for (Py_ssize_t i = 0; i < 2; i++) { - python_pars[i + 1] = args[i]; - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, python_pars); - } else if ( function->m_args_simple && 2 + 1 + function->m_defaults_given == function->m_args_positional_count ) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - memcpy(python_pars+1, args, 2 * sizeof(PyObject *)); - memcpy(python_pars+1 + 2, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsMethodPos(function, python_pars, method->m_object, args, 2)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } - } else if (PyCFunction_Check(called)) { - // Try to be fast about wrapping the arguments. - int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST); - - if (flags & METH_NOARGS) { -#if 2 == 0 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, NULL ); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1( - PyExc_TypeError, - "%s() takes no arguments (2 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_O) { -#if 2 == 1 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, args[0]); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, - "%s() takes exactly one argument (2 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_VARARGS) { - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - PyObject *pos_args = MAKE_TUPLE(args, 2); - - PyObject *result; - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - -#if PYTHON_VERSION < 0x360 - if (flags & METH_KEYWORDS) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else { - result = (*method)(self, pos_args); - } -#else - if (flags == (METH_VARARGS|METH_KEYWORDS)) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else if (flags == METH_FASTCALL) { -#if PYTHON_VERSION < 0x370 - result = (*(_PyCFunctionFast)method)(self, &PyTuple_GET_ITEM(pos_args, 0), 2, NULL); -#else - result = (*(_PyCFunctionFast)method)(self, &pos_args, 2); -#endif - } else { - result = (*method)(self, pos_args); - } -#endif - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - Py_DECREF(pos_args); - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - Py_DECREF(pos_args); - return NULL; - } - } - } else if (PyFunction_Check(called)) { - return callPythonFunction( - called, - args, - 2 - ); - } - - PyObject *pos_args = MAKE_TUPLE(args, 2); - - PyObject *result = CALL_FUNCTION(called, pos_args, NULL); - - Py_DECREF(pos_args); - - return result; -} - -PyObject *CALL_FUNCTION_WITH_ARGS3(PyObject *called, PyObject **args) { - CHECK_OBJECT(called); - - // Check if arguments are valid objects in debug mode. -#ifndef __NUITKA_NO_ASSERT__ - for (size_t i = 0; i < 3; i++) { - CHECK_OBJECT(args[i]); - } -#endif - - if (Nuitka_Function_Check(called)) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called; - PyObject *result; - - if (function->m_args_simple && 3 == function->m_args_positional_count){ - for (Py_ssize_t i = 0; i < 3; i++) { - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, args); - } else if (function->m_args_simple && 3 + function->m_defaults_given == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - memcpy(python_pars, args, 3 * sizeof(PyObject *)); - memcpy(python_pars + 3, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsPos(function, python_pars, args, 3)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } else if (Nuitka_Method_Check(called)) { - struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called; - - // Unbound method without arguments, let the error path be slow. - if (method->m_object != NULL) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = method->m_function; - - PyObject *result; - - if (function->m_args_simple && 3 + 1 == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - for (Py_ssize_t i = 0; i < 3; i++) { - python_pars[i + 1] = args[i]; - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, python_pars); - } else if ( function->m_args_simple && 3 + 1 + function->m_defaults_given == function->m_args_positional_count ) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - memcpy(python_pars+1, args, 3 * sizeof(PyObject *)); - memcpy(python_pars+1 + 3, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsMethodPos(function, python_pars, method->m_object, args, 3)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } - } else if (PyCFunction_Check(called)) { - // Try to be fast about wrapping the arguments. - int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST); - - if (flags & METH_NOARGS) { -#if 3 == 0 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, NULL ); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1( - PyExc_TypeError, - "%s() takes no arguments (3 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_O) { -#if 3 == 1 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, args[0]); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, - "%s() takes exactly one argument (3 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_VARARGS) { - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - PyObject *pos_args = MAKE_TUPLE(args, 3); - - PyObject *result; - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - -#if PYTHON_VERSION < 0x360 - if (flags & METH_KEYWORDS) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else { - result = (*method)(self, pos_args); - } -#else - if (flags == (METH_VARARGS|METH_KEYWORDS)) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else if (flags == METH_FASTCALL) { -#if PYTHON_VERSION < 0x370 - result = (*(_PyCFunctionFast)method)(self, &PyTuple_GET_ITEM(pos_args, 0), 3, NULL); -#else - result = (*(_PyCFunctionFast)method)(self, &pos_args, 3); -#endif - } else { - result = (*method)(self, pos_args); - } -#endif - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - Py_DECREF(pos_args); - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - Py_DECREF(pos_args); - return NULL; - } - } - } else if (PyFunction_Check(called)) { - return callPythonFunction( - called, - args, - 3 - ); - } - - PyObject *pos_args = MAKE_TUPLE(args, 3); - - PyObject *result = CALL_FUNCTION(called, pos_args, NULL); - - Py_DECREF(pos_args); - - return result; -} - -PyObject *CALL_FUNCTION_WITH_ARGS4(PyObject *called, PyObject **args) { - CHECK_OBJECT(called); - - // Check if arguments are valid objects in debug mode. -#ifndef __NUITKA_NO_ASSERT__ - for (size_t i = 0; i < 4; i++) { - CHECK_OBJECT(args[i]); - } -#endif - - if (Nuitka_Function_Check(called)) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called; - PyObject *result; - - if (function->m_args_simple && 4 == function->m_args_positional_count){ - for (Py_ssize_t i = 0; i < 4; i++) { - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, args); - } else if (function->m_args_simple && 4 + function->m_defaults_given == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - memcpy(python_pars, args, 4 * sizeof(PyObject *)); - memcpy(python_pars + 4, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsPos(function, python_pars, args, 4)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } else if (Nuitka_Method_Check(called)) { - struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called; - - // Unbound method without arguments, let the error path be slow. - if (method->m_object != NULL) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = method->m_function; - - PyObject *result; - - if (function->m_args_simple && 4 + 1 == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - for (Py_ssize_t i = 0; i < 4; i++) { - python_pars[i + 1] = args[i]; - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, python_pars); - } else if ( function->m_args_simple && 4 + 1 + function->m_defaults_given == function->m_args_positional_count ) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - memcpy(python_pars+1, args, 4 * sizeof(PyObject *)); - memcpy(python_pars+1 + 4, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsMethodPos(function, python_pars, method->m_object, args, 4)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } - } else if (PyCFunction_Check(called)) { - // Try to be fast about wrapping the arguments. - int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST); - - if (flags & METH_NOARGS) { -#if 4 == 0 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, NULL ); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1( - PyExc_TypeError, - "%s() takes no arguments (4 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_O) { -#if 4 == 1 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, args[0]); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, - "%s() takes exactly one argument (4 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_VARARGS) { - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - PyObject *pos_args = MAKE_TUPLE(args, 4); - - PyObject *result; - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - -#if PYTHON_VERSION < 0x360 - if (flags & METH_KEYWORDS) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else { - result = (*method)(self, pos_args); - } -#else - if (flags == (METH_VARARGS|METH_KEYWORDS)) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else if (flags == METH_FASTCALL) { -#if PYTHON_VERSION < 0x370 - result = (*(_PyCFunctionFast)method)(self, &PyTuple_GET_ITEM(pos_args, 0), 4, NULL); -#else - result = (*(_PyCFunctionFast)method)(self, &pos_args, 4); -#endif - } else { - result = (*method)(self, pos_args); - } -#endif - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - Py_DECREF(pos_args); - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - Py_DECREF(pos_args); - return NULL; - } - } - } else if (PyFunction_Check(called)) { - return callPythonFunction( - called, - args, - 4 - ); - } - - PyObject *pos_args = MAKE_TUPLE(args, 4); - - PyObject *result = CALL_FUNCTION(called, pos_args, NULL); - - Py_DECREF(pos_args); - - return result; -} - -PyObject *CALL_FUNCTION_WITH_ARGS5(PyObject *called, PyObject **args) { - CHECK_OBJECT(called); - - // Check if arguments are valid objects in debug mode. -#ifndef __NUITKA_NO_ASSERT__ - for (size_t i = 0; i < 5; i++) { - CHECK_OBJECT(args[i]); - } -#endif - - if (Nuitka_Function_Check(called)) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called; - PyObject *result; - - if (function->m_args_simple && 5 == function->m_args_positional_count){ - for (Py_ssize_t i = 0; i < 5; i++) { - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, args); - } else if (function->m_args_simple && 5 + function->m_defaults_given == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - memcpy(python_pars, args, 5 * sizeof(PyObject *)); - memcpy(python_pars + 5, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsPos(function, python_pars, args, 5)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } else if (Nuitka_Method_Check(called)) { - struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called; - - // Unbound method without arguments, let the error path be slow. - if (method->m_object != NULL) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = method->m_function; - - PyObject *result; - - if (function->m_args_simple && 5 + 1 == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - for (Py_ssize_t i = 0; i < 5; i++) { - python_pars[i + 1] = args[i]; - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, python_pars); - } else if ( function->m_args_simple && 5 + 1 + function->m_defaults_given == function->m_args_positional_count ) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - memcpy(python_pars+1, args, 5 * sizeof(PyObject *)); - memcpy(python_pars+1 + 5, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsMethodPos(function, python_pars, method->m_object, args, 5)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } - } else if (PyCFunction_Check(called)) { - // Try to be fast about wrapping the arguments. - int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST); - - if (flags & METH_NOARGS) { -#if 5 == 0 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, NULL ); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1( - PyExc_TypeError, - "%s() takes no arguments (5 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_O) { -#if 5 == 1 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, args[0]); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, - "%s() takes exactly one argument (5 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_VARARGS) { - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - PyObject *pos_args = MAKE_TUPLE(args, 5); - - PyObject *result; - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - -#if PYTHON_VERSION < 0x360 - if (flags & METH_KEYWORDS) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else { - result = (*method)(self, pos_args); - } -#else - if (flags == (METH_VARARGS|METH_KEYWORDS)) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else if (flags == METH_FASTCALL) { -#if PYTHON_VERSION < 0x370 - result = (*(_PyCFunctionFast)method)(self, &PyTuple_GET_ITEM(pos_args, 0), 5, NULL); -#else - result = (*(_PyCFunctionFast)method)(self, &pos_args, 5); -#endif - } else { - result = (*method)(self, pos_args); - } -#endif - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - Py_DECREF(pos_args); - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - Py_DECREF(pos_args); - return NULL; - } - } - } else if (PyFunction_Check(called)) { - return callPythonFunction( - called, - args, - 5 - ); - } - - PyObject *pos_args = MAKE_TUPLE(args, 5); - - PyObject *result = CALL_FUNCTION(called, pos_args, NULL); - - Py_DECREF(pos_args); - - return result; -} - -PyObject *CALL_FUNCTION_WITH_ARGS6(PyObject *called, PyObject **args) { - CHECK_OBJECT(called); - - // Check if arguments are valid objects in debug mode. -#ifndef __NUITKA_NO_ASSERT__ - for (size_t i = 0; i < 6; i++) { - CHECK_OBJECT(args[i]); - } -#endif - - if (Nuitka_Function_Check(called)) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called; - PyObject *result; - - if (function->m_args_simple && 6 == function->m_args_positional_count){ - for (Py_ssize_t i = 0; i < 6; i++) { - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, args); - } else if (function->m_args_simple && 6 + function->m_defaults_given == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - memcpy(python_pars, args, 6 * sizeof(PyObject *)); - memcpy(python_pars + 6, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsPos(function, python_pars, args, 6)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } else if (Nuitka_Method_Check(called)) { - struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called; - - // Unbound method without arguments, let the error path be slow. - if (method->m_object != NULL) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = method->m_function; - - PyObject *result; - - if (function->m_args_simple && 6 + 1 == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - for (Py_ssize_t i = 0; i < 6; i++) { - python_pars[i + 1] = args[i]; - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, python_pars); - } else if ( function->m_args_simple && 6 + 1 + function->m_defaults_given == function->m_args_positional_count ) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - memcpy(python_pars+1, args, 6 * sizeof(PyObject *)); - memcpy(python_pars+1 + 6, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsMethodPos(function, python_pars, method->m_object, args, 6)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } - } else if (PyCFunction_Check(called)) { - // Try to be fast about wrapping the arguments. - int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST); - - if (flags & METH_NOARGS) { -#if 6 == 0 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, NULL ); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1( - PyExc_TypeError, - "%s() takes no arguments (6 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_O) { -#if 6 == 1 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, args[0]); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, - "%s() takes exactly one argument (6 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_VARARGS) { - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - PyObject *pos_args = MAKE_TUPLE(args, 6); - - PyObject *result; - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - -#if PYTHON_VERSION < 0x360 - if (flags & METH_KEYWORDS) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else { - result = (*method)(self, pos_args); - } -#else - if (flags == (METH_VARARGS|METH_KEYWORDS)) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else if (flags == METH_FASTCALL) { -#if PYTHON_VERSION < 0x370 - result = (*(_PyCFunctionFast)method)(self, &PyTuple_GET_ITEM(pos_args, 0), 6, NULL); -#else - result = (*(_PyCFunctionFast)method)(self, &pos_args, 6); -#endif - } else { - result = (*method)(self, pos_args); - } -#endif - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - Py_DECREF(pos_args); - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - Py_DECREF(pos_args); - return NULL; - } - } - } else if (PyFunction_Check(called)) { - return callPythonFunction( - called, - args, - 6 - ); - } - - PyObject *pos_args = MAKE_TUPLE(args, 6); - - PyObject *result = CALL_FUNCTION(called, pos_args, NULL); - - Py_DECREF(pos_args); - - return result; -} - -PyObject *CALL_FUNCTION_WITH_ARGS7(PyObject *called, PyObject **args) { - CHECK_OBJECT(called); - - // Check if arguments are valid objects in debug mode. -#ifndef __NUITKA_NO_ASSERT__ - for (size_t i = 0; i < 7; i++) { - CHECK_OBJECT(args[i]); - } -#endif - - if (Nuitka_Function_Check(called)) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called; - PyObject *result; - - if (function->m_args_simple && 7 == function->m_args_positional_count){ - for (Py_ssize_t i = 0; i < 7; i++) { - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, args); - } else if (function->m_args_simple && 7 + function->m_defaults_given == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - memcpy(python_pars, args, 7 * sizeof(PyObject *)); - memcpy(python_pars + 7, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsPos(function, python_pars, args, 7)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } else if (Nuitka_Method_Check(called)) { - struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called; - - // Unbound method without arguments, let the error path be slow. - if (method->m_object != NULL) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = method->m_function; - - PyObject *result; - - if (function->m_args_simple && 7 + 1 == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - for (Py_ssize_t i = 0; i < 7; i++) { - python_pars[i + 1] = args[i]; - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, python_pars); - } else if ( function->m_args_simple && 7 + 1 + function->m_defaults_given == function->m_args_positional_count ) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - memcpy(python_pars+1, args, 7 * sizeof(PyObject *)); - memcpy(python_pars+1 + 7, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsMethodPos(function, python_pars, method->m_object, args, 7)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } - } else if (PyCFunction_Check(called)) { - // Try to be fast about wrapping the arguments. - int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST); - - if (flags & METH_NOARGS) { -#if 7 == 0 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, NULL ); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1( - PyExc_TypeError, - "%s() takes no arguments (7 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_O) { -#if 7 == 1 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, args[0]); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, - "%s() takes exactly one argument (7 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_VARARGS) { - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - PyObject *pos_args = MAKE_TUPLE(args, 7); - - PyObject *result; - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - -#if PYTHON_VERSION < 0x360 - if (flags & METH_KEYWORDS) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else { - result = (*method)(self, pos_args); - } -#else - if (flags == (METH_VARARGS|METH_KEYWORDS)) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else if (flags == METH_FASTCALL) { -#if PYTHON_VERSION < 0x370 - result = (*(_PyCFunctionFast)method)(self, &PyTuple_GET_ITEM(pos_args, 0), 7, NULL); -#else - result = (*(_PyCFunctionFast)method)(self, &pos_args, 7); -#endif - } else { - result = (*method)(self, pos_args); - } -#endif - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - Py_DECREF(pos_args); - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - Py_DECREF(pos_args); - return NULL; - } - } - } else if (PyFunction_Check(called)) { - return callPythonFunction( - called, - args, - 7 - ); - } - - PyObject *pos_args = MAKE_TUPLE(args, 7); - - PyObject *result = CALL_FUNCTION(called, pos_args, NULL); - - Py_DECREF(pos_args); - - return result; -} - -PyObject *CALL_FUNCTION_WITH_ARGS8(PyObject *called, PyObject **args) { - CHECK_OBJECT(called); - - // Check if arguments are valid objects in debug mode. -#ifndef __NUITKA_NO_ASSERT__ - for (size_t i = 0; i < 8; i++) { - CHECK_OBJECT(args[i]); - } -#endif - - if (Nuitka_Function_Check(called)) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called; - PyObject *result; - - if (function->m_args_simple && 8 == function->m_args_positional_count){ - for (Py_ssize_t i = 0; i < 8; i++) { - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, args); - } else if (function->m_args_simple && 8 + function->m_defaults_given == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - memcpy(python_pars, args, 8 * sizeof(PyObject *)); - memcpy(python_pars + 8, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsPos(function, python_pars, args, 8)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } else if (Nuitka_Method_Check(called)) { - struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called; - - // Unbound method without arguments, let the error path be slow. - if (method->m_object != NULL) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = method->m_function; - - PyObject *result; - - if (function->m_args_simple && 8 + 1 == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - for (Py_ssize_t i = 0; i < 8; i++) { - python_pars[i + 1] = args[i]; - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, python_pars); - } else if ( function->m_args_simple && 8 + 1 + function->m_defaults_given == function->m_args_positional_count ) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - memcpy(python_pars+1, args, 8 * sizeof(PyObject *)); - memcpy(python_pars+1 + 8, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsMethodPos(function, python_pars, method->m_object, args, 8)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } - } else if (PyCFunction_Check(called)) { - // Try to be fast about wrapping the arguments. - int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST); - - if (flags & METH_NOARGS) { -#if 8 == 0 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, NULL ); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1( - PyExc_TypeError, - "%s() takes no arguments (8 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_O) { -#if 8 == 1 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, args[0]); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, - "%s() takes exactly one argument (8 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_VARARGS) { - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - PyObject *pos_args = MAKE_TUPLE(args, 8); - - PyObject *result; - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - -#if PYTHON_VERSION < 0x360 - if (flags & METH_KEYWORDS) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else { - result = (*method)(self, pos_args); - } -#else - if (flags == (METH_VARARGS|METH_KEYWORDS)) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else if (flags == METH_FASTCALL) { -#if PYTHON_VERSION < 0x370 - result = (*(_PyCFunctionFast)method)(self, &PyTuple_GET_ITEM(pos_args, 0), 8, NULL); -#else - result = (*(_PyCFunctionFast)method)(self, &pos_args, 8); -#endif - } else { - result = (*method)(self, pos_args); - } -#endif - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - Py_DECREF(pos_args); - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - Py_DECREF(pos_args); - return NULL; - } - } - } else if (PyFunction_Check(called)) { - return callPythonFunction( - called, - args, - 8 - ); - } - - PyObject *pos_args = MAKE_TUPLE(args, 8); - - PyObject *result = CALL_FUNCTION(called, pos_args, NULL); - - Py_DECREF(pos_args); - - return result; -} - -PyObject *CALL_FUNCTION_WITH_ARGS9(PyObject *called, PyObject **args) { - CHECK_OBJECT(called); - - // Check if arguments are valid objects in debug mode. -#ifndef __NUITKA_NO_ASSERT__ - for (size_t i = 0; i < 9; i++) { - CHECK_OBJECT(args[i]); - } -#endif - - if (Nuitka_Function_Check(called)) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = (struct Nuitka_FunctionObject *)called; - PyObject *result; - - if (function->m_args_simple && 9 == function->m_args_positional_count){ - for (Py_ssize_t i = 0; i < 9; i++) { - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, args); - } else if (function->m_args_simple && 9 + function->m_defaults_given == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - memcpy(python_pars, args, 9 * sizeof(PyObject *)); - memcpy(python_pars + 9, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 0; i < function->m_args_positional_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsPos(function, python_pars, args, 9)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } else if (Nuitka_Method_Check(called)) { - struct Nuitka_MethodObject *method = (struct Nuitka_MethodObject *)called; - - // Unbound method without arguments, let the error path be slow. - if (method->m_object != NULL) { - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } - - struct Nuitka_FunctionObject *function = method->m_function; - - PyObject *result; - - if (function->m_args_simple && 9 + 1 == function->m_args_positional_count) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - for (Py_ssize_t i = 0; i < 9; i++) { - python_pars[i + 1] = args[i]; - Py_INCREF(args[i]); - } - - result = function->m_c_code(function, python_pars); - } else if ( function->m_args_simple && 9 + 1 + function->m_defaults_given == function->m_args_positional_count ) { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_positional_count); -#else - PyObject *python_pars[function->m_args_positional_count]; -#endif - python_pars[0] = method->m_object; - Py_INCREF(method->m_object); - - memcpy(python_pars+1, args, 9 * sizeof(PyObject *)); - memcpy(python_pars+1 + 9, &PyTuple_GET_ITEM(function->m_defaults, 0), function->m_defaults_given * sizeof(PyObject *)); - - for (Py_ssize_t i = 1; i < function->m_args_overall_count; i++) { - Py_INCREF(python_pars[i]); - } - - result = function->m_c_code(function, python_pars); - } else { -#ifdef _MSC_VER - PyObject **python_pars = (PyObject **)_alloca(sizeof(PyObject *) * function->m_args_overall_count); -#else - PyObject *python_pars[function->m_args_overall_count]; -#endif - memset(python_pars, 0, function->m_args_overall_count * sizeof(PyObject *)); - - if (parseArgumentsMethodPos(function, python_pars, method->m_object, args, 9)) { - result = function->m_c_code(function, python_pars); - } else { - result = NULL; - } - } - - Py_LeaveRecursiveCall(); - - return result; - } - } else if (PyCFunction_Check(called)) { - // Try to be fast about wrapping the arguments. - int flags = PyCFunction_GET_FLAGS(called) & ~(METH_CLASS | METH_STATIC | METH_COEXIST); - - if (flags & METH_NOARGS) { -#if 9 == 0 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, NULL ); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1( - PyExc_TypeError, - "%s() takes no arguments (9 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_O) { -#if 9 == 1 - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - - PyObject *result = (*method)( self, args[0]); - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - return NULL; - } -#else - SET_CURRENT_EXCEPTION_TYPE0_FORMAT1(PyExc_TypeError, - "%s() takes exactly one argument (9 given)", - ((PyCFunctionObject *)called)->m_ml->ml_name - ); - return NULL; -#endif - } else if (flags & METH_VARARGS) { - PyCFunction method = PyCFunction_GET_FUNCTION(called); - PyObject *self = PyCFunction_GET_SELF(called); - - PyObject *pos_args = MAKE_TUPLE(args, 9); - - PyObject *result; - - // Recursion guard is not strictly necessary, as we already have - // one on our way to here. -#ifdef _NUITKA_FULL_COMPAT - if (unlikely(Py_EnterRecursiveCall((char *)" while calling a Python object"))) { - return NULL; - } -#endif - -#if PYTHON_VERSION < 0x360 - if (flags & METH_KEYWORDS) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else { - result = (*method)(self, pos_args); - } -#else - if (flags == (METH_VARARGS|METH_KEYWORDS)) { - result = (*(PyCFunctionWithKeywords)method)(self, pos_args, NULL); - } else if (flags == METH_FASTCALL) { -#if PYTHON_VERSION < 0x370 - result = (*(_PyCFunctionFast)method)(self, &PyTuple_GET_ITEM(pos_args, 0), 9, NULL); -#else - result = (*(_PyCFunctionFast)method)(self, &pos_args, 9); -#endif - } else { - result = (*method)(self, pos_args); - } -#endif - -#ifdef _NUITKA_FULL_COMPAT - Py_LeaveRecursiveCall(); -#endif - - if (result != NULL) { - // Some buggy C functions do set an error, but do not indicate it - // and Nuitka inner workings can get upset/confused from it. - DROP_ERROR_OCCURRED(); - - Py_DECREF(pos_args); - return result; - } else { - // Other buggy C functions do this, return NULL, but with - // no error set, not allowed. - if (unlikely(!ERROR_OCCURRED())) { - SET_CURRENT_EXCEPTION_TYPE0_STR( - PyExc_SystemError, - "NULL result without error in PyObject_Call" - ); - } - - Py_DECREF(pos_args); - return NULL; - } - } - } else if (PyFunction_Check(called)) { - return callPythonFunction( - called, - args, - 9 - ); - } - - PyObject *pos_args = MAKE_TUPLE(args, 9); - - PyObject *result = CALL_FUNCTION(called, pos_args, NULL); - - Py_DECREF(pos_args); - - return result; -} - -PyObject *CALL_METHOD_WITH_ARGS1(PyObject *source, PyObject *attr_name, PyObject **args) { - CHECK_OBJECT(source); - CHECK_OBJECT(attr_name); - - // Check if arguments are valid objects in debug mode. -#ifndef __NUITKA_NO_ASSERT__ - for (size_t i = 0; i < 1; i++) { - CHECK_OBJECT(args[i]); - } -#endif - - PyTypeObject *type = Py_TYPE(source); - - if (type->tp_getattro == PyObject_GenericGetAttr) { - // Unfortunately this is required, although of cause rarely necessary. - if (unlikely(type->tp_dict == NULL)) { - if (unlikely(PyType_Ready(type) < 0)) { - return NULL; - } - } - - PyObject *descr = _PyType_Lookup(type, attr_name); - descrgetfunc func = NULL; - - if (descr != NULL) { - Py_INCREF(descr); - -#if PYTHON_VERSION < 0x300 - if (PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)) { -#endif - func = Py_TYPE(descr)->tp_descr_get; - - if (func != NULL && PyDescr_IsData(descr)) { - PyObject *called_object = func(descr, source, (PyObject *)type); - Py_DECREF(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS1( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } -#if PYTHON_VERSION < 0x300 - } -#endif - } - - Py_ssize_t dictoffset = type->tp_dictoffset; - PyObject *dict = NULL; - - if (dictoffset != 0) { - // Negative dictionary offsets have special meaning. - if (dictoffset < 0) { - Py_ssize_t tsize; - size_t size; - - tsize = ((PyVarObject *)source)->ob_size; - if (tsize < 0) { - tsize = -tsize; - } - size = _PyObject_VAR_SIZE( type, tsize ); - - dictoffset += (long)size; - } - - PyObject **dictptr = (PyObject **) ((char *)source + dictoffset); - dict = *dictptr; - } - - if (dict != NULL) { - CHECK_OBJECT(dict); - - Py_INCREF(dict); - - PyObject *called_object = DICT_GET_ITEM1(dict, attr_name); - - if (called_object != NULL) { - Py_XDECREF(descr); - Py_DECREF(dict); - - PyObject *result = CALL_FUNCTION_WITH_ARGS1( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } - - Py_DECREF(dict); - } - - if (func != NULL) { - if (func == Nuitka_Function_Type.tp_descr_get) { - PyObject *result = Nuitka_CallMethodFunctionPosArgs( - (struct Nuitka_FunctionObject const *)descr, - source, - args, - 1 - ); - - Py_DECREF(descr); - - return result; - } else { - PyObject *called_object = func(descr, source, (PyObject *)type); - CHECK_OBJECT(called_object); - - Py_DECREF(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS1( - called_object, - args - ); - Py_DECREF(called_object); - - return result; - } - } - - if (descr != NULL) { - CHECK_OBJECT(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS1( - descr, - args - ); - Py_DECREF(descr); - - return result; - } - -#if PYTHON_VERSION < 0x300 - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "'%s' object has no attribute '%s'", - type->tp_name, - PyString_AS_STRING(attr_name) - ); -#else - PyErr_Format( - PyExc_AttributeError, - "'%s' object has no attribute '%U'", - type->tp_name, - attr_name - ); -#endif - return NULL; - } -#if PYTHON_VERSION < 0x300 - else if (type == &PyInstance_Type) { - PyInstanceObject *source_instance = (PyInstanceObject *)source; - - // The special cases have their own variant on the code generation level - // as we are called with constants only. - assert(attr_name != const_str_plain___dict__); - assert(attr_name != const_str_plain___class__); - - // Try the instance dict first. - PyObject *called_object = GET_STRING_DICT_VALUE( - (PyDictObject *)source_instance->in_dict, - (PyStringObject *)attr_name - ); - - // Note: The "called_object" was found without taking a reference, - // so we need not release it in this branch. - if (called_object != NULL) { - return CALL_FUNCTION_WITH_ARGS1(called_object, args); - } - - // Then check the class dictionaries. - called_object = FIND_ATTRIBUTE_IN_CLASS( - source_instance->in_class, - attr_name - ); - - // Note: The "called_object" was found without taking a reference, - // so we need not release it in this branch. - if (called_object != NULL) { - descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get; - - if (descr_get == Nuitka_Function_Type.tp_descr_get) { - return Nuitka_CallMethodFunctionPosArgs( - (struct Nuitka_FunctionObject const *)called_object, - source, - args, - 1 - ); - } else if (descr_get != NULL) { - PyObject *method = descr_get( - called_object, - source, - (PyObject *)source_instance->in_class - ); - - if (unlikely(method == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS1(method, args); - Py_DECREF(method); - return result; - } else { - return CALL_FUNCTION_WITH_ARGS1(called_object, args); - } - - } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) { - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "%s instance has no attribute '%s'", - PyString_AS_STRING(source_instance->in_class->cl_name), - PyString_AS_STRING(attr_name) - ); - - return NULL; - } else { - // Finally allow the "__getattr__" override to provide it or else - // it's an error. - - PyObject *args2[] = { - source, - attr_name - }; - - called_object = CALL_FUNCTION_WITH_ARGS2( - source_instance->in_class->cl_getattr, - args2 - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS1( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } - } -#endif - else if (type->tp_getattro != NULL) { - PyObject *called_object = (*type->tp_getattro)( - source, - attr_name - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS1( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } else if (type->tp_getattr != NULL) { - PyObject *called_object = (*type->tp_getattr)( - source, - (char *)Nuitka_String_AsString_Unchecked(attr_name) - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS1( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } else { - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "'%s' object has no attribute '%s'", - type->tp_name, - Nuitka_String_AsString_Unchecked(attr_name) - ); - - return NULL; - } -} - -PyObject *CALL_METHOD_WITH_ARGS2(PyObject *source, PyObject *attr_name, PyObject **args) { - CHECK_OBJECT(source); - CHECK_OBJECT(attr_name); - - // Check if arguments are valid objects in debug mode. -#ifndef __NUITKA_NO_ASSERT__ - for (size_t i = 0; i < 2; i++) { - CHECK_OBJECT(args[i]); - } -#endif - - PyTypeObject *type = Py_TYPE(source); - - if (type->tp_getattro == PyObject_GenericGetAttr) { - // Unfortunately this is required, although of cause rarely necessary. - if (unlikely(type->tp_dict == NULL)) { - if (unlikely(PyType_Ready(type) < 0)) { - return NULL; - } - } - - PyObject *descr = _PyType_Lookup(type, attr_name); - descrgetfunc func = NULL; - - if (descr != NULL) { - Py_INCREF(descr); - -#if PYTHON_VERSION < 0x300 - if (PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)) { -#endif - func = Py_TYPE(descr)->tp_descr_get; - - if (func != NULL && PyDescr_IsData(descr)) { - PyObject *called_object = func(descr, source, (PyObject *)type); - Py_DECREF(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS2( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } -#if PYTHON_VERSION < 0x300 - } -#endif - } - - Py_ssize_t dictoffset = type->tp_dictoffset; - PyObject *dict = NULL; - - if (dictoffset != 0) { - // Negative dictionary offsets have special meaning. - if (dictoffset < 0) { - Py_ssize_t tsize; - size_t size; - - tsize = ((PyVarObject *)source)->ob_size; - if (tsize < 0) { - tsize = -tsize; - } - size = _PyObject_VAR_SIZE( type, tsize ); - - dictoffset += (long)size; - } - - PyObject **dictptr = (PyObject **) ((char *)source + dictoffset); - dict = *dictptr; - } - - if (dict != NULL) { - CHECK_OBJECT(dict); - - Py_INCREF(dict); - - PyObject *called_object = DICT_GET_ITEM1(dict, attr_name); - - if (called_object != NULL) { - Py_XDECREF(descr); - Py_DECREF(dict); - - PyObject *result = CALL_FUNCTION_WITH_ARGS2( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } - - Py_DECREF(dict); - } - - if (func != NULL) { - if (func == Nuitka_Function_Type.tp_descr_get) { - PyObject *result = Nuitka_CallMethodFunctionPosArgs( - (struct Nuitka_FunctionObject const *)descr, - source, - args, - 2 - ); - - Py_DECREF(descr); - - return result; - } else { - PyObject *called_object = func(descr, source, (PyObject *)type); - CHECK_OBJECT(called_object); - - Py_DECREF(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS2( - called_object, - args - ); - Py_DECREF(called_object); - - return result; - } - } - - if (descr != NULL) { - CHECK_OBJECT(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS2( - descr, - args - ); - Py_DECREF(descr); - - return result; - } - -#if PYTHON_VERSION < 0x300 - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "'%s' object has no attribute '%s'", - type->tp_name, - PyString_AS_STRING(attr_name) - ); -#else - PyErr_Format( - PyExc_AttributeError, - "'%s' object has no attribute '%U'", - type->tp_name, - attr_name - ); -#endif - return NULL; - } -#if PYTHON_VERSION < 0x300 - else if (type == &PyInstance_Type) { - PyInstanceObject *source_instance = (PyInstanceObject *)source; - - // The special cases have their own variant on the code generation level - // as we are called with constants only. - assert(attr_name != const_str_plain___dict__); - assert(attr_name != const_str_plain___class__); - - // Try the instance dict first. - PyObject *called_object = GET_STRING_DICT_VALUE( - (PyDictObject *)source_instance->in_dict, - (PyStringObject *)attr_name - ); - - // Note: The "called_object" was found without taking a reference, - // so we need not release it in this branch. - if (called_object != NULL) { - return CALL_FUNCTION_WITH_ARGS2(called_object, args); - } - - // Then check the class dictionaries. - called_object = FIND_ATTRIBUTE_IN_CLASS( - source_instance->in_class, - attr_name - ); - - // Note: The "called_object" was found without taking a reference, - // so we need not release it in this branch. - if (called_object != NULL) { - descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get; - - if (descr_get == Nuitka_Function_Type.tp_descr_get) { - return Nuitka_CallMethodFunctionPosArgs( - (struct Nuitka_FunctionObject const *)called_object, - source, - args, - 2 - ); - } else if (descr_get != NULL) { - PyObject *method = descr_get( - called_object, - source, - (PyObject *)source_instance->in_class - ); - - if (unlikely(method == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS2(method, args); - Py_DECREF(method); - return result; - } else { - return CALL_FUNCTION_WITH_ARGS2(called_object, args); - } - - } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) { - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "%s instance has no attribute '%s'", - PyString_AS_STRING(source_instance->in_class->cl_name), - PyString_AS_STRING(attr_name) - ); - - return NULL; - } else { - // Finally allow the "__getattr__" override to provide it or else - // it's an error. - - PyObject *args2[] = { - source, - attr_name - }; - - called_object = CALL_FUNCTION_WITH_ARGS2( - source_instance->in_class->cl_getattr, - args2 - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS2( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } - } -#endif - else if (type->tp_getattro != NULL) { - PyObject *called_object = (*type->tp_getattro)( - source, - attr_name - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS2( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } else if (type->tp_getattr != NULL) { - PyObject *called_object = (*type->tp_getattr)( - source, - (char *)Nuitka_String_AsString_Unchecked(attr_name) - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS2( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } else { - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "'%s' object has no attribute '%s'", - type->tp_name, - Nuitka_String_AsString_Unchecked(attr_name) - ); - - return NULL; - } -} - -PyObject *CALL_METHOD_WITH_ARGS3(PyObject *source, PyObject *attr_name, PyObject **args) { - CHECK_OBJECT(source); - CHECK_OBJECT(attr_name); - - // Check if arguments are valid objects in debug mode. -#ifndef __NUITKA_NO_ASSERT__ - for (size_t i = 0; i < 3; i++) { - CHECK_OBJECT(args[i]); - } -#endif - - PyTypeObject *type = Py_TYPE(source); - - if (type->tp_getattro == PyObject_GenericGetAttr) { - // Unfortunately this is required, although of cause rarely necessary. - if (unlikely(type->tp_dict == NULL)) { - if (unlikely(PyType_Ready(type) < 0)) { - return NULL; - } - } - - PyObject *descr = _PyType_Lookup(type, attr_name); - descrgetfunc func = NULL; - - if (descr != NULL) { - Py_INCREF(descr); - -#if PYTHON_VERSION < 0x300 - if (PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)) { -#endif - func = Py_TYPE(descr)->tp_descr_get; - - if (func != NULL && PyDescr_IsData(descr)) { - PyObject *called_object = func(descr, source, (PyObject *)type); - Py_DECREF(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS3( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } -#if PYTHON_VERSION < 0x300 - } -#endif - } - - Py_ssize_t dictoffset = type->tp_dictoffset; - PyObject *dict = NULL; - - if (dictoffset != 0) { - // Negative dictionary offsets have special meaning. - if (dictoffset < 0) { - Py_ssize_t tsize; - size_t size; - - tsize = ((PyVarObject *)source)->ob_size; - if (tsize < 0) { - tsize = -tsize; - } - size = _PyObject_VAR_SIZE( type, tsize ); - - dictoffset += (long)size; - } - - PyObject **dictptr = (PyObject **) ((char *)source + dictoffset); - dict = *dictptr; - } - - if (dict != NULL) { - CHECK_OBJECT(dict); - - Py_INCREF(dict); - - PyObject *called_object = DICT_GET_ITEM1(dict, attr_name); - - if (called_object != NULL) { - Py_XDECREF(descr); - Py_DECREF(dict); - - PyObject *result = CALL_FUNCTION_WITH_ARGS3( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } - - Py_DECREF(dict); - } - - if (func != NULL) { - if (func == Nuitka_Function_Type.tp_descr_get) { - PyObject *result = Nuitka_CallMethodFunctionPosArgs( - (struct Nuitka_FunctionObject const *)descr, - source, - args, - 3 - ); - - Py_DECREF(descr); - - return result; - } else { - PyObject *called_object = func(descr, source, (PyObject *)type); - CHECK_OBJECT(called_object); - - Py_DECREF(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS3( - called_object, - args - ); - Py_DECREF(called_object); - - return result; - } - } - - if (descr != NULL) { - CHECK_OBJECT(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS3( - descr, - args - ); - Py_DECREF(descr); - - return result; - } - -#if PYTHON_VERSION < 0x300 - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "'%s' object has no attribute '%s'", - type->tp_name, - PyString_AS_STRING(attr_name) - ); -#else - PyErr_Format( - PyExc_AttributeError, - "'%s' object has no attribute '%U'", - type->tp_name, - attr_name - ); -#endif - return NULL; - } -#if PYTHON_VERSION < 0x300 - else if (type == &PyInstance_Type) { - PyInstanceObject *source_instance = (PyInstanceObject *)source; - - // The special cases have their own variant on the code generation level - // as we are called with constants only. - assert(attr_name != const_str_plain___dict__); - assert(attr_name != const_str_plain___class__); - - // Try the instance dict first. - PyObject *called_object = GET_STRING_DICT_VALUE( - (PyDictObject *)source_instance->in_dict, - (PyStringObject *)attr_name - ); - - // Note: The "called_object" was found without taking a reference, - // so we need not release it in this branch. - if (called_object != NULL) { - return CALL_FUNCTION_WITH_ARGS3(called_object, args); - } - - // Then check the class dictionaries. - called_object = FIND_ATTRIBUTE_IN_CLASS( - source_instance->in_class, - attr_name - ); - - // Note: The "called_object" was found without taking a reference, - // so we need not release it in this branch. - if (called_object != NULL) { - descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get; - - if (descr_get == Nuitka_Function_Type.tp_descr_get) { - return Nuitka_CallMethodFunctionPosArgs( - (struct Nuitka_FunctionObject const *)called_object, - source, - args, - 3 - ); - } else if (descr_get != NULL) { - PyObject *method = descr_get( - called_object, - source, - (PyObject *)source_instance->in_class - ); - - if (unlikely(method == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS3(method, args); - Py_DECREF(method); - return result; - } else { - return CALL_FUNCTION_WITH_ARGS3(called_object, args); - } - - } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) { - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "%s instance has no attribute '%s'", - PyString_AS_STRING(source_instance->in_class->cl_name), - PyString_AS_STRING(attr_name) - ); - - return NULL; - } else { - // Finally allow the "__getattr__" override to provide it or else - // it's an error. - - PyObject *args2[] = { - source, - attr_name - }; - - called_object = CALL_FUNCTION_WITH_ARGS2( - source_instance->in_class->cl_getattr, - args2 - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS3( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } - } -#endif - else if (type->tp_getattro != NULL) { - PyObject *called_object = (*type->tp_getattro)( - source, - attr_name - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS3( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } else if (type->tp_getattr != NULL) { - PyObject *called_object = (*type->tp_getattr)( - source, - (char *)Nuitka_String_AsString_Unchecked(attr_name) - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS3( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } else { - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "'%s' object has no attribute '%s'", - type->tp_name, - Nuitka_String_AsString_Unchecked(attr_name) - ); - - return NULL; - } -} - -PyObject *CALL_METHOD_WITH_ARGS4(PyObject *source, PyObject *attr_name, PyObject **args) { - CHECK_OBJECT(source); - CHECK_OBJECT(attr_name); - - // Check if arguments are valid objects in debug mode. -#ifndef __NUITKA_NO_ASSERT__ - for (size_t i = 0; i < 4; i++) { - CHECK_OBJECT(args[i]); - } -#endif - - PyTypeObject *type = Py_TYPE(source); - - if (type->tp_getattro == PyObject_GenericGetAttr) { - // Unfortunately this is required, although of cause rarely necessary. - if (unlikely(type->tp_dict == NULL)) { - if (unlikely(PyType_Ready(type) < 0)) { - return NULL; - } - } - - PyObject *descr = _PyType_Lookup(type, attr_name); - descrgetfunc func = NULL; - - if (descr != NULL) { - Py_INCREF(descr); - -#if PYTHON_VERSION < 0x300 - if (PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)) { -#endif - func = Py_TYPE(descr)->tp_descr_get; - - if (func != NULL && PyDescr_IsData(descr)) { - PyObject *called_object = func(descr, source, (PyObject *)type); - Py_DECREF(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS4( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } -#if PYTHON_VERSION < 0x300 - } -#endif - } - - Py_ssize_t dictoffset = type->tp_dictoffset; - PyObject *dict = NULL; - - if (dictoffset != 0) { - // Negative dictionary offsets have special meaning. - if (dictoffset < 0) { - Py_ssize_t tsize; - size_t size; - - tsize = ((PyVarObject *)source)->ob_size; - if (tsize < 0) { - tsize = -tsize; - } - size = _PyObject_VAR_SIZE( type, tsize ); - - dictoffset += (long)size; - } - - PyObject **dictptr = (PyObject **) ((char *)source + dictoffset); - dict = *dictptr; - } - - if (dict != NULL) { - CHECK_OBJECT(dict); - - Py_INCREF(dict); - - PyObject *called_object = DICT_GET_ITEM1(dict, attr_name); - - if (called_object != NULL) { - Py_XDECREF(descr); - Py_DECREF(dict); - - PyObject *result = CALL_FUNCTION_WITH_ARGS4( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } - - Py_DECREF(dict); - } - - if (func != NULL) { - if (func == Nuitka_Function_Type.tp_descr_get) { - PyObject *result = Nuitka_CallMethodFunctionPosArgs( - (struct Nuitka_FunctionObject const *)descr, - source, - args, - 4 - ); - - Py_DECREF(descr); - - return result; - } else { - PyObject *called_object = func(descr, source, (PyObject *)type); - CHECK_OBJECT(called_object); - - Py_DECREF(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS4( - called_object, - args - ); - Py_DECREF(called_object); - - return result; - } - } - - if (descr != NULL) { - CHECK_OBJECT(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS4( - descr, - args - ); - Py_DECREF(descr); - - return result; - } - -#if PYTHON_VERSION < 0x300 - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "'%s' object has no attribute '%s'", - type->tp_name, - PyString_AS_STRING(attr_name) - ); -#else - PyErr_Format( - PyExc_AttributeError, - "'%s' object has no attribute '%U'", - type->tp_name, - attr_name - ); -#endif - return NULL; - } -#if PYTHON_VERSION < 0x300 - else if (type == &PyInstance_Type) { - PyInstanceObject *source_instance = (PyInstanceObject *)source; - - // The special cases have their own variant on the code generation level - // as we are called with constants only. - assert(attr_name != const_str_plain___dict__); - assert(attr_name != const_str_plain___class__); - - // Try the instance dict first. - PyObject *called_object = GET_STRING_DICT_VALUE( - (PyDictObject *)source_instance->in_dict, - (PyStringObject *)attr_name - ); - - // Note: The "called_object" was found without taking a reference, - // so we need not release it in this branch. - if (called_object != NULL) { - return CALL_FUNCTION_WITH_ARGS4(called_object, args); - } - - // Then check the class dictionaries. - called_object = FIND_ATTRIBUTE_IN_CLASS( - source_instance->in_class, - attr_name - ); - - // Note: The "called_object" was found without taking a reference, - // so we need not release it in this branch. - if (called_object != NULL) { - descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get; - - if (descr_get == Nuitka_Function_Type.tp_descr_get) { - return Nuitka_CallMethodFunctionPosArgs( - (struct Nuitka_FunctionObject const *)called_object, - source, - args, - 4 - ); - } else if (descr_get != NULL) { - PyObject *method = descr_get( - called_object, - source, - (PyObject *)source_instance->in_class - ); - - if (unlikely(method == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS4(method, args); - Py_DECREF(method); - return result; - } else { - return CALL_FUNCTION_WITH_ARGS4(called_object, args); - } - - } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) { - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "%s instance has no attribute '%s'", - PyString_AS_STRING(source_instance->in_class->cl_name), - PyString_AS_STRING(attr_name) - ); - - return NULL; - } else { - // Finally allow the "__getattr__" override to provide it or else - // it's an error. - - PyObject *args2[] = { - source, - attr_name - }; - - called_object = CALL_FUNCTION_WITH_ARGS2( - source_instance->in_class->cl_getattr, - args2 - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS4( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } - } -#endif - else if (type->tp_getattro != NULL) { - PyObject *called_object = (*type->tp_getattro)( - source, - attr_name - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS4( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } else if (type->tp_getattr != NULL) { - PyObject *called_object = (*type->tp_getattr)( - source, - (char *)Nuitka_String_AsString_Unchecked(attr_name) - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS4( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } else { - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "'%s' object has no attribute '%s'", - type->tp_name, - Nuitka_String_AsString_Unchecked(attr_name) - ); - - return NULL; - } -} - -PyObject *CALL_METHOD_WITH_ARGS5(PyObject *source, PyObject *attr_name, PyObject **args) { - CHECK_OBJECT(source); - CHECK_OBJECT(attr_name); - - // Check if arguments are valid objects in debug mode. -#ifndef __NUITKA_NO_ASSERT__ - for (size_t i = 0; i < 5; i++) { - CHECK_OBJECT(args[i]); - } -#endif - - PyTypeObject *type = Py_TYPE(source); - - if (type->tp_getattro == PyObject_GenericGetAttr) { - // Unfortunately this is required, although of cause rarely necessary. - if (unlikely(type->tp_dict == NULL)) { - if (unlikely(PyType_Ready(type) < 0)) { - return NULL; - } - } - - PyObject *descr = _PyType_Lookup(type, attr_name); - descrgetfunc func = NULL; - - if (descr != NULL) { - Py_INCREF(descr); - -#if PYTHON_VERSION < 0x300 - if (PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)) { -#endif - func = Py_TYPE(descr)->tp_descr_get; - - if (func != NULL && PyDescr_IsData(descr)) { - PyObject *called_object = func(descr, source, (PyObject *)type); - Py_DECREF(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS5( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } -#if PYTHON_VERSION < 0x300 - } -#endif - } - - Py_ssize_t dictoffset = type->tp_dictoffset; - PyObject *dict = NULL; - - if (dictoffset != 0) { - // Negative dictionary offsets have special meaning. - if (dictoffset < 0) { - Py_ssize_t tsize; - size_t size; - - tsize = ((PyVarObject *)source)->ob_size; - if (tsize < 0) { - tsize = -tsize; - } - size = _PyObject_VAR_SIZE( type, tsize ); - - dictoffset += (long)size; - } - - PyObject **dictptr = (PyObject **) ((char *)source + dictoffset); - dict = *dictptr; - } - - if (dict != NULL) { - CHECK_OBJECT(dict); - - Py_INCREF(dict); - - PyObject *called_object = DICT_GET_ITEM1(dict, attr_name); - - if (called_object != NULL) { - Py_XDECREF(descr); - Py_DECREF(dict); - - PyObject *result = CALL_FUNCTION_WITH_ARGS5( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } - - Py_DECREF(dict); - } - - if (func != NULL) { - if (func == Nuitka_Function_Type.tp_descr_get) { - PyObject *result = Nuitka_CallMethodFunctionPosArgs( - (struct Nuitka_FunctionObject const *)descr, - source, - args, - 5 - ); - - Py_DECREF(descr); - - return result; - } else { - PyObject *called_object = func(descr, source, (PyObject *)type); - CHECK_OBJECT(called_object); - - Py_DECREF(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS5( - called_object, - args - ); - Py_DECREF(called_object); - - return result; - } - } - - if (descr != NULL) { - CHECK_OBJECT(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS5( - descr, - args - ); - Py_DECREF(descr); - - return result; - } - -#if PYTHON_VERSION < 0x300 - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "'%s' object has no attribute '%s'", - type->tp_name, - PyString_AS_STRING(attr_name) - ); -#else - PyErr_Format( - PyExc_AttributeError, - "'%s' object has no attribute '%U'", - type->tp_name, - attr_name - ); -#endif - return NULL; - } -#if PYTHON_VERSION < 0x300 - else if (type == &PyInstance_Type) { - PyInstanceObject *source_instance = (PyInstanceObject *)source; - - // The special cases have their own variant on the code generation level - // as we are called with constants only. - assert(attr_name != const_str_plain___dict__); - assert(attr_name != const_str_plain___class__); - - // Try the instance dict first. - PyObject *called_object = GET_STRING_DICT_VALUE( - (PyDictObject *)source_instance->in_dict, - (PyStringObject *)attr_name - ); - - // Note: The "called_object" was found without taking a reference, - // so we need not release it in this branch. - if (called_object != NULL) { - return CALL_FUNCTION_WITH_ARGS5(called_object, args); - } - - // Then check the class dictionaries. - called_object = FIND_ATTRIBUTE_IN_CLASS( - source_instance->in_class, - attr_name - ); - - // Note: The "called_object" was found without taking a reference, - // so we need not release it in this branch. - if (called_object != NULL) { - descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get; - - if (descr_get == Nuitka_Function_Type.tp_descr_get) { - return Nuitka_CallMethodFunctionPosArgs( - (struct Nuitka_FunctionObject const *)called_object, - source, - args, - 5 - ); - } else if (descr_get != NULL) { - PyObject *method = descr_get( - called_object, - source, - (PyObject *)source_instance->in_class - ); - - if (unlikely(method == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS5(method, args); - Py_DECREF(method); - return result; - } else { - return CALL_FUNCTION_WITH_ARGS5(called_object, args); - } - - } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) { - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "%s instance has no attribute '%s'", - PyString_AS_STRING(source_instance->in_class->cl_name), - PyString_AS_STRING(attr_name) - ); - - return NULL; - } else { - // Finally allow the "__getattr__" override to provide it or else - // it's an error. - - PyObject *args2[] = { - source, - attr_name - }; - - called_object = CALL_FUNCTION_WITH_ARGS2( - source_instance->in_class->cl_getattr, - args2 - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS5( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } - } -#endif - else if (type->tp_getattro != NULL) { - PyObject *called_object = (*type->tp_getattro)( - source, - attr_name - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS5( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } else if (type->tp_getattr != NULL) { - PyObject *called_object = (*type->tp_getattr)( - source, - (char *)Nuitka_String_AsString_Unchecked(attr_name) - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS5( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } else { - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "'%s' object has no attribute '%s'", - type->tp_name, - Nuitka_String_AsString_Unchecked(attr_name) - ); - - return NULL; - } -} - -PyObject *CALL_METHOD_WITH_ARGS7(PyObject *source, PyObject *attr_name, PyObject **args) { - CHECK_OBJECT(source); - CHECK_OBJECT(attr_name); - - // Check if arguments are valid objects in debug mode. -#ifndef __NUITKA_NO_ASSERT__ - for (size_t i = 0; i < 7; i++) { - CHECK_OBJECT(args[i]); - } -#endif - - PyTypeObject *type = Py_TYPE(source); - - if (type->tp_getattro == PyObject_GenericGetAttr) { - // Unfortunately this is required, although of cause rarely necessary. - if (unlikely(type->tp_dict == NULL)) { - if (unlikely(PyType_Ready(type) < 0)) { - return NULL; - } - } - - PyObject *descr = _PyType_Lookup(type, attr_name); - descrgetfunc func = NULL; - - if (descr != NULL) { - Py_INCREF(descr); - -#if PYTHON_VERSION < 0x300 - if (PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)) { -#endif - func = Py_TYPE(descr)->tp_descr_get; - - if (func != NULL && PyDescr_IsData(descr)) { - PyObject *called_object = func(descr, source, (PyObject *)type); - Py_DECREF(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS7( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } -#if PYTHON_VERSION < 0x300 - } -#endif - } - - Py_ssize_t dictoffset = type->tp_dictoffset; - PyObject *dict = NULL; - - if (dictoffset != 0) { - // Negative dictionary offsets have special meaning. - if (dictoffset < 0) { - Py_ssize_t tsize; - size_t size; - - tsize = ((PyVarObject *)source)->ob_size; - if (tsize < 0) { - tsize = -tsize; - } - size = _PyObject_VAR_SIZE( type, tsize ); - - dictoffset += (long)size; - } - - PyObject **dictptr = (PyObject **) ((char *)source + dictoffset); - dict = *dictptr; - } - - if (dict != NULL) { - CHECK_OBJECT(dict); - - Py_INCREF(dict); - - PyObject *called_object = DICT_GET_ITEM1(dict, attr_name); - - if (called_object != NULL) { - Py_XDECREF(descr); - Py_DECREF(dict); - - PyObject *result = CALL_FUNCTION_WITH_ARGS7( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } - - Py_DECREF(dict); - } - - if (func != NULL) { - if (func == Nuitka_Function_Type.tp_descr_get) { - PyObject *result = Nuitka_CallMethodFunctionPosArgs( - (struct Nuitka_FunctionObject const *)descr, - source, - args, - 7 - ); - - Py_DECREF(descr); - - return result; - } else { - PyObject *called_object = func(descr, source, (PyObject *)type); - CHECK_OBJECT(called_object); - - Py_DECREF(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS7( - called_object, - args - ); - Py_DECREF(called_object); - - return result; - } - } - - if (descr != NULL) { - CHECK_OBJECT(descr); - - PyObject *result = CALL_FUNCTION_WITH_ARGS7( - descr, - args - ); - Py_DECREF(descr); - - return result; - } - -#if PYTHON_VERSION < 0x300 - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "'%s' object has no attribute '%s'", - type->tp_name, - PyString_AS_STRING(attr_name) - ); -#else - PyErr_Format( - PyExc_AttributeError, - "'%s' object has no attribute '%U'", - type->tp_name, - attr_name - ); -#endif - return NULL; - } -#if PYTHON_VERSION < 0x300 - else if (type == &PyInstance_Type) { - PyInstanceObject *source_instance = (PyInstanceObject *)source; - - // The special cases have their own variant on the code generation level - // as we are called with constants only. - assert(attr_name != const_str_plain___dict__); - assert(attr_name != const_str_plain___class__); - - // Try the instance dict first. - PyObject *called_object = GET_STRING_DICT_VALUE( - (PyDictObject *)source_instance->in_dict, - (PyStringObject *)attr_name - ); - - // Note: The "called_object" was found without taking a reference, - // so we need not release it in this branch. - if (called_object != NULL) { - return CALL_FUNCTION_WITH_ARGS7(called_object, args); - } - - // Then check the class dictionaries. - called_object = FIND_ATTRIBUTE_IN_CLASS( - source_instance->in_class, - attr_name - ); - - // Note: The "called_object" was found without taking a reference, - // so we need not release it in this branch. - if (called_object != NULL) { - descrgetfunc descr_get = Py_TYPE(called_object)->tp_descr_get; - - if (descr_get == Nuitka_Function_Type.tp_descr_get) { - return Nuitka_CallMethodFunctionPosArgs( - (struct Nuitka_FunctionObject const *)called_object, - source, - args, - 7 - ); - } else if (descr_get != NULL) { - PyObject *method = descr_get( - called_object, - source, - (PyObject *)source_instance->in_class - ); - - if (unlikely(method == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS7(method, args); - Py_DECREF(method); - return result; - } else { - return CALL_FUNCTION_WITH_ARGS7(called_object, args); - } - - } else if (unlikely(source_instance->in_class->cl_getattr == NULL)) { - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "%s instance has no attribute '%s'", - PyString_AS_STRING(source_instance->in_class->cl_name), - PyString_AS_STRING(attr_name) - ); - - return NULL; - } else { - // Finally allow the "__getattr__" override to provide it or else - // it's an error. - - PyObject *args2[] = { - source, - attr_name - }; - - called_object = CALL_FUNCTION_WITH_ARGS2( - source_instance->in_class->cl_getattr, - args2 - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS7( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } - } -#endif - else if (type->tp_getattro != NULL) { - PyObject *called_object = (*type->tp_getattro)( - source, - attr_name - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS7( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } else if (type->tp_getattr != NULL) { - PyObject *called_object = (*type->tp_getattr)( - source, - (char *)Nuitka_String_AsString_Unchecked(attr_name) - ); - - if (unlikely(called_object == NULL)) { - return NULL; - } - - PyObject *result = CALL_FUNCTION_WITH_ARGS7( - called_object, - args - ); - Py_DECREF(called_object); - return result; - } else { - SET_CURRENT_EXCEPTION_TYPE0_FORMAT2( - PyExc_AttributeError, - "'%s' object has no attribute '%s'", - type->tp_name, - Nuitka_String_AsString_Unchecked(attr_name) - ); - - return NULL; - } -} -