From 4a8133204cc43c82239e72b4ead393401c15b2ee Mon Sep 17 00:00:00 2001 From: Roman Mogylatov Date: Thu, 6 Aug 2020 16:33:06 -0400 Subject: [PATCH] Factory deep init injections (#277) * Add factory deep context providing * Add example * Add test --- .../providers/factory_deep_init_injections.py | 48 + src/dependency_injector/containers.c | 1354 +++++++++++++---- src/dependency_injector/providers.c | 1056 +++++++++++-- src/dependency_injector/providers.pxd | 66 +- .../unit/providers/test_factories_py2_py3.py | 39 + 5 files changed, 2157 insertions(+), 406 deletions(-) create mode 100644 examples/providers/factory_deep_init_injections.py diff --git a/examples/providers/factory_deep_init_injections.py b/examples/providers/factory_deep_init_injections.py new file mode 100644 index 00000000..0cc9fba7 --- /dev/null +++ b/examples/providers/factory_deep_init_injections.py @@ -0,0 +1,48 @@ +"""`Factory` providers deep init injections example.""" + +from dependency_injector import providers + + +class Regularizer: + def __init__(self, alpha): + self.alpha = alpha + + +class Loss: + def __init__(self, regularizer): + self.regularizer = regularizer + + +class ClassificationTask: + def __init__(self, loss): + self.loss = loss + + +class Algorithm: + def __init__(self, task): + self.task = task + + +algorithm_factory = providers.Factory( + Algorithm, + task=providers.Factory( + ClassificationTask, + loss=providers.Factory( + Loss, + regularizer=providers.Factory( + Regularizer, + ), + ), + ), +) + + +if __name__ == '__main__': + algorithm_1 = algorithm_factory(task__loss__regularizer__alpha=0.5) + assert algorithm_1.task.loss.regularizer.alpha == 0.5 + + algorithm_2 = algorithm_factory(task__loss__regularizer__alpha=0.7) + assert algorithm_2.task.loss.regularizer.alpha == 0.7 + + algorithm_3 = algorithm_factory(task__loss__regularizer=Regularizer(alpha=0.8)) + assert algorithm_3.task.loss.regularizer.alpha == 0.8 diff --git a/src/dependency_injector/containers.c b/src/dependency_injector/containers.c index 11dd911a..ebd17ce4 100644 --- a/src/dependency_injector/containers.c +++ b/src/dependency_injector/containers.c @@ -2286,6 +2286,63 @@ static void __Pyx_WriteUnraisable(const char *name, int clineno, int lineno, const char *filename, int full_traceback, int nogil); +/* py_dict_items.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d); + +/* UnpackUnboundCMethod.proto */ +typedef struct { + PyObject *type; + PyObject **method_name; + PyCFunction func; + PyObject *method; + int flag; +} __Pyx_CachedCFunction; + +/* CallUnboundCMethod0.proto */ +static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_CallUnboundCMethod0(cfunc, self)\ + (likely((cfunc)->func) ?\ + (likely((cfunc)->flag == METH_NOARGS) ? (*((cfunc)->func))(self, NULL) :\ + (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\ + (PY_VERSION_HEX >= 0x030700A0 ?\ + (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\ + (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\ + (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\ + (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\ + (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ? ((*(PyCFunctionWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\ + ((cfunc)->flag == METH_VARARGS ? (*((cfunc)->func))(self, __pyx_empty_tuple) :\ + __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\ + __Pyx__CallUnboundCMethod0(cfunc, self)) +#else +#define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self) +#endif + +/* PyIntBinop.proto */ +#if !CYTHON_COMPILING_IN_PYPY +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); +#else +#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\ + (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) +#endif + +/* PyDictContains.proto */ +static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) { + int result = PyDict_Contains(dict, item); + return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); +} + +/* DictGetItem.proto */ +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key); +#define __Pyx_PyObject_Dict_GetItem(obj, name)\ + (likely(PyDict_CheckExact(obj)) ?\ + __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name)) +#else +#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) +#define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name) +#endif + /* ListAppend.proto */ #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { @@ -2316,11 +2373,8 @@ static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) { #endif } -/* PyDictContains.proto */ -static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) { - int result = PyDict_Contains(dict, item); - return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); -} +/* RaiseNoneIterError.proto */ +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); /* IncludeStringH.proto */ #include @@ -2577,6 +2631,8 @@ static PyObject **__pyx_vp_19dependency_injector_9providers_CLASS_TYPES = 0; static PyObject *(*__pyx_f_19dependency_injector_9providers_deepcopy)(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_19dependency_injector_9providers_deepcopy *__pyx_optional_args); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_name(struct __pyx_obj_19dependency_injector_9providers_NamedInjection *); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_value(struct __pyx_obj_19dependency_injector_9providers_Injection *); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_value_kwargs(struct __pyx_obj_19dependency_injector_9providers_Injection *, PyObject *); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___separate_prefixed_kwargs(PyObject *); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provide_positional_args(PyObject *, PyObject *, int); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provide_keyword_args(PyObject *, PyObject *, int); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___inject_attributes(PyObject *, PyObject *, int); /*proto*/ @@ -2601,6 +2657,7 @@ static PyObject *__pyx_builtin_super; static PyObject *__pyx_builtin_id; static PyObject *__pyx_builtin_AttributeError; static PyObject *__pyx_builtin_range; +static const char __pyx_k__6[] = "__"; static const char __pyx_k_id[] = "id"; static const char __pyx_k_cls[] = "cls"; static const char __pyx_k_doc[] = "__doc__"; @@ -2621,6 +2678,7 @@ static const char __pyx_k_Error[] = "Error"; static const char __pyx_k_bases[] = "bases"; static const char __pyx_k_class[] = "__class__"; static const char __pyx_k_close[] = "close"; +static const char __pyx_k_index[] = "index"; static const char __pyx_k_items[] = "items"; static const char __pyx_k_range[] = "range"; static const char __pyx_k_super[] = "super"; @@ -2734,6 +2792,7 @@ static PyObject *__pyx_n_s_DynamicContainer_set_providers; static PyObject *__pyx_kp_s_Dynamic_inversion_of_control_con; static PyObject *__pyx_n_s_Error; static PyObject *__pyx_n_s_IS_CONTAINER; +static PyObject *__pyx_n_s__6; static PyObject *__pyx_n_s_add_metaclass; static PyObject *__pyx_n_s_args; static PyObject *__pyx_n_s_attributes; @@ -2762,6 +2821,7 @@ static PyObject *__pyx_n_s_genexpr; static PyObject *__pyx_n_s_get; static PyObject *__pyx_n_s_id; static PyObject *__pyx_n_s_import; +static PyObject *__pyx_n_s_index; static PyObject *__pyx_n_s_inherited_providers; static PyObject *__pyx_n_s_init; static PyObject *__pyx_n_s_instance_type; @@ -2837,50 +2897,52 @@ static PyObject *__pyx_tp_new_19dependency_injector_10containers___pyx_scope_str static PyObject *__pyx_tp_new_19dependency_injector_10containers___pyx_scope_struct_3_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_19dependency_injector_10containers___pyx_scope_struct_4_override(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_19dependency_injector_10containers___pyx_scope_struct_5_copy(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items = {0, &__pyx_n_s_items, 0, 0, 0}; +static PyObject *__pyx_int_2; static PyObject *__pyx_int_neg_1; static PyObject *__pyx_slice_; static PyObject *__pyx_tuple__2; static PyObject *__pyx_tuple__4; -static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; -static PyObject *__pyx_tuple__9; -static PyObject *__pyx_tuple__11; -static PyObject *__pyx_tuple__13; -static PyObject *__pyx_tuple__15; -static PyObject *__pyx_tuple__17; -static PyObject *__pyx_tuple__19; -static PyObject *__pyx_tuple__21; -static PyObject *__pyx_tuple__23; -static PyObject *__pyx_tuple__25; -static PyObject *__pyx_tuple__27; -static PyObject *__pyx_tuple__29; -static PyObject *__pyx_tuple__31; +static PyObject *__pyx_tuple__8; +static PyObject *__pyx_tuple__10; +static PyObject *__pyx_tuple__12; +static PyObject *__pyx_tuple__14; +static PyObject *__pyx_tuple__16; +static PyObject *__pyx_tuple__18; +static PyObject *__pyx_tuple__20; +static PyObject *__pyx_tuple__22; +static PyObject *__pyx_tuple__24; +static PyObject *__pyx_tuple__26; +static PyObject *__pyx_tuple__28; +static PyObject *__pyx_tuple__30; static PyObject *__pyx_tuple__32; -static PyObject *__pyx_tuple__34; -static PyObject *__pyx_tuple__36; -static PyObject *__pyx_tuple__38; -static PyObject *__pyx_tuple__40; -static PyObject *__pyx_tuple__42; +static PyObject *__pyx_tuple__33; +static PyObject *__pyx_tuple__35; +static PyObject *__pyx_tuple__37; +static PyObject *__pyx_tuple__39; +static PyObject *__pyx_tuple__41; +static PyObject *__pyx_tuple__43; static PyObject *__pyx_codeobj__3; static PyObject *__pyx_codeobj__5; -static PyObject *__pyx_codeobj__8; -static PyObject *__pyx_codeobj__10; -static PyObject *__pyx_codeobj__12; -static PyObject *__pyx_codeobj__14; -static PyObject *__pyx_codeobj__16; -static PyObject *__pyx_codeobj__18; -static PyObject *__pyx_codeobj__20; -static PyObject *__pyx_codeobj__22; -static PyObject *__pyx_codeobj__24; -static PyObject *__pyx_codeobj__26; -static PyObject *__pyx_codeobj__28; -static PyObject *__pyx_codeobj__30; -static PyObject *__pyx_codeobj__33; -static PyObject *__pyx_codeobj__35; -static PyObject *__pyx_codeobj__37; -static PyObject *__pyx_codeobj__39; -static PyObject *__pyx_codeobj__41; -static PyObject *__pyx_codeobj__43; +static PyObject *__pyx_codeobj__9; +static PyObject *__pyx_codeobj__11; +static PyObject *__pyx_codeobj__13; +static PyObject *__pyx_codeobj__15; +static PyObject *__pyx_codeobj__17; +static PyObject *__pyx_codeobj__19; +static PyObject *__pyx_codeobj__21; +static PyObject *__pyx_codeobj__23; +static PyObject *__pyx_codeobj__25; +static PyObject *__pyx_codeobj__27; +static PyObject *__pyx_codeobj__29; +static PyObject *__pyx_codeobj__31; +static PyObject *__pyx_codeobj__34; +static PyObject *__pyx_codeobj__36; +static PyObject *__pyx_codeobj__38; +static PyObject *__pyx_codeobj__40; +static PyObject *__pyx_codeobj__42; +static PyObject *__pyx_codeobj__44; /* Late includes */ /* "dependency_injector/containers.pyx":47 @@ -9504,12 +9566,448 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_va return __pyx_r; } -/* "providers.pxd":255 +/* "providers.pxd":253 + * + * + * cdef inline object __get_value_kwargs(Injection self, dict kwargs): # <<<<<<<<<<<<<< + * if self.__call == 0: + * return self.__value + */ + +static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_value_kwargs(struct __pyx_obj_19dependency_injector_9providers_Injection *__pyx_v_self, PyObject *__pyx_v_kwargs) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get_value_kwargs", 0); + + /* "providers.pxd":254 + * + * cdef inline object __get_value_kwargs(Injection self, dict kwargs): + * if self.__call == 0: # <<<<<<<<<<<<<< + * return self.__value + * return self.__value(**kwargs) + */ + __pyx_t_1 = ((__pyx_v_self->__pyx___call == 0) != 0); + if (__pyx_t_1) { + + /* "providers.pxd":255 + * cdef inline object __get_value_kwargs(Injection self, dict kwargs): + * if self.__call == 0: + * return self.__value # <<<<<<<<<<<<<< + * return self.__value(**kwargs) + * + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->__pyx___value); + __pyx_r = __pyx_v_self->__pyx___value; + goto __pyx_L0; + + /* "providers.pxd":254 + * + * cdef inline object __get_value_kwargs(Injection self, dict kwargs): + * if self.__call == 0: # <<<<<<<<<<<<<< + * return self.__value + * return self.__value(**kwargs) + */ + } + + /* "providers.pxd":256 + * if self.__call == 0: + * return self.__value + * return self.__value(**kwargs) # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + if (unlikely(__pyx_v_kwargs == Py_None)) { + PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); + __PYX_ERR(1, 256, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_self->__pyx___value, __pyx_empty_tuple, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 256, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "providers.pxd":253 + * + * + * cdef inline object __get_value_kwargs(Injection self, dict kwargs): # <<<<<<<<<<<<<< + * if self.__call == 0: + * return self.__value + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("dependency_injector.providers.__get_value_kwargs", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "providers.pxd":259 + * + * + * cdef inline tuple __separate_prefixed_kwargs(dict kwargs): # <<<<<<<<<<<<<< + * cdef dict plain_kwargs = {} + * cdef dict prefixed_kwargs = {} + */ + +static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___separate_prefixed_kwargs(PyObject *__pyx_v_kwargs) { + PyObject *__pyx_v_plain_kwargs = 0; + PyObject *__pyx_v_prefixed_kwargs = 0; + PyObject *__pyx_v_key = NULL; + PyObject *__pyx_v_value = NULL; + PyObject *__pyx_v_index = NULL; + PyObject *__pyx_v_prefix = NULL; + PyObject *__pyx_v_name = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *(*__pyx_t_8)(PyObject *); + int __pyx_t_9; + int __pyx_t_10; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__separate_prefixed_kwargs", 0); + + /* "providers.pxd":260 + * + * cdef inline tuple __separate_prefixed_kwargs(dict kwargs): + * cdef dict plain_kwargs = {} # <<<<<<<<<<<<<< + * cdef dict prefixed_kwargs = {} + * + */ + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 260, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_plain_kwargs = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "providers.pxd":261 + * cdef inline tuple __separate_prefixed_kwargs(dict kwargs): + * cdef dict plain_kwargs = {} + * cdef dict prefixed_kwargs = {} # <<<<<<<<<<<<<< + * + * for key, value in kwargs.items(): + */ + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 261, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_prefixed_kwargs = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "providers.pxd":263 + * cdef dict prefixed_kwargs = {} + * + * for key, value in kwargs.items(): # <<<<<<<<<<<<<< + * if '__' not in key: + * plain_kwargs[key] = value + */ + if (unlikely(__pyx_v_kwargs == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); + __PYX_ERR(1, 263, __pyx_L1_error) + } + __pyx_t_1 = __Pyx_PyDict_Items(__pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { + __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 263, __pyx_L1_error) + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + for (;;) { + if (likely(!__pyx_t_4)) { + if (likely(PyList_CheckExact(__pyx_t_2))) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 263, __pyx_L1_error) + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + #endif + } else { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 263, __pyx_L1_error) + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + #endif + } + } else { + __pyx_t_1 = __pyx_t_4(__pyx_t_2); + if (unlikely(!__pyx_t_1)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(1, 263, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { + PyObject* sequence = __pyx_t_1; + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(1, 263, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_5 = PyList_GET_ITEM(sequence, 0); + __pyx_t_6 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + #else + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; + index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_5); + index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_6); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(1, 263, __pyx_L1_error) + __pyx_t_8 = NULL; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + goto __pyx_L6_unpacking_done; + __pyx_L5_unpacking_failed:; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_8 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + __PYX_ERR(1, 263, __pyx_L1_error) + __pyx_L6_unpacking_done:; + } + __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_5); + __pyx_t_5 = 0; + __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_6); + __pyx_t_6 = 0; + + /* "providers.pxd":264 + * + * for key, value in kwargs.items(): + * if '__' not in key: # <<<<<<<<<<<<<< + * plain_kwargs[key] = value + * continue + */ + __pyx_t_9 = (__Pyx_PySequence_ContainsTF(__pyx_n_s__6, __pyx_v_key, Py_NE)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(1, 264, __pyx_L1_error) + __pyx_t_10 = (__pyx_t_9 != 0); + if (__pyx_t_10) { + + /* "providers.pxd":265 + * for key, value in kwargs.items(): + * if '__' not in key: + * plain_kwargs[key] = value # <<<<<<<<<<<<<< + * continue + * + */ + if (unlikely(PyDict_SetItem(__pyx_v_plain_kwargs, __pyx_v_key, __pyx_v_value) < 0)) __PYX_ERR(1, 265, __pyx_L1_error) + + /* "providers.pxd":266 + * if '__' not in key: + * plain_kwargs[key] = value + * continue # <<<<<<<<<<<<<< + * + * index = key.index('__') + */ + goto __pyx_L3_continue; + + /* "providers.pxd":264 + * + * for key, value in kwargs.items(): + * if '__' not in key: # <<<<<<<<<<<<<< + * plain_kwargs[key] = value + * continue + */ + } + + /* "providers.pxd":268 + * continue + * + * index = key.index('__') # <<<<<<<<<<<<<< + * prefix, name = key[:index], key[index+2:] + * + */ + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_key, __pyx_n_s_index); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 268, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_5 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_6, function); + } + } + __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_n_s__6) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_n_s__6); + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 268, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_1); + __pyx_t_1 = 0; + + /* "providers.pxd":269 + * + * index = key.index('__') + * prefix, name = key[:index], key[index+2:] # <<<<<<<<<<<<<< + * + * if prefix not in prefixed_kwargs: + */ + __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_key, 0, 0, NULL, &__pyx_v_index, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 269, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_v_index, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 269, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_v_key, 0, 0, &__pyx_t_6, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 269, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_prefix, __pyx_t_1); + __pyx_t_1 = 0; + __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_5); + __pyx_t_5 = 0; + + /* "providers.pxd":271 + * prefix, name = key[:index], key[index+2:] + * + * if prefix not in prefixed_kwargs: # <<<<<<<<<<<<<< + * prefixed_kwargs[prefix] = {} + * prefixed_kwargs[prefix][name] = value + */ + __pyx_t_10 = (__Pyx_PyDict_ContainsTF(__pyx_v_prefix, __pyx_v_prefixed_kwargs, Py_NE)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(1, 271, __pyx_L1_error) + __pyx_t_9 = (__pyx_t_10 != 0); + if (__pyx_t_9) { + + /* "providers.pxd":272 + * + * if prefix not in prefixed_kwargs: + * prefixed_kwargs[prefix] = {} # <<<<<<<<<<<<<< + * prefixed_kwargs[prefix][name] = value + * + */ + __pyx_t_5 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 272, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (unlikely(PyDict_SetItem(__pyx_v_prefixed_kwargs, __pyx_v_prefix, __pyx_t_5) < 0)) __PYX_ERR(1, 272, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "providers.pxd":271 + * prefix, name = key[:index], key[index+2:] + * + * if prefix not in prefixed_kwargs: # <<<<<<<<<<<<<< + * prefixed_kwargs[prefix] = {} + * prefixed_kwargs[prefix][name] = value + */ + } + + /* "providers.pxd":273 + * if prefix not in prefixed_kwargs: + * prefixed_kwargs[prefix] = {} + * prefixed_kwargs[prefix][name] = value # <<<<<<<<<<<<<< + * + * return plain_kwargs, prefixed_kwargs + */ + __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_prefixed_kwargs, __pyx_v_prefix); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 273, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_v_name, __pyx_v_value) < 0)) __PYX_ERR(1, 273, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "providers.pxd":263 + * cdef dict prefixed_kwargs = {} + * + * for key, value in kwargs.items(): # <<<<<<<<<<<<<< + * if '__' not in key: + * plain_kwargs[key] = value + */ + __pyx_L3_continue:; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "providers.pxd":275 + * prefixed_kwargs[prefix][name] = value + * + * return plain_kwargs, prefixed_kwargs # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 275, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_v_plain_kwargs); + __Pyx_GIVEREF(__pyx_v_plain_kwargs); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_plain_kwargs); + __Pyx_INCREF(__pyx_v_prefixed_kwargs); + __Pyx_GIVEREF(__pyx_v_prefixed_kwargs); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_prefixed_kwargs); + __pyx_r = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "providers.pxd":259 + * + * + * cdef inline tuple __separate_prefixed_kwargs(dict kwargs): # <<<<<<<<<<<<<< + * cdef dict plain_kwargs = {} + * cdef dict prefixed_kwargs = {} + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("dependency_injector.providers.__separate_prefixed_kwargs", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_plain_kwargs); + __Pyx_XDECREF(__pyx_v_prefixed_kwargs); + __Pyx_XDECREF(__pyx_v_key); + __Pyx_XDECREF(__pyx_v_value); + __Pyx_XDECREF(__pyx_v_index); + __Pyx_XDECREF(__pyx_v_prefix); + __Pyx_XDECREF(__pyx_v_name); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "providers.pxd":280 * @cython.boundscheck(False) * @cython.wraparound(False) - * cdef inline tuple __provide_positional_args(tuple args, # <<<<<<<<<<<<<< - * tuple inj_args, - * int inj_args_len): + * cdef inline tuple __provide_positional_args( # <<<<<<<<<<<<<< + * tuple args, + * tuple inj_args, */ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provide_positional_args(PyObject *__pyx_v_args, PyObject *__pyx_v_inj_args, int __pyx_v_inj_args_len) { @@ -9529,7 +10027,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__provide_positional_args", 0); - /* "providers.pxd":262 + /* "providers.pxd":289 * cdef PositionalInjection injection * * if inj_args_len == 0: # <<<<<<<<<<<<<< @@ -9539,7 +10037,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid __pyx_t_1 = ((__pyx_v_inj_args_len == 0) != 0); if (__pyx_t_1) { - /* "providers.pxd":263 + /* "providers.pxd":290 * * if inj_args_len == 0: * return args # <<<<<<<<<<<<<< @@ -9551,7 +10049,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid __pyx_r = __pyx_v_args; goto __pyx_L0; - /* "providers.pxd":262 + /* "providers.pxd":289 * cdef PositionalInjection injection * * if inj_args_len == 0: # <<<<<<<<<<<<<< @@ -9560,19 +10058,19 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid */ } - /* "providers.pxd":265 + /* "providers.pxd":292 * return args * * positional_args = list() # <<<<<<<<<<<<<< * for index in range(inj_args_len): * injection = inj_args[index] */ - __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 265, __pyx_L1_error) + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_positional_args = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "providers.pxd":266 + /* "providers.pxd":293 * * positional_args = list() * for index in range(inj_args_len): # <<<<<<<<<<<<<< @@ -9584,7 +10082,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_index = __pyx_t_5; - /* "providers.pxd":267 + /* "providers.pxd":294 * positional_args = list() * for index in range(inj_args_len): * injection = inj_args[index] # <<<<<<<<<<<<<< @@ -9593,36 +10091,36 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid */ if (unlikely(__pyx_v_inj_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(1, 267, __pyx_L1_error) + __PYX_ERR(1, 294, __pyx_L1_error) } __pyx_t_2 = PyTuple_GET_ITEM(__pyx_v_inj_args, __pyx_v_index); __Pyx_INCREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_injection, ((struct __pyx_obj_19dependency_injector_9providers_PositionalInjection *)__pyx_t_2)); __pyx_t_2 = 0; - /* "providers.pxd":268 + /* "providers.pxd":295 * for index in range(inj_args_len): * injection = inj_args[index] * positional_args.append(__get_value(injection)) # <<<<<<<<<<<<<< * positional_args.extend(args) * */ - __pyx_t_2 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_injection)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 268, __pyx_L1_error) + __pyx_t_2 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_injection)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_positional_args, __pyx_t_2); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 268, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_positional_args, __pyx_t_2); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 295, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } - /* "providers.pxd":269 + /* "providers.pxd":296 * injection = inj_args[index] * positional_args.append(__get_value(injection)) * positional_args.extend(args) # <<<<<<<<<<<<<< * * return tuple(positional_args) */ - __pyx_t_6 = __Pyx_PyList_Extend(__pyx_v_positional_args, __pyx_v_args); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 269, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyList_Extend(__pyx_v_positional_args, __pyx_v_args); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 296, __pyx_L1_error) - /* "providers.pxd":271 + /* "providers.pxd":298 * positional_args.extend(args) * * return tuple(positional_args) # <<<<<<<<<<<<<< @@ -9630,18 +10128,18 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyList_AsTuple(__pyx_v_positional_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 271, __pyx_L1_error) + __pyx_t_2 = PyList_AsTuple(__pyx_v_positional_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0; - /* "providers.pxd":255 + /* "providers.pxd":280 * @cython.boundscheck(False) * @cython.wraparound(False) - * cdef inline tuple __provide_positional_args(tuple args, # <<<<<<<<<<<<<< - * tuple inj_args, - * int inj_args_len): + * cdef inline tuple __provide_positional_args( # <<<<<<<<<<<<<< + * tuple args, + * tuple inj_args, */ /* function exit code */ @@ -9657,17 +10155,19 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid return __pyx_r; } -/* "providers.pxd":276 +/* "providers.pxd":303 * @cython.boundscheck(False) * @cython.wraparound(False) - * cdef inline dict __provide_keyword_args(dict kwargs, # <<<<<<<<<<<<<< - * tuple inj_kwargs, - * int inj_kwargs_len): + * cdef inline dict __provide_keyword_args( # <<<<<<<<<<<<<< + * dict kwargs, + * tuple inj_kwargs, */ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provide_keyword_args(PyObject *__pyx_v_kwargs, PyObject *__pyx_v_inj_kwargs, int __pyx_v_inj_kwargs_len) { int __pyx_v_index; PyObject *__pyx_v_name = 0; + PyObject *__pyx_v_value = 0; + PyObject *__pyx_v_prefixed = 0; struct __pyx_obj_19dependency_injector_9providers_NamedInjection *__pyx_v_kw_injection = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -9677,13 +10177,16 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + int __pyx_t_9; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__provide_keyword_args", 0); + __Pyx_INCREF(__pyx_v_kwargs); - /* "providers.pxd":283 + /* "providers.pxd":314 * cdef NamedInjection kw_injection * * if len(kwargs) == 0: # <<<<<<<<<<<<<< @@ -9692,13 +10195,13 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid */ if (unlikely(__pyx_v_kwargs == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(1, 283, __pyx_L1_error) + __PYX_ERR(1, 314, __pyx_L1_error) } - __pyx_t_1 = PyDict_Size(__pyx_v_kwargs); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 283, __pyx_L1_error) + __pyx_t_1 = PyDict_Size(__pyx_v_kwargs); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 314, __pyx_L1_error) __pyx_t_2 = ((__pyx_t_1 == 0) != 0); if (__pyx_t_2) { - /* "providers.pxd":284 + /* "providers.pxd":315 * * if len(kwargs) == 0: * for index in range(inj_kwargs_len): # <<<<<<<<<<<<<< @@ -9710,7 +10213,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_index = __pyx_t_5; - /* "providers.pxd":285 + /* "providers.pxd":316 * if len(kwargs) == 0: * for index in range(inj_kwargs_len): * kw_injection = inj_kwargs[index] # <<<<<<<<<<<<<< @@ -9719,43 +10222,43 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid */ if (unlikely(__pyx_v_inj_kwargs == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(1, 285, __pyx_L1_error) + __PYX_ERR(1, 316, __pyx_L1_error) } __pyx_t_6 = PyTuple_GET_ITEM(__pyx_v_inj_kwargs, __pyx_v_index); __Pyx_INCREF(__pyx_t_6); __Pyx_XDECREF_SET(__pyx_v_kw_injection, ((struct __pyx_obj_19dependency_injector_9providers_NamedInjection *)__pyx_t_6)); __pyx_t_6 = 0; - /* "providers.pxd":286 + /* "providers.pxd":317 * for index in range(inj_kwargs_len): * kw_injection = inj_kwargs[index] * name = __get_name(kw_injection) # <<<<<<<<<<<<<< * kwargs[name] = __get_value(kw_injection) * else: */ - __pyx_t_6 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_kw_injection); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 286, __pyx_L1_error) + __pyx_t_6 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_kw_injection); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 317, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_6); __pyx_t_6 = 0; - /* "providers.pxd":287 + /* "providers.pxd":318 * kw_injection = inj_kwargs[index] * name = __get_name(kw_injection) * kwargs[name] = __get_value(kw_injection) # <<<<<<<<<<<<<< * else: - * for index in range(inj_kwargs_len): + * kwargs, prefixed = __separate_prefixed_kwargs(kwargs) */ - __pyx_t_6 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_kw_injection)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 287, __pyx_L1_error) + __pyx_t_6 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_kw_injection)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (unlikely(__pyx_v_kwargs == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(1, 287, __pyx_L1_error) + __PYX_ERR(1, 318, __pyx_L1_error) } - if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_v_name, __pyx_t_6) < 0)) __PYX_ERR(1, 287, __pyx_L1_error) + if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_v_name, __pyx_t_6) < 0)) __PYX_ERR(1, 318, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } - /* "providers.pxd":283 + /* "providers.pxd":314 * cdef NamedInjection kw_injection * * if len(kwargs) == 0: # <<<<<<<<<<<<<< @@ -9765,92 +10268,198 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid goto __pyx_L3; } - /* "providers.pxd":289 + /* "providers.pxd":320 * kwargs[name] = __get_value(kw_injection) * else: + * kwargs, prefixed = __separate_prefixed_kwargs(kwargs) # <<<<<<<<<<<<<< + * + * + */ + /*else*/ { + __pyx_t_6 = __pyx_f_19dependency_injector_9providers___separate_prefixed_kwargs(__pyx_v_kwargs); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 320, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (likely(__pyx_t_6 != Py_None)) { + PyObject* sequence = __pyx_t_6; + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(1, 320, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(__pyx_t_8); + #else + __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 320, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 320, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + #endif + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else { + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 320, __pyx_L1_error) + } + if (!(likely(PyDict_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_7)->tp_name), 0))) __PYX_ERR(1, 320, __pyx_L1_error) + if (!(likely(PyDict_CheckExact(__pyx_t_8))||((__pyx_t_8) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_8)->tp_name), 0))) __PYX_ERR(1, 320, __pyx_L1_error) + __Pyx_DECREF_SET(__pyx_v_kwargs, ((PyObject*)__pyx_t_7)); + __pyx_t_7 = 0; + __pyx_v_prefixed = ((PyObject*)__pyx_t_8); + __pyx_t_8 = 0; + + /* "providers.pxd":323 + * + * * for index in range(inj_kwargs_len): # <<<<<<<<<<<<<< * kw_injection = inj_kwargs[index] * name = __get_name(kw_injection) */ - /*else*/ { __pyx_t_3 = __pyx_v_inj_kwargs_len; __pyx_t_4 = __pyx_t_3; for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_index = __pyx_t_5; - /* "providers.pxd":290 - * else: + /* "providers.pxd":324 + * * for index in range(inj_kwargs_len): * kw_injection = inj_kwargs[index] # <<<<<<<<<<<<<< * name = __get_name(kw_injection) - * if name not in kwargs: + * */ if (unlikely(__pyx_v_inj_kwargs == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(1, 290, __pyx_L1_error) + __PYX_ERR(1, 324, __pyx_L1_error) } __pyx_t_6 = PyTuple_GET_ITEM(__pyx_v_inj_kwargs, __pyx_v_index); __Pyx_INCREF(__pyx_t_6); __Pyx_XDECREF_SET(__pyx_v_kw_injection, ((struct __pyx_obj_19dependency_injector_9providers_NamedInjection *)__pyx_t_6)); __pyx_t_6 = 0; - /* "providers.pxd":291 + /* "providers.pxd":325 * for index in range(inj_kwargs_len): * kw_injection = inj_kwargs[index] * name = __get_name(kw_injection) # <<<<<<<<<<<<<< - * if name not in kwargs: - * kwargs[name] = __get_value(kw_injection) + * + * if name in kwargs: */ - __pyx_t_6 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_kw_injection); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 291, __pyx_L1_error) + __pyx_t_6 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_kw_injection); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_6); __pyx_t_6 = 0; - /* "providers.pxd":292 - * kw_injection = inj_kwargs[index] + /* "providers.pxd":327 * name = __get_name(kw_injection) - * if name not in kwargs: # <<<<<<<<<<<<<< - * kwargs[name] = __get_value(kw_injection) + * + * if name in kwargs: # <<<<<<<<<<<<<< + * continue * */ if (unlikely(__pyx_v_kwargs == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - __PYX_ERR(1, 292, __pyx_L1_error) + __PYX_ERR(1, 327, __pyx_L1_error) } - __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_v_name, __pyx_v_kwargs, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 292, __pyx_L1_error) - __pyx_t_7 = (__pyx_t_2 != 0); - if (__pyx_t_7) { + __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_v_name, __pyx_v_kwargs, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 327, __pyx_L1_error) + __pyx_t_9 = (__pyx_t_2 != 0); + if (__pyx_t_9) { - /* "providers.pxd":293 + /* "providers.pxd":328 + * + * if name in kwargs: + * continue # <<<<<<<<<<<<<< + * + * if name in prefixed: + */ + goto __pyx_L6_continue; + + /* "providers.pxd":327 * name = __get_name(kw_injection) - * if name not in kwargs: - * kwargs[name] = __get_value(kw_injection) # <<<<<<<<<<<<<< + * + * if name in kwargs: # <<<<<<<<<<<<<< + * continue + * + */ + } + + /* "providers.pxd":330 + * continue + * + * if name in prefixed: # <<<<<<<<<<<<<< + * value = __get_value_kwargs(kw_injection, prefixed[name]) + * else: + */ + if (unlikely(__pyx_v_prefixed == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + __PYX_ERR(1, 330, __pyx_L1_error) + } + __pyx_t_9 = (__Pyx_PyDict_ContainsTF(__pyx_v_name, __pyx_v_prefixed, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(1, 330, __pyx_L1_error) + __pyx_t_2 = (__pyx_t_9 != 0); + if (__pyx_t_2) { + + /* "providers.pxd":331 + * + * if name in prefixed: + * value = __get_value_kwargs(kw_injection, prefixed[name]) # <<<<<<<<<<<<<< + * else: + * value = __get_value(kw_injection) + */ + if (unlikely(__pyx_v_prefixed == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + __PYX_ERR(1, 331, __pyx_L1_error) + } + __pyx_t_6 = __Pyx_PyDict_GetItem(__pyx_v_prefixed, __pyx_v_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 331, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (!(likely(PyDict_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_6)->tp_name), 0))) __PYX_ERR(1, 331, __pyx_L1_error) + __pyx_t_8 = __pyx_f_19dependency_injector_9providers___get_value_kwargs(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_kw_injection), ((PyObject*)__pyx_t_6)); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 331, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_8); + __pyx_t_8 = 0; + + /* "providers.pxd":330 + * continue + * + * if name in prefixed: # <<<<<<<<<<<<<< + * value = __get_value_kwargs(kw_injection, prefixed[name]) + * else: + */ + goto __pyx_L9; + } + + /* "providers.pxd":333 + * value = __get_value_kwargs(kw_injection, prefixed[name]) + * else: + * value = __get_value(kw_injection) # <<<<<<<<<<<<<< + * + * kwargs[name] = value + */ + /*else*/ { + __pyx_t_8 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_kw_injection)); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 333, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_8); + __pyx_t_8 = 0; + } + __pyx_L9:; + + /* "providers.pxd":335 + * value = __get_value(kw_injection) + * + * kwargs[name] = value # <<<<<<<<<<<<<< * * return kwargs */ - __pyx_t_6 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_kw_injection)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 293, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (unlikely(__pyx_v_kwargs == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(1, 293, __pyx_L1_error) - } - if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_v_name, __pyx_t_6) < 0)) __PYX_ERR(1, 293, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "providers.pxd":292 - * kw_injection = inj_kwargs[index] - * name = __get_name(kw_injection) - * if name not in kwargs: # <<<<<<<<<<<<<< - * kwargs[name] = __get_value(kw_injection) - * - */ + if (unlikely(__pyx_v_kwargs == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + __PYX_ERR(1, 335, __pyx_L1_error) } + if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_v_name, __pyx_v_value) < 0)) __PYX_ERR(1, 335, __pyx_L1_error) + __pyx_L6_continue:; } } __pyx_L3:; - /* "providers.pxd":295 - * kwargs[name] = __get_value(kw_injection) + /* "providers.pxd":337 + * kwargs[name] = value * * return kwargs # <<<<<<<<<<<<<< * @@ -9861,33 +10470,38 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid __pyx_r = __pyx_v_kwargs; goto __pyx_L0; - /* "providers.pxd":276 + /* "providers.pxd":303 * @cython.boundscheck(False) * @cython.wraparound(False) - * cdef inline dict __provide_keyword_args(dict kwargs, # <<<<<<<<<<<<<< - * tuple inj_kwargs, - * int inj_kwargs_len): + * cdef inline dict __provide_keyword_args( # <<<<<<<<<<<<<< + * dict kwargs, + * tuple inj_kwargs, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("dependency_injector.providers.__provide_keyword_args", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_name); + __Pyx_XDECREF(__pyx_v_value); + __Pyx_XDECREF(__pyx_v_prefixed); __Pyx_XDECREF((PyObject *)__pyx_v_kw_injection); + __Pyx_XDECREF(__pyx_v_kwargs); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "providers.pxd":300 +/* "providers.pxd":342 * @cython.boundscheck(False) * @cython.wraparound(False) - * cdef inline object __inject_attributes(object instance, # <<<<<<<<<<<<<< - * tuple attributes, - * int attributes_len): + * cdef inline object __inject_attributes( # <<<<<<<<<<<<<< + * object instance, + * tuple attributes, */ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___inject_attributes(PyObject *__pyx_v_instance, PyObject *__pyx_v_attributes, int __pyx_v_attributes_len) { @@ -9906,8 +10520,8 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___inject int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__inject_attributes", 0); - /* "providers.pxd":304 - * int attributes_len): + /* "providers.pxd":348 + * ): * cdef NamedInjection attr_injection * for index in range(attributes_len): # <<<<<<<<<<<<<< * attr_injection = attributes[index] @@ -9918,7 +10532,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___inject for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_index = __pyx_t_3; - /* "providers.pxd":305 + /* "providers.pxd":349 * cdef NamedInjection attr_injection * for index in range(attributes_len): * attr_injection = attributes[index] # <<<<<<<<<<<<<< @@ -9927,51 +10541,51 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___inject */ if (unlikely(__pyx_v_attributes == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(1, 305, __pyx_L1_error) + __PYX_ERR(1, 349, __pyx_L1_error) } __pyx_t_4 = PyTuple_GET_ITEM(__pyx_v_attributes, __pyx_v_index); __Pyx_INCREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_attr_injection, ((struct __pyx_obj_19dependency_injector_9providers_NamedInjection *)__pyx_t_4)); __pyx_t_4 = 0; - /* "providers.pxd":307 + /* "providers.pxd":351 * attr_injection = attributes[index] * setattr(instance, * __get_name(attr_injection), # <<<<<<<<<<<<<< * __get_value(attr_injection)) * */ - __pyx_t_4 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_attr_injection); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 307, __pyx_L1_error) + __pyx_t_4 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_attr_injection); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 351, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - /* "providers.pxd":308 + /* "providers.pxd":352 * setattr(instance, * __get_name(attr_injection), * __get_value(attr_injection)) # <<<<<<<<<<<<<< * * */ - __pyx_t_5 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_attr_injection)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 308, __pyx_L1_error) + __pyx_t_5 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_attr_injection)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - /* "providers.pxd":306 + /* "providers.pxd":350 * for index in range(attributes_len): * attr_injection = attributes[index] * setattr(instance, # <<<<<<<<<<<<<< * __get_name(attr_injection), * __get_value(attr_injection)) */ - __pyx_t_6 = PyObject_SetAttr(__pyx_v_instance, __pyx_t_4, __pyx_t_5); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 306, __pyx_L1_error) + __pyx_t_6 = PyObject_SetAttr(__pyx_v_instance, __pyx_t_4, __pyx_t_5); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 350, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } - /* "providers.pxd":300 + /* "providers.pxd":342 * @cython.boundscheck(False) * @cython.wraparound(False) - * cdef inline object __inject_attributes(object instance, # <<<<<<<<<<<<<< - * tuple attributes, - * int attributes_len): + * cdef inline object __inject_attributes( # <<<<<<<<<<<<<< + * object instance, + * tuple attributes, */ /* function exit code */ @@ -9989,7 +10603,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___inject return __pyx_r; } -/* "providers.pxd":311 +/* "providers.pxd":355 * * * cdef inline object __callable_call(Callable self, tuple args, dict kwargs): # <<<<<<<<<<<<<< @@ -10009,7 +10623,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___callab int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__callable_call", 0); - /* "providers.pxd":316 + /* "providers.pxd":360 * * positional_args = __provide_positional_args(args, * self.__args, # <<<<<<<<<<<<<< @@ -10019,20 +10633,20 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___callab __pyx_t_1 = __pyx_v_self->__pyx___args; __Pyx_INCREF(__pyx_t_1); - /* "providers.pxd":315 + /* "providers.pxd":359 * cdef dict keyword_args * * positional_args = __provide_positional_args(args, # <<<<<<<<<<<<<< * self.__args, * self.__args_len) */ - __pyx_t_2 = __pyx_f_19dependency_injector_9providers___provide_positional_args(__pyx_v_args, ((PyObject*)__pyx_t_1), __pyx_v_self->__pyx___args_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 315, __pyx_L1_error) + __pyx_t_2 = __pyx_f_19dependency_injector_9providers___provide_positional_args(__pyx_v_args, ((PyObject*)__pyx_t_1), __pyx_v_self->__pyx___args_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 359, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_positional_args = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "providers.pxd":319 + /* "providers.pxd":363 * self.__args_len) * keyword_args = __provide_keyword_args(kwargs, * self.__kwargs, # <<<<<<<<<<<<<< @@ -10042,20 +10656,20 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___callab __pyx_t_2 = __pyx_v_self->__pyx___kwargs; __Pyx_INCREF(__pyx_t_2); - /* "providers.pxd":318 + /* "providers.pxd":362 * self.__args, * self.__args_len) * keyword_args = __provide_keyword_args(kwargs, # <<<<<<<<<<<<<< * self.__kwargs, * self.__kwargs_len) */ - __pyx_t_1 = __pyx_f_19dependency_injector_9providers___provide_keyword_args(__pyx_v_kwargs, ((PyObject*)__pyx_t_2), __pyx_v_self->__pyx___kwargs_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 318, __pyx_L1_error) + __pyx_t_1 = __pyx_f_19dependency_injector_9providers___provide_keyword_args(__pyx_v_kwargs, ((PyObject*)__pyx_t_2), __pyx_v_self->__pyx___kwargs_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 362, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_keyword_args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "providers.pxd":322 + /* "providers.pxd":366 * self.__kwargs_len) * * return self.__provides(*positional_args, **keyword_args) # <<<<<<<<<<<<<< @@ -10065,19 +10679,19 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___callab __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_positional_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - __PYX_ERR(1, 322, __pyx_L1_error) + __PYX_ERR(1, 366, __pyx_L1_error) } if (unlikely(__pyx_v_keyword_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); - __PYX_ERR(1, 322, __pyx_L1_error) + __PYX_ERR(1, 366, __pyx_L1_error) } - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_self->__pyx___provides, __pyx_v_positional_args, __pyx_v_keyword_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 322, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_self->__pyx___provides, __pyx_v_positional_args, __pyx_v_keyword_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 366, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "providers.pxd":311 + /* "providers.pxd":355 * * * cdef inline object __callable_call(Callable self, tuple args, dict kwargs): # <<<<<<<<<<<<<< @@ -10099,7 +10713,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___callab return __pyx_r; } -/* "providers.pxd":325 +/* "providers.pxd":369 * * * cdef inline object __factory_call(Factory self, tuple args, dict kwargs): # <<<<<<<<<<<<<< @@ -10119,7 +10733,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__factory_call", 0); - /* "providers.pxd":328 + /* "providers.pxd":372 * cdef object instance * * instance = __callable_call(self.__instantiator, args, kwargs) # <<<<<<<<<<<<<< @@ -10128,13 +10742,13 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor */ __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx___instantiator); __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = __pyx_f_19dependency_injector_9providers___callable_call(((struct __pyx_obj_19dependency_injector_9providers_Callable *)__pyx_t_1), __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 328, __pyx_L1_error) + __pyx_t_2 = __pyx_f_19dependency_injector_9providers___callable_call(((struct __pyx_obj_19dependency_injector_9providers_Callable *)__pyx_t_1), __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_instance = __pyx_t_2; __pyx_t_2 = 0; - /* "providers.pxd":330 + /* "providers.pxd":374 * instance = __callable_call(self.__instantiator, args, kwargs) * * if self.__attributes_len > 0: # <<<<<<<<<<<<<< @@ -10144,7 +10758,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor __pyx_t_3 = ((__pyx_v_self->__pyx___attributes_len > 0) != 0); if (__pyx_t_3) { - /* "providers.pxd":332 + /* "providers.pxd":376 * if self.__attributes_len > 0: * __inject_attributes(instance, * self.__attributes, # <<<<<<<<<<<<<< @@ -10154,19 +10768,19 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor __pyx_t_2 = __pyx_v_self->__pyx___attributes; __Pyx_INCREF(__pyx_t_2); - /* "providers.pxd":331 + /* "providers.pxd":375 * * if self.__attributes_len > 0: * __inject_attributes(instance, # <<<<<<<<<<<<<< * self.__attributes, * self.__attributes_len) */ - __pyx_t_1 = __pyx_f_19dependency_injector_9providers___inject_attributes(__pyx_v_instance, ((PyObject*)__pyx_t_2), __pyx_v_self->__pyx___attributes_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 331, __pyx_L1_error) + __pyx_t_1 = __pyx_f_19dependency_injector_9providers___inject_attributes(__pyx_v_instance, ((PyObject*)__pyx_t_2), __pyx_v_self->__pyx___attributes_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 375, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "providers.pxd":330 + /* "providers.pxd":374 * instance = __callable_call(self.__instantiator, args, kwargs) * * if self.__attributes_len > 0: # <<<<<<<<<<<<<< @@ -10175,7 +10789,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor */ } - /* "providers.pxd":335 + /* "providers.pxd":379 * self.__attributes_len) * * return instance # <<<<<<<<<<<<<< @@ -10185,7 +10799,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor __pyx_r = __pyx_v_instance; goto __pyx_L0; - /* "providers.pxd":325 + /* "providers.pxd":369 * * * cdef inline object __factory_call(Factory self, tuple args, dict kwargs): # <<<<<<<<<<<<<< @@ -10998,6 +11612,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_Dynamic_inversion_of_control_con, __pyx_k_Dynamic_inversion_of_control_con, sizeof(__pyx_k_Dynamic_inversion_of_control_con), 0, 0, 1, 0}, {&__pyx_n_s_Error, __pyx_k_Error, sizeof(__pyx_k_Error), 0, 0, 1, 1}, {&__pyx_n_s_IS_CONTAINER, __pyx_k_IS_CONTAINER, sizeof(__pyx_k_IS_CONTAINER), 0, 0, 1, 1}, + {&__pyx_n_s__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 0, 1, 1}, {&__pyx_n_s_add_metaclass, __pyx_k_add_metaclass, sizeof(__pyx_k_add_metaclass), 0, 0, 1, 1}, {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1}, {&__pyx_n_s_attributes, __pyx_k_attributes, sizeof(__pyx_k_attributes), 0, 0, 1, 1}, @@ -11026,6 +11641,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1}, {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1}, {&__pyx_n_s_inherited_providers, __pyx_k_inherited_providers, sizeof(__pyx_k_inherited_providers), 0, 0, 1, 1}, {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1}, {&__pyx_n_s_instance_type, __pyx_k_instance_type, sizeof(__pyx_k_instance_type), 0, 0, 1, 1}, @@ -11077,7 +11693,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 55, __pyx_L1_error) __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(0, 59, __pyx_L1_error) __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 138, __pyx_L1_error) - __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(1, 266, __pyx_L1_error) + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(1, 293, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; @@ -11129,9 +11745,9 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Dynamic inversion of control container. * */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 16, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__6); - __Pyx_GIVEREF(__pyx_tuple__6); + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 16, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); /* "dependency_injector/containers.pyx":47 * __IS_CONTAINER__ = True @@ -11140,10 +11756,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Initializer. * */ - __pyx_tuple__7 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__7); - __Pyx_GIVEREF(__pyx_tuple__7); - __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_init, 47, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 47, __pyx_L1_error) + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 47, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); + __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_init, 47, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 47, __pyx_L1_error) /* "dependency_injector/containers.pyx":57 * super(DynamicContainer, self).__init__() @@ -11152,10 +11768,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Create and return full copy of container.""" * copied = memo.get(id(self)) */ - __pyx_tuple__9 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_memo, __pyx_n_s_copied, __pyx_n_s_name, __pyx_n_s_provider); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 57, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__9); - __Pyx_GIVEREF(__pyx_tuple__9); - __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_deepcopy, 57, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 57, __pyx_L1_error) + __pyx_tuple__10 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_memo, __pyx_n_s_copied, __pyx_n_s_name, __pyx_n_s_provider); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 57, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__10); + __Pyx_GIVEREF(__pyx_tuple__10); + __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_deepcopy, 57, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 57, __pyx_L1_error) /* "dependency_injector/containers.pyx":72 * return copied @@ -11164,10 +11780,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Set instance attribute. * */ - __pyx_tuple__11 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_name, __pyx_n_s_value); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__11); - __Pyx_GIVEREF(__pyx_tuple__11); - __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_setattr, 72, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 72, __pyx_L1_error) + __pyx_tuple__12 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_name, __pyx_n_s_value); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 72, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__12); + __Pyx_GIVEREF(__pyx_tuple__12); + __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__12, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_setattr, 72, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 72, __pyx_L1_error) /* "dependency_injector/containers.pyx":91 * super(DynamicContainer, self).__setattr__(name, value) @@ -11176,10 +11792,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Delete instance attribute. * */ - __pyx_tuple__13 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_name); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 91, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__13); - __Pyx_GIVEREF(__pyx_tuple__13); - __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_delattr, 91, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 91, __pyx_L1_error) + __pyx_tuple__14 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_name); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 91, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__14); + __Pyx_GIVEREF(__pyx_tuple__14); + __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_delattr, 91, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 91, __pyx_L1_error) /* "dependency_injector/containers.pyx":106 * super(DynamicContainer, self).__delattr__(name) @@ -11188,10 +11804,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Set container providers. * */ - __pyx_tuple__15 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_providers, __pyx_n_s_name, __pyx_n_s_provider); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 106, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__15); - __Pyx_GIVEREF(__pyx_tuple__15); - __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_set_providers, 106, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_tuple__16 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_providers, __pyx_n_s_name, __pyx_n_s_provider); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 106, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__16); + __Pyx_GIVEREF(__pyx_tuple__16); + __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__16, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_set_providers, 106, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 106, __pyx_L1_error) /* "dependency_injector/containers.pyx":118 * setattr(self, name, provider) @@ -11200,10 +11816,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Override current container by overriding container. * */ - __pyx_tuple__17 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_overriding, __pyx_n_s_name, __pyx_n_s_provider); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 118, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__17); - __Pyx_GIVEREF(__pyx_tuple__17); - __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_override, 118, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 118, __pyx_L1_error) + __pyx_tuple__18 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_overriding, __pyx_n_s_name, __pyx_n_s_provider); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__18); + __Pyx_GIVEREF(__pyx_tuple__18); + __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_override, 118, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 118, __pyx_L1_error) /* "dependency_injector/containers.pyx":141 * pass @@ -11212,10 +11828,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Override container providers. * */ - __pyx_tuple__19 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_overriding_providers, __pyx_n_s_name, __pyx_n_s_overriding_provider, __pyx_n_s_container_provider); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 141, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__19); - __Pyx_GIVEREF(__pyx_tuple__19); - __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_override_providers, 141, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 141, __pyx_L1_error) + __pyx_tuple__20 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_overriding_providers, __pyx_n_s_name, __pyx_n_s_overriding_provider, __pyx_n_s_container_provider); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 141, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__20); + __Pyx_GIVEREF(__pyx_tuple__20); + __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_override_providers, 141, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 141, __pyx_L1_error) /* "dependency_injector/containers.pyx":154 * container_provider.override(overriding_provider) @@ -11224,10 +11840,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Reset last overriding provider for each container providers. * */ - __pyx_tuple__21 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_provider); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 154, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__21); - __Pyx_GIVEREF(__pyx_tuple__21); - __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_reset_last_overriding, 154, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_tuple__22 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_provider); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__22); + __Pyx_GIVEREF(__pyx_tuple__22); + __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_reset_last_overriding, 154, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 154, __pyx_L1_error) /* "dependency_injector/containers.pyx":167 * provider.reset_last_overriding() @@ -11236,10 +11852,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Reset all overridings for each container providers. * */ - __pyx_tuple__23 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_provider); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 167, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__23); - __Pyx_GIVEREF(__pyx_tuple__23); - __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_reset_override, 167, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_tuple__24 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_provider); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 167, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__24); + __Pyx_GIVEREF(__pyx_tuple__24); + __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_reset_override, 167, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 167, __pyx_L1_error) /* "dependency_injector/containers.pyx":181 * """Declarative inversion of control container meta class.""" @@ -11248,10 +11864,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Declarative container class factory.""" * cdef tuple cls_providers */ - __pyx_tuple__25 = PyTuple_Pack(13, __pyx_n_s_mcs, __pyx_n_s_class_name, __pyx_n_s_bases, __pyx_n_s_attributes, __pyx_n_s_cls_providers, __pyx_n_s_inherited_providers, __pyx_n_s_cls, __pyx_n_s_containers, __pyx_n_s_provider, __pyx_n_s_genexpr, __pyx_n_s_genexpr, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 181, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__25); - __Pyx_GIVEREF(__pyx_tuple__25); - __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(4, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_new, 181, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 181, __pyx_L1_error) + __pyx_tuple__26 = PyTuple_Pack(13, __pyx_n_s_mcs, __pyx_n_s_class_name, __pyx_n_s_bases, __pyx_n_s_attributes, __pyx_n_s_cls_providers, __pyx_n_s_inherited_providers, __pyx_n_s_cls, __pyx_n_s_containers, __pyx_n_s_provider, __pyx_n_s_genexpr, __pyx_n_s_genexpr, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 181, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__26); + __Pyx_GIVEREF(__pyx_tuple__26); + __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(4, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_new, 181, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 181, __pyx_L1_error) /* "dependency_injector/containers.pyx":214 * return cls @@ -11260,10 +11876,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Set class attribute. * */ - __pyx_tuple__27 = PyTuple_Pack(3, __pyx_n_s_cls, __pyx_n_s_name, __pyx_n_s_value); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__27); - __Pyx_GIVEREF(__pyx_tuple__27); - __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_setattr, 214, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 214, __pyx_L1_error) + __pyx_tuple__28 = PyTuple_Pack(3, __pyx_n_s_cls, __pyx_n_s_name, __pyx_n_s_value); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 214, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__28); + __Pyx_GIVEREF(__pyx_tuple__28); + __pyx_codeobj__29 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__28, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_setattr, 214, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 214, __pyx_L1_error) /* "dependency_injector/containers.pyx":234 * super(DeclarativeContainerMetaClass, cls).__setattr__(name, value) @@ -11272,10 +11888,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Delete class attribute. * */ - __pyx_tuple__29 = PyTuple_Pack(2, __pyx_n_s_cls, __pyx_n_s_name); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 234, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__29); - __Pyx_GIVEREF(__pyx_tuple__29); - __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_delattr, 234, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 234, __pyx_L1_error) + __pyx_tuple__30 = PyTuple_Pack(2, __pyx_n_s_cls, __pyx_n_s_name); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 234, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__30); + __Pyx_GIVEREF(__pyx_tuple__30); + __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_delattr, 234, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 234, __pyx_L1_error) /* "dependency_injector/containers.pyx":252 * @@ -11284,9 +11900,9 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Declarative inversion of control container. * */ - __pyx_tuple__31 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 252, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__31); - __Pyx_GIVEREF(__pyx_tuple__31); + __pyx_tuple__32 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 252, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__32); + __Pyx_GIVEREF(__pyx_tuple__32); /* "dependency_injector/containers.pyx":308 * """ @@ -11295,10 +11911,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Constructor. * */ - __pyx_tuple__32 = PyTuple_Pack(3, __pyx_n_s_cls, __pyx_n_s_overriding_providers, __pyx_n_s_container); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 308, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__32); - __Pyx_GIVEREF(__pyx_tuple__32); - __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_new, 308, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 308, __pyx_L1_error) + __pyx_tuple__33 = PyTuple_Pack(3, __pyx_n_s_cls, __pyx_n_s_overriding_providers, __pyx_n_s_container); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 308, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__33); + __Pyx_GIVEREF(__pyx_tuple__33); + __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_new, 308, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 308, __pyx_L1_error) /* "dependency_injector/containers.pyx":321 * @@ -11307,10 +11923,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Override current container by overriding container. * */ - __pyx_tuple__34 = PyTuple_Pack(4, __pyx_n_s_cls, __pyx_n_s_overriding, __pyx_n_s_name, __pyx_n_s_provider); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 321, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__34); - __Pyx_GIVEREF(__pyx_tuple__34); - __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_override, 321, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 321, __pyx_L1_error) + __pyx_tuple__35 = PyTuple_Pack(4, __pyx_n_s_cls, __pyx_n_s_overriding, __pyx_n_s_name, __pyx_n_s_provider); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 321, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__35); + __Pyx_GIVEREF(__pyx_tuple__35); + __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_override, 321, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 321, __pyx_L1_error) /* "dependency_injector/containers.pyx":345 * @@ -11319,10 +11935,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Reset last overriding provider for each container providers. * */ - __pyx_tuple__36 = PyTuple_Pack(2, __pyx_n_s_cls, __pyx_n_s_provider); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 345, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__36); - __Pyx_GIVEREF(__pyx_tuple__36); - __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_reset_last_overriding, 345, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(0, 345, __pyx_L1_error) + __pyx_tuple__37 = PyTuple_Pack(2, __pyx_n_s_cls, __pyx_n_s_provider); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 345, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__37); + __Pyx_GIVEREF(__pyx_tuple__37); + __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_reset_last_overriding, 345, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 345, __pyx_L1_error) /* "dependency_injector/containers.pyx":359 * @@ -11331,10 +11947,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """Reset all overridings for each container providers. * */ - __pyx_tuple__38 = PyTuple_Pack(2, __pyx_n_s_cls, __pyx_n_s_provider); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 359, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__38); - __Pyx_GIVEREF(__pyx_tuple__38); - __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_reset_override, 359, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 359, __pyx_L1_error) + __pyx_tuple__39 = PyTuple_Pack(2, __pyx_n_s_cls, __pyx_n_s_provider); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 359, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__39); + __Pyx_GIVEREF(__pyx_tuple__39); + __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_reset_override, 359, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 359, __pyx_L1_error) /* "dependency_injector/containers.pyx":370 * @@ -11343,10 +11959,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """:py:class:`DeclarativeContainer` overriding decorator. * */ - __pyx_tuple__40 = PyTuple_Pack(3, __pyx_n_s_container, __pyx_n_s_decorator, __pyx_n_s_decorator); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 370, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__40); - __Pyx_GIVEREF(__pyx_tuple__40); - __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_override, 370, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(0, 370, __pyx_L1_error) + __pyx_tuple__41 = PyTuple_Pack(3, __pyx_n_s_container, __pyx_n_s_decorator, __pyx_n_s_decorator); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 370, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__41); + __Pyx_GIVEREF(__pyx_tuple__41); + __pyx_codeobj__42 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__41, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_override, 370, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__42)) __PYX_ERR(0, 370, __pyx_L1_error) /* "dependency_injector/containers.pyx":387 * @@ -11355,10 +11971,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { * """:py:class:`DeclarativeContainer` copying decorator. * */ - __pyx_tuple__42 = PyTuple_Pack(3, __pyx_n_s_container, __pyx_n_s_decorator, __pyx_n_s_decorator); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 387, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__42); - __Pyx_GIVEREF(__pyx_tuple__42); - __pyx_codeobj__43 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_copy, 387, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__43)) __PYX_ERR(0, 387, __pyx_L1_error) + __pyx_tuple__43 = PyTuple_Pack(3, __pyx_n_s_container, __pyx_n_s_decorator, __pyx_n_s_decorator); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 387, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__43); + __Pyx_GIVEREF(__pyx_tuple__43); + __pyx_codeobj__44 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__43, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_dependency_injector_containe, __pyx_n_s_copy, 387, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__44)) __PYX_ERR(0, 387, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -11367,7 +11983,9 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { } static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { + __pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type; if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error) return 0; __pyx_L1_error:; @@ -11888,9 +12506,9 @@ if (!__Pyx_RefNanny) { * """Dynamic inversion of control container. * */ - __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) + __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_tuple__6, __pyx_n_s_DynamicContainer, __pyx_n_s_DynamicContainer, (PyObject *) NULL, __pyx_n_s_dependency_injector_containers, __pyx_kp_s_Dynamic_inversion_of_control_con); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) + __pyx_t_1 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_tuple__7, __pyx_n_s_DynamicContainer, __pyx_n_s_DynamicContainer, (PyObject *) NULL, __pyx_n_s_dependency_injector_containers, __pyx_kp_s_Dynamic_inversion_of_control_con); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); /* "dependency_injector/containers.pyx":45 @@ -11909,7 +12527,7 @@ if (!__Pyx_RefNanny) { * """Initializer. * */ - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_1__init__, 0, __pyx_n_s_DynamicContainer___init, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 47, __pyx_L1_error) + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_1__init__, 0, __pyx_n_s_DynamicContainer___init, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__9)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_init, __pyx_t_3) < 0) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -11921,7 +12539,7 @@ if (!__Pyx_RefNanny) { * """Create and return full copy of container.""" * copied = memo.get(id(self)) */ - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_3__deepcopy__, 0, __pyx_n_s_DynamicContainer___deepcopy, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 57, __pyx_L1_error) + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_3__deepcopy__, 0, __pyx_n_s_DynamicContainer___deepcopy, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_deepcopy, __pyx_t_3) < 0) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -11933,7 +12551,7 @@ if (!__Pyx_RefNanny) { * """Set instance attribute. * */ - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_5__setattr__, 0, __pyx_n_s_DynamicContainer___setattr, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error) + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_5__setattr__, 0, __pyx_n_s_DynamicContainer___setattr, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__13)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_setattr, __pyx_t_3) < 0) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -11945,7 +12563,7 @@ if (!__Pyx_RefNanny) { * """Delete instance attribute. * */ - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_7__delattr__, 0, __pyx_n_s_DynamicContainer___delattr, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 91, __pyx_L1_error) + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_7__delattr__, 0, __pyx_n_s_DynamicContainer___delattr, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__15)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_delattr, __pyx_t_3) < 0) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -11957,7 +12575,7 @@ if (!__Pyx_RefNanny) { * """Set container providers. * */ - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_9set_providers, 0, __pyx_n_s_DynamicContainer_set_providers, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 106, __pyx_L1_error) + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_9set_providers, 0, __pyx_n_s_DynamicContainer_set_providers, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__17)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_set_providers, __pyx_t_3) < 0) __PYX_ERR(0, 106, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -11969,7 +12587,7 @@ if (!__Pyx_RefNanny) { * """Override current container by overriding container. * */ - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_11override, 0, __pyx_n_s_DynamicContainer_override, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 118, __pyx_L1_error) + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_11override, 0, __pyx_n_s_DynamicContainer_override, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__19)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_override, __pyx_t_3) < 0) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -11981,7 +12599,7 @@ if (!__Pyx_RefNanny) { * """Override container providers. * */ - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_13override_providers, 0, __pyx_n_s_DynamicContainer_override_provid, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__20)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 141, __pyx_L1_error) + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_13override_providers, 0, __pyx_n_s_DynamicContainer_override_provid, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__21)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 141, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_override_providers, __pyx_t_3) < 0) __PYX_ERR(0, 141, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -11993,7 +12611,7 @@ if (!__Pyx_RefNanny) { * """Reset last overriding provider for each container providers. * */ - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_15reset_last_overriding, 0, __pyx_n_s_DynamicContainer_reset_last_over, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_15reset_last_overriding, 0, __pyx_n_s_DynamicContainer_reset_last_over, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__23)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 154, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_reset_last_overriding, __pyx_t_3) < 0) __PYX_ERR(0, 154, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -12005,7 +12623,7 @@ if (!__Pyx_RefNanny) { * """Reset all overridings for each container providers. * */ - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_17reset_override, 0, __pyx_n_s_DynamicContainer_reset_override, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_16DynamicContainer_17reset_override, 0, __pyx_n_s_DynamicContainer_reset_override, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_reset_override, __pyx_t_3) < 0) __PYX_ERR(0, 167, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -12017,7 +12635,7 @@ if (!__Pyx_RefNanny) { * """Dynamic inversion of control container. * */ - __pyx_t_3 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_DynamicContainer, __pyx_tuple__6, __pyx_t_1, NULL, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 16, __pyx_L1_error) + __pyx_t_3 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_DynamicContainer, __pyx_tuple__7, __pyx_t_1, NULL, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_DynamicContainer, __pyx_t_3) < 0) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -12048,7 +12666,7 @@ if (!__Pyx_RefNanny) { * """Declarative container class factory.""" * cdef tuple cls_providers */ - __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_29DeclarativeContainerMetaClass_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_DeclarativeContainerMetaClass_3, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__26)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error) + __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_29DeclarativeContainerMetaClass_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_DeclarativeContainerMetaClass_3, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_new, __pyx_t_4) < 0) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -12060,7 +12678,7 @@ if (!__Pyx_RefNanny) { * """Set class attribute. * */ - __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_29DeclarativeContainerMetaClass_3__setattr__, 0, __pyx_n_s_DeclarativeContainerMetaClass_4, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__28)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 214, __pyx_L1_error) + __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_29DeclarativeContainerMetaClass_3__setattr__, 0, __pyx_n_s_DeclarativeContainerMetaClass_4, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__29)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 214, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_setattr, __pyx_t_4) < 0) __PYX_ERR(0, 214, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -12072,7 +12690,7 @@ if (!__Pyx_RefNanny) { * """Delete class attribute. * */ - __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_29DeclarativeContainerMetaClass_5__delattr__, 0, __pyx_n_s_DeclarativeContainerMetaClass_5, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__30)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 234, __pyx_L1_error) + __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_29DeclarativeContainerMetaClass_5__delattr__, 0, __pyx_n_s_DeclarativeContainerMetaClass_5, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__31)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 234, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_delattr, __pyx_t_4) < 0) __PYX_ERR(0, 234, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -12099,9 +12717,9 @@ if (!__Pyx_RefNanny) { * """Declarative inversion of control container. * */ - __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__31); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_tuple__31, __pyx_n_s_DeclarativeContainer, __pyx_n_s_DeclarativeContainer, (PyObject *) NULL, __pyx_n_s_dependency_injector_containers, __pyx_kp_s_Declarative_inversion_of_control_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_t_1 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_tuple__32, __pyx_n_s_DeclarativeContainer, __pyx_n_s_DeclarativeContainer, (PyObject *) NULL, __pyx_n_s_dependency_injector_containers, __pyx_kp_s_Declarative_inversion_of_control_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); /* "dependency_injector/containers.pyx":263 @@ -12201,7 +12819,7 @@ if (!__Pyx_RefNanny) { * """Constructor. * */ - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_20DeclarativeContainer_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_DeclarativeContainer___new, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__33)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 308, __pyx_L1_error) + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_20DeclarativeContainer_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_DeclarativeContainer___new, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__34)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_new, __pyx_t_3) < 0) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -12213,7 +12831,7 @@ if (!__Pyx_RefNanny) { * """Override current container by overriding container. * */ - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_20DeclarativeContainer_3override, __Pyx_CYFUNCTION_CLASSMETHOD, __pyx_n_s_DeclarativeContainer_override, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__35)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 321, __pyx_L1_error) + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_20DeclarativeContainer_3override, __Pyx_CYFUNCTION_CLASSMETHOD, __pyx_n_s_DeclarativeContainer_override, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__36)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 321, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* "dependency_injector/containers.pyx":320 @@ -12236,7 +12854,7 @@ if (!__Pyx_RefNanny) { * """Reset last overriding provider for each container providers. * */ - __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_20DeclarativeContainer_5reset_last_overriding, __Pyx_CYFUNCTION_CLASSMETHOD, __pyx_n_s_DeclarativeContainer_reset_last, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__37)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 345, __pyx_L1_error) + __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_20DeclarativeContainer_5reset_last_overriding, __Pyx_CYFUNCTION_CLASSMETHOD, __pyx_n_s_DeclarativeContainer_reset_last, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); /* "dependency_injector/containers.pyx":344 @@ -12259,7 +12877,7 @@ if (!__Pyx_RefNanny) { * """Reset all overridings for each container providers. * */ - __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_20DeclarativeContainer_7reset_override, __Pyx_CYFUNCTION_CLASSMETHOD, __pyx_n_s_DeclarativeContainer_reset_overr, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__39)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 359, __pyx_L1_error) + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_19dependency_injector_10containers_20DeclarativeContainer_7reset_override, __Pyx_CYFUNCTION_CLASSMETHOD, __pyx_n_s_DeclarativeContainer_reset_overr, NULL, __pyx_n_s_dependency_injector_containers, __pyx_d, ((PyObject *)__pyx_codeobj__40)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 359, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* "dependency_injector/containers.pyx":358 @@ -12313,7 +12931,7 @@ if (!__Pyx_RefNanny) { * """Declarative inversion of control container. * */ - __pyx_t_6 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_DeclarativeContainer, __pyx_tuple__31, __pyx_t_1, NULL, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_t_6 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_DeclarativeContainer, __pyx_tuple__32, __pyx_t_1, NULL, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { @@ -12370,7 +12988,7 @@ if (!__Pyx_RefNanny) { if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "providers.pxd":325 + /* "providers.pxd":369 * * * cdef inline object __factory_call(Factory self, tuple args, dict kwargs): # <<<<<<<<<<<<<< @@ -14115,6 +14733,206 @@ static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, #endif } +/* UnpackUnboundCMethod */ +static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) { + PyObject *method; + method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name); + if (unlikely(!method)) + return -1; + target->method = method; +#if CYTHON_COMPILING_IN_CPYTHON + #if PY_MAJOR_VERSION >= 3 + if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type))) + #endif + { + PyMethodDescrObject *descr = (PyMethodDescrObject*) method; + target->func = descr->d_method->ml_meth; + target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS); + } +#endif + return 0; +} + +/* CallUnboundCMethod0 */ +static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) { + PyObject *args, *result = NULL; + if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; +#if CYTHON_ASSUME_SAFE_MACROS + args = PyTuple_New(1); + if (unlikely(!args)) goto bad; + Py_INCREF(self); + PyTuple_SET_ITEM(args, 0, self); +#else + args = PyTuple_Pack(1, self); + if (unlikely(!args)) goto bad; +#endif + result = __Pyx_PyObject_Call(cfunc->method, args, NULL); + Py_DECREF(args); +bad: + return result; +} + +/* py_dict_items */ +static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) { + if (PY_MAJOR_VERSION >= 3) + return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_items, d); + else + return PyDict_Items(d); +} + +/* PyIntBinop */ +#if !CYTHON_COMPILING_IN_PYPY +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) { + (void)inplace; + (void)zerodivision_check; + #if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(op1))) { + const long b = intval; + long x; + long a = PyInt_AS_LONG(op1); + x = (long)((unsigned long)a + b); + if (likely((x^a) >= 0 || (x^b) >= 0)) + return PyInt_FromLong(x); + return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + #endif + #if CYTHON_USE_PYLONG_INTERNALS + if (likely(PyLong_CheckExact(op1))) { + const long b = intval; + long a, x; +#ifdef HAVE_LONG_LONG + const PY_LONG_LONG llb = intval; + PY_LONG_LONG lla, llx; +#endif + const digit* digits = ((PyLongObject*)op1)->ob_digit; + const Py_ssize_t size = Py_SIZE(op1); + if (likely(__Pyx_sst_abs(size) <= 1)) { + a = likely(size) ? digits[0] : 0; + if (size == -1) a = -a; + } else { + switch (size) { + case -2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case -3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case -4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + default: return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + } + x = a + b; + return PyLong_FromLong(x); +#ifdef HAVE_LONG_LONG + long_long: + llx = lla + llb; + return PyLong_FromLongLong(llx); +#endif + + + } + #endif + if (PyFloat_CheckExact(op1)) { + const long b = intval; + double a = PyFloat_AS_DOUBLE(op1); + double result; + PyFPE_START_PROTECT("add", return NULL) + result = ((double)a) + (double)b; + PyFPE_END_PROTECT(result) + return PyFloat_FromDouble(result); + } + return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); +} +#endif + +/* DictGetItem */ +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { + PyObject *value; + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (!PyErr_Occurred()) { + if (unlikely(PyTuple_Check(key))) { + PyObject* args = PyTuple_Pack(1, key); + if (likely(args)) { + PyErr_SetObject(PyExc_KeyError, args); + Py_DECREF(args); + } + } else { + PyErr_SetObject(PyExc_KeyError, key); + } + } + return NULL; + } + Py_INCREF(value); + return value; +} +#endif + +/* RaiseNoneIterError */ +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + /* PyObject_GenericGetAttrNoDict */ #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { diff --git a/src/dependency_injector/providers.c b/src/dependency_injector/providers.c index 8f6a0a03..031d148b 100644 --- a/src/dependency_injector/providers.c +++ b/src/dependency_injector/providers.c @@ -2432,6 +2432,20 @@ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /* HasAttr.proto */ static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *); +/* SliceObject.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice( + PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, + PyObject** py_start, PyObject** py_stop, PyObject** py_slice, + int has_cstart, int has_cstop, int wraparound); + +/* PyIntBinop.proto */ +#if !CYTHON_COMPILING_IN_PYPY +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); +#else +#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\ + (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) +#endif + /* ListExtend.proto */ static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) { #if CYTHON_COMPILING_IN_CPYTHON @@ -2445,6 +2459,9 @@ static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) { #endif } +/* RaiseNoneIterError.proto */ +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + /* PyObject_GenericGetAttrNoDict.proto */ #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name); @@ -2768,6 +2785,8 @@ static PyObject *__pyx_f_19dependency_injector_9providers_represent_provider(PyO static PyObject *__pyx_f_19dependency_injector_9providers_deepcopy(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_19dependency_injector_9providers_deepcopy *__pyx_optional_args); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_name(struct __pyx_obj_19dependency_injector_9providers_NamedInjection *); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_value(struct __pyx_obj_19dependency_injector_9providers_Injection *); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_value_kwargs(struct __pyx_obj_19dependency_injector_9providers_Injection *, PyObject *); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___separate_prefixed_kwargs(PyObject *); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provide_positional_args(PyObject *, PyObject *, int); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provide_keyword_args(PyObject *, PyObject *, int); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___inject_attributes(PyObject *, PyObject *, int); /*proto*/ @@ -2877,6 +2896,7 @@ static const char __pyx_k_close[] = "close"; static const char __pyx_k_dict1[] = "dict1"; static const char __pyx_k_dict2[] = "dict2"; static const char __pyx_k_enter[] = "__enter__"; +static const char __pyx_k_index[] = "index"; static const char __pyx_k_items[] = "items"; static const char __pyx_k_local[] = "local"; static const char __pyx_k_range[] = "range"; @@ -3331,6 +3351,7 @@ static PyObject *__pyx_n_s_im_class; static PyObject *__pyx_n_s_im_func; static PyObject *__pyx_n_s_im_self; static PyObject *__pyx_n_s_import; +static PyObject *__pyx_n_s_index; static PyObject *__pyx_n_s_iniconfigparser; static PyObject *__pyx_n_s_init; static PyObject *__pyx_n_s_inspect; @@ -3835,6 +3856,7 @@ static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_get = {0, &__pyx_n_s_get, static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items = {0, &__pyx_n_s_items, 0, 0, 0}; static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_values = {0, &__pyx_n_s_values, 0, 0, 0}; static PyObject *__pyx_int_0; +static PyObject *__pyx_int_2; static PyObject *__pyx_int_3; static PyObject *__pyx_int_5; static PyObject *__pyx_int_3297756; @@ -67009,12 +67031,448 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_va return __pyx_r; } -/* "dependency_injector/providers.pxd":255 +/* "dependency_injector/providers.pxd":253 + * + * + * cdef inline object __get_value_kwargs(Injection self, dict kwargs): # <<<<<<<<<<<<<< + * if self.__call == 0: + * return self.__value + */ + +static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_value_kwargs(struct __pyx_obj_19dependency_injector_9providers_Injection *__pyx_v_self, PyObject *__pyx_v_kwargs) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get_value_kwargs", 0); + + /* "dependency_injector/providers.pxd":254 + * + * cdef inline object __get_value_kwargs(Injection self, dict kwargs): + * if self.__call == 0: # <<<<<<<<<<<<<< + * return self.__value + * return self.__value(**kwargs) + */ + __pyx_t_1 = ((__pyx_v_self->__pyx___call == 0) != 0); + if (__pyx_t_1) { + + /* "dependency_injector/providers.pxd":255 + * cdef inline object __get_value_kwargs(Injection self, dict kwargs): + * if self.__call == 0: + * return self.__value # <<<<<<<<<<<<<< + * return self.__value(**kwargs) + * + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->__pyx___value); + __pyx_r = __pyx_v_self->__pyx___value; + goto __pyx_L0; + + /* "dependency_injector/providers.pxd":254 + * + * cdef inline object __get_value_kwargs(Injection self, dict kwargs): + * if self.__call == 0: # <<<<<<<<<<<<<< + * return self.__value + * return self.__value(**kwargs) + */ + } + + /* "dependency_injector/providers.pxd":256 + * if self.__call == 0: + * return self.__value + * return self.__value(**kwargs) # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + if (unlikely(__pyx_v_kwargs == Py_None)) { + PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); + __PYX_ERR(0, 256, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_self->__pyx___value, __pyx_empty_tuple, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 256, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "dependency_injector/providers.pxd":253 + * + * + * cdef inline object __get_value_kwargs(Injection self, dict kwargs): # <<<<<<<<<<<<<< + * if self.__call == 0: + * return self.__value + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("dependency_injector.providers.__get_value_kwargs", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "dependency_injector/providers.pxd":259 + * + * + * cdef inline tuple __separate_prefixed_kwargs(dict kwargs): # <<<<<<<<<<<<<< + * cdef dict plain_kwargs = {} + * cdef dict prefixed_kwargs = {} + */ + +static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___separate_prefixed_kwargs(PyObject *__pyx_v_kwargs) { + PyObject *__pyx_v_plain_kwargs = 0; + PyObject *__pyx_v_prefixed_kwargs = 0; + PyObject *__pyx_v_key = NULL; + PyObject *__pyx_v_value = NULL; + PyObject *__pyx_v_index = NULL; + PyObject *__pyx_v_prefix = NULL; + PyObject *__pyx_v_name = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *(*__pyx_t_8)(PyObject *); + int __pyx_t_9; + int __pyx_t_10; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__separate_prefixed_kwargs", 0); + + /* "dependency_injector/providers.pxd":260 + * + * cdef inline tuple __separate_prefixed_kwargs(dict kwargs): + * cdef dict plain_kwargs = {} # <<<<<<<<<<<<<< + * cdef dict prefixed_kwargs = {} + * + */ + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 260, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_plain_kwargs = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "dependency_injector/providers.pxd":261 + * cdef inline tuple __separate_prefixed_kwargs(dict kwargs): + * cdef dict plain_kwargs = {} + * cdef dict prefixed_kwargs = {} # <<<<<<<<<<<<<< + * + * for key, value in kwargs.items(): + */ + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_prefixed_kwargs = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "dependency_injector/providers.pxd":263 + * cdef dict prefixed_kwargs = {} + * + * for key, value in kwargs.items(): # <<<<<<<<<<<<<< + * if '__' not in key: + * plain_kwargs[key] = value + */ + if (unlikely(__pyx_v_kwargs == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); + __PYX_ERR(0, 263, __pyx_L1_error) + } + __pyx_t_1 = __Pyx_PyDict_Items(__pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { + __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 263, __pyx_L1_error) + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + for (;;) { + if (likely(!__pyx_t_4)) { + if (likely(PyList_CheckExact(__pyx_t_2))) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 263, __pyx_L1_error) + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + #endif + } else { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 263, __pyx_L1_error) + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + #endif + } + } else { + __pyx_t_1 = __pyx_t_4(__pyx_t_2); + if (unlikely(!__pyx_t_1)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 263, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { + PyObject* sequence = __pyx_t_1; + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(0, 263, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_5 = PyList_GET_ITEM(sequence, 0); + __pyx_t_6 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + #else + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; + index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_5); + index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_6); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 263, __pyx_L1_error) + __pyx_t_8 = NULL; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + goto __pyx_L6_unpacking_done; + __pyx_L5_unpacking_failed:; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_8 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + __PYX_ERR(0, 263, __pyx_L1_error) + __pyx_L6_unpacking_done:; + } + __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_5); + __pyx_t_5 = 0; + __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_6); + __pyx_t_6 = 0; + + /* "dependency_injector/providers.pxd":264 + * + * for key, value in kwargs.items(): + * if '__' not in key: # <<<<<<<<<<<<<< + * plain_kwargs[key] = value + * continue + */ + __pyx_t_9 = (__Pyx_PySequence_ContainsTF(__pyx_n_s__3, __pyx_v_key, Py_NE)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 264, __pyx_L1_error) + __pyx_t_10 = (__pyx_t_9 != 0); + if (__pyx_t_10) { + + /* "dependency_injector/providers.pxd":265 + * for key, value in kwargs.items(): + * if '__' not in key: + * plain_kwargs[key] = value # <<<<<<<<<<<<<< + * continue + * + */ + if (unlikely(PyDict_SetItem(__pyx_v_plain_kwargs, __pyx_v_key, __pyx_v_value) < 0)) __PYX_ERR(0, 265, __pyx_L1_error) + + /* "dependency_injector/providers.pxd":266 + * if '__' not in key: + * plain_kwargs[key] = value + * continue # <<<<<<<<<<<<<< + * + * index = key.index('__') + */ + goto __pyx_L3_continue; + + /* "dependency_injector/providers.pxd":264 + * + * for key, value in kwargs.items(): + * if '__' not in key: # <<<<<<<<<<<<<< + * plain_kwargs[key] = value + * continue + */ + } + + /* "dependency_injector/providers.pxd":268 + * continue + * + * index = key.index('__') # <<<<<<<<<<<<<< + * prefix, name = key[:index], key[index+2:] + * + */ + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_key, __pyx_n_s_index); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_5 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_6, function); + } + } + __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_n_s__3) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_n_s__3); + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 268, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_1); + __pyx_t_1 = 0; + + /* "dependency_injector/providers.pxd":269 + * + * index = key.index('__') + * prefix, name = key[:index], key[index+2:] # <<<<<<<<<<<<<< + * + * if prefix not in prefixed_kwargs: + */ + __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_key, 0, 0, NULL, &__pyx_v_index, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_v_index, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 269, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_v_key, 0, 0, &__pyx_t_6, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 269, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_prefix, __pyx_t_1); + __pyx_t_1 = 0; + __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_5); + __pyx_t_5 = 0; + + /* "dependency_injector/providers.pxd":271 + * prefix, name = key[:index], key[index+2:] + * + * if prefix not in prefixed_kwargs: # <<<<<<<<<<<<<< + * prefixed_kwargs[prefix] = {} + * prefixed_kwargs[prefix][name] = value + */ + __pyx_t_10 = (__Pyx_PyDict_ContainsTF(__pyx_v_prefix, __pyx_v_prefixed_kwargs, Py_NE)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 271, __pyx_L1_error) + __pyx_t_9 = (__pyx_t_10 != 0); + if (__pyx_t_9) { + + /* "dependency_injector/providers.pxd":272 + * + * if prefix not in prefixed_kwargs: + * prefixed_kwargs[prefix] = {} # <<<<<<<<<<<<<< + * prefixed_kwargs[prefix][name] = value + * + */ + __pyx_t_5 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 272, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (unlikely(PyDict_SetItem(__pyx_v_prefixed_kwargs, __pyx_v_prefix, __pyx_t_5) < 0)) __PYX_ERR(0, 272, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "dependency_injector/providers.pxd":271 + * prefix, name = key[:index], key[index+2:] + * + * if prefix not in prefixed_kwargs: # <<<<<<<<<<<<<< + * prefixed_kwargs[prefix] = {} + * prefixed_kwargs[prefix][name] = value + */ + } + + /* "dependency_injector/providers.pxd":273 + * if prefix not in prefixed_kwargs: + * prefixed_kwargs[prefix] = {} + * prefixed_kwargs[prefix][name] = value # <<<<<<<<<<<<<< + * + * return plain_kwargs, prefixed_kwargs + */ + __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_prefixed_kwargs, __pyx_v_prefix); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 273, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_v_name, __pyx_v_value) < 0)) __PYX_ERR(0, 273, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "dependency_injector/providers.pxd":263 + * cdef dict prefixed_kwargs = {} + * + * for key, value in kwargs.items(): # <<<<<<<<<<<<<< + * if '__' not in key: + * plain_kwargs[key] = value + */ + __pyx_L3_continue:; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "dependency_injector/providers.pxd":275 + * prefixed_kwargs[prefix][name] = value + * + * return plain_kwargs, prefixed_kwargs # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 275, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_v_plain_kwargs); + __Pyx_GIVEREF(__pyx_v_plain_kwargs); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_plain_kwargs); + __Pyx_INCREF(__pyx_v_prefixed_kwargs); + __Pyx_GIVEREF(__pyx_v_prefixed_kwargs); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_prefixed_kwargs); + __pyx_r = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "dependency_injector/providers.pxd":259 + * + * + * cdef inline tuple __separate_prefixed_kwargs(dict kwargs): # <<<<<<<<<<<<<< + * cdef dict plain_kwargs = {} + * cdef dict prefixed_kwargs = {} + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("dependency_injector.providers.__separate_prefixed_kwargs", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_plain_kwargs); + __Pyx_XDECREF(__pyx_v_prefixed_kwargs); + __Pyx_XDECREF(__pyx_v_key); + __Pyx_XDECREF(__pyx_v_value); + __Pyx_XDECREF(__pyx_v_index); + __Pyx_XDECREF(__pyx_v_prefix); + __Pyx_XDECREF(__pyx_v_name); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "dependency_injector/providers.pxd":280 * @cython.boundscheck(False) * @cython.wraparound(False) - * cdef inline tuple __provide_positional_args(tuple args, # <<<<<<<<<<<<<< - * tuple inj_args, - * int inj_args_len): + * cdef inline tuple __provide_positional_args( # <<<<<<<<<<<<<< + * tuple args, + * tuple inj_args, */ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provide_positional_args(PyObject *__pyx_v_args, PyObject *__pyx_v_inj_args, int __pyx_v_inj_args_len) { @@ -67034,7 +67492,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__provide_positional_args", 0); - /* "dependency_injector/providers.pxd":262 + /* "dependency_injector/providers.pxd":289 * cdef PositionalInjection injection * * if inj_args_len == 0: # <<<<<<<<<<<<<< @@ -67044,7 +67502,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid __pyx_t_1 = ((__pyx_v_inj_args_len == 0) != 0); if (__pyx_t_1) { - /* "dependency_injector/providers.pxd":263 + /* "dependency_injector/providers.pxd":290 * * if inj_args_len == 0: * return args # <<<<<<<<<<<<<< @@ -67056,7 +67514,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid __pyx_r = __pyx_v_args; goto __pyx_L0; - /* "dependency_injector/providers.pxd":262 + /* "dependency_injector/providers.pxd":289 * cdef PositionalInjection injection * * if inj_args_len == 0: # <<<<<<<<<<<<<< @@ -67065,19 +67523,19 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid */ } - /* "dependency_injector/providers.pxd":265 + /* "dependency_injector/providers.pxd":292 * return args * * positional_args = list() # <<<<<<<<<<<<<< * for index in range(inj_args_len): * injection = inj_args[index] */ - __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error) + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_positional_args = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "dependency_injector/providers.pxd":266 + /* "dependency_injector/providers.pxd":293 * * positional_args = list() * for index in range(inj_args_len): # <<<<<<<<<<<<<< @@ -67089,7 +67547,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_index = __pyx_t_5; - /* "dependency_injector/providers.pxd":267 + /* "dependency_injector/providers.pxd":294 * positional_args = list() * for index in range(inj_args_len): * injection = inj_args[index] # <<<<<<<<<<<<<< @@ -67098,36 +67556,36 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid */ if (unlikely(__pyx_v_inj_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 267, __pyx_L1_error) + __PYX_ERR(0, 294, __pyx_L1_error) } __pyx_t_2 = PyTuple_GET_ITEM(__pyx_v_inj_args, __pyx_v_index); __Pyx_INCREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_injection, ((struct __pyx_obj_19dependency_injector_9providers_PositionalInjection *)__pyx_t_2)); __pyx_t_2 = 0; - /* "dependency_injector/providers.pxd":268 + /* "dependency_injector/providers.pxd":295 * for index in range(inj_args_len): * injection = inj_args[index] * positional_args.append(__get_value(injection)) # <<<<<<<<<<<<<< * positional_args.extend(args) * */ - __pyx_t_2 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_injection)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 268, __pyx_L1_error) + __pyx_t_2 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_injection)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_positional_args, __pyx_t_2); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 268, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_positional_args, __pyx_t_2); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } - /* "dependency_injector/providers.pxd":269 + /* "dependency_injector/providers.pxd":296 * injection = inj_args[index] * positional_args.append(__get_value(injection)) * positional_args.extend(args) # <<<<<<<<<<<<<< * * return tuple(positional_args) */ - __pyx_t_6 = __Pyx_PyList_Extend(__pyx_v_positional_args, __pyx_v_args); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 269, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyList_Extend(__pyx_v_positional_args, __pyx_v_args); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 296, __pyx_L1_error) - /* "dependency_injector/providers.pxd":271 + /* "dependency_injector/providers.pxd":298 * positional_args.extend(args) * * return tuple(positional_args) # <<<<<<<<<<<<<< @@ -67135,18 +67593,18 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyList_AsTuple(__pyx_v_positional_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error) + __pyx_t_2 = PyList_AsTuple(__pyx_v_positional_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0; - /* "dependency_injector/providers.pxd":255 + /* "dependency_injector/providers.pxd":280 * @cython.boundscheck(False) * @cython.wraparound(False) - * cdef inline tuple __provide_positional_args(tuple args, # <<<<<<<<<<<<<< - * tuple inj_args, - * int inj_args_len): + * cdef inline tuple __provide_positional_args( # <<<<<<<<<<<<<< + * tuple args, + * tuple inj_args, */ /* function exit code */ @@ -67162,17 +67620,19 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid return __pyx_r; } -/* "dependency_injector/providers.pxd":276 +/* "dependency_injector/providers.pxd":303 * @cython.boundscheck(False) * @cython.wraparound(False) - * cdef inline dict __provide_keyword_args(dict kwargs, # <<<<<<<<<<<<<< - * tuple inj_kwargs, - * int inj_kwargs_len): + * cdef inline dict __provide_keyword_args( # <<<<<<<<<<<<<< + * dict kwargs, + * tuple inj_kwargs, */ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provide_keyword_args(PyObject *__pyx_v_kwargs, PyObject *__pyx_v_inj_kwargs, int __pyx_v_inj_kwargs_len) { int __pyx_v_index; PyObject *__pyx_v_name = 0; + PyObject *__pyx_v_value = 0; + PyObject *__pyx_v_prefixed = 0; struct __pyx_obj_19dependency_injector_9providers_NamedInjection *__pyx_v_kw_injection = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -67182,13 +67642,16 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid int __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + int __pyx_t_9; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__provide_keyword_args", 0); + __Pyx_INCREF(__pyx_v_kwargs); - /* "dependency_injector/providers.pxd":283 + /* "dependency_injector/providers.pxd":314 * cdef NamedInjection kw_injection * * if len(kwargs) == 0: # <<<<<<<<<<<<<< @@ -67197,13 +67660,13 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid */ if (unlikely(__pyx_v_kwargs == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 283, __pyx_L1_error) + __PYX_ERR(0, 314, __pyx_L1_error) } - __pyx_t_1 = PyDict_Size(__pyx_v_kwargs); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 283, __pyx_L1_error) + __pyx_t_1 = PyDict_Size(__pyx_v_kwargs); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 314, __pyx_L1_error) __pyx_t_2 = ((__pyx_t_1 == 0) != 0); if (__pyx_t_2) { - /* "dependency_injector/providers.pxd":284 + /* "dependency_injector/providers.pxd":315 * * if len(kwargs) == 0: * for index in range(inj_kwargs_len): # <<<<<<<<<<<<<< @@ -67215,7 +67678,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_index = __pyx_t_5; - /* "dependency_injector/providers.pxd":285 + /* "dependency_injector/providers.pxd":316 * if len(kwargs) == 0: * for index in range(inj_kwargs_len): * kw_injection = inj_kwargs[index] # <<<<<<<<<<<<<< @@ -67224,43 +67687,43 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid */ if (unlikely(__pyx_v_inj_kwargs == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 285, __pyx_L1_error) + __PYX_ERR(0, 316, __pyx_L1_error) } __pyx_t_6 = PyTuple_GET_ITEM(__pyx_v_inj_kwargs, __pyx_v_index); __Pyx_INCREF(__pyx_t_6); __Pyx_XDECREF_SET(__pyx_v_kw_injection, ((struct __pyx_obj_19dependency_injector_9providers_NamedInjection *)__pyx_t_6)); __pyx_t_6 = 0; - /* "dependency_injector/providers.pxd":286 + /* "dependency_injector/providers.pxd":317 * for index in range(inj_kwargs_len): * kw_injection = inj_kwargs[index] * name = __get_name(kw_injection) # <<<<<<<<<<<<<< * kwargs[name] = __get_value(kw_injection) * else: */ - __pyx_t_6 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_kw_injection); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_6 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_kw_injection); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 317, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_6); __pyx_t_6 = 0; - /* "dependency_injector/providers.pxd":287 + /* "dependency_injector/providers.pxd":318 * kw_injection = inj_kwargs[index] * name = __get_name(kw_injection) * kwargs[name] = __get_value(kw_injection) # <<<<<<<<<<<<<< * else: - * for index in range(inj_kwargs_len): + * kwargs, prefixed = __separate_prefixed_kwargs(kwargs) */ - __pyx_t_6 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_kw_injection)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error) + __pyx_t_6 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_kw_injection)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (unlikely(__pyx_v_kwargs == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 287, __pyx_L1_error) + __PYX_ERR(0, 318, __pyx_L1_error) } - if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_v_name, __pyx_t_6) < 0)) __PYX_ERR(0, 287, __pyx_L1_error) + if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_v_name, __pyx_t_6) < 0)) __PYX_ERR(0, 318, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } - /* "dependency_injector/providers.pxd":283 + /* "dependency_injector/providers.pxd":314 * cdef NamedInjection kw_injection * * if len(kwargs) == 0: # <<<<<<<<<<<<<< @@ -67270,92 +67733,198 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid goto __pyx_L3; } - /* "dependency_injector/providers.pxd":289 + /* "dependency_injector/providers.pxd":320 * kwargs[name] = __get_value(kw_injection) * else: + * kwargs, prefixed = __separate_prefixed_kwargs(kwargs) # <<<<<<<<<<<<<< + * + * + */ + /*else*/ { + __pyx_t_6 = __pyx_f_19dependency_injector_9providers___separate_prefixed_kwargs(__pyx_v_kwargs); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 320, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (likely(__pyx_t_6 != Py_None)) { + PyObject* sequence = __pyx_t_6; + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(0, 320, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(__pyx_t_8); + #else + __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 320, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 320, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + #endif + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else { + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 320, __pyx_L1_error) + } + if (!(likely(PyDict_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_7)->tp_name), 0))) __PYX_ERR(0, 320, __pyx_L1_error) + if (!(likely(PyDict_CheckExact(__pyx_t_8))||((__pyx_t_8) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_8)->tp_name), 0))) __PYX_ERR(0, 320, __pyx_L1_error) + __Pyx_DECREF_SET(__pyx_v_kwargs, ((PyObject*)__pyx_t_7)); + __pyx_t_7 = 0; + __pyx_v_prefixed = ((PyObject*)__pyx_t_8); + __pyx_t_8 = 0; + + /* "dependency_injector/providers.pxd":323 + * + * * for index in range(inj_kwargs_len): # <<<<<<<<<<<<<< * kw_injection = inj_kwargs[index] * name = __get_name(kw_injection) */ - /*else*/ { __pyx_t_3 = __pyx_v_inj_kwargs_len; __pyx_t_4 = __pyx_t_3; for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_index = __pyx_t_5; - /* "dependency_injector/providers.pxd":290 - * else: + /* "dependency_injector/providers.pxd":324 + * * for index in range(inj_kwargs_len): * kw_injection = inj_kwargs[index] # <<<<<<<<<<<<<< * name = __get_name(kw_injection) - * if name not in kwargs: + * */ if (unlikely(__pyx_v_inj_kwargs == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 290, __pyx_L1_error) + __PYX_ERR(0, 324, __pyx_L1_error) } __pyx_t_6 = PyTuple_GET_ITEM(__pyx_v_inj_kwargs, __pyx_v_index); __Pyx_INCREF(__pyx_t_6); __Pyx_XDECREF_SET(__pyx_v_kw_injection, ((struct __pyx_obj_19dependency_injector_9providers_NamedInjection *)__pyx_t_6)); __pyx_t_6 = 0; - /* "dependency_injector/providers.pxd":291 + /* "dependency_injector/providers.pxd":325 * for index in range(inj_kwargs_len): * kw_injection = inj_kwargs[index] * name = __get_name(kw_injection) # <<<<<<<<<<<<<< - * if name not in kwargs: - * kwargs[name] = __get_value(kw_injection) + * + * if name in kwargs: */ - __pyx_t_6 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_kw_injection); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_6 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_kw_injection); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_6); __pyx_t_6 = 0; - /* "dependency_injector/providers.pxd":292 - * kw_injection = inj_kwargs[index] + /* "dependency_injector/providers.pxd":327 * name = __get_name(kw_injection) - * if name not in kwargs: # <<<<<<<<<<<<<< - * kwargs[name] = __get_value(kw_injection) + * + * if name in kwargs: # <<<<<<<<<<<<<< + * continue * */ if (unlikely(__pyx_v_kwargs == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - __PYX_ERR(0, 292, __pyx_L1_error) + __PYX_ERR(0, 327, __pyx_L1_error) } - __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_v_name, __pyx_v_kwargs, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 292, __pyx_L1_error) - __pyx_t_7 = (__pyx_t_2 != 0); - if (__pyx_t_7) { + __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_v_name, __pyx_v_kwargs, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 327, __pyx_L1_error) + __pyx_t_9 = (__pyx_t_2 != 0); + if (__pyx_t_9) { - /* "dependency_injector/providers.pxd":293 + /* "dependency_injector/providers.pxd":328 + * + * if name in kwargs: + * continue # <<<<<<<<<<<<<< + * + * if name in prefixed: + */ + goto __pyx_L6_continue; + + /* "dependency_injector/providers.pxd":327 * name = __get_name(kw_injection) - * if name not in kwargs: - * kwargs[name] = __get_value(kw_injection) # <<<<<<<<<<<<<< + * + * if name in kwargs: # <<<<<<<<<<<<<< + * continue + * + */ + } + + /* "dependency_injector/providers.pxd":330 + * continue + * + * if name in prefixed: # <<<<<<<<<<<<<< + * value = __get_value_kwargs(kw_injection, prefixed[name]) + * else: + */ + if (unlikely(__pyx_v_prefixed == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + __PYX_ERR(0, 330, __pyx_L1_error) + } + __pyx_t_9 = (__Pyx_PyDict_ContainsTF(__pyx_v_name, __pyx_v_prefixed, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 330, __pyx_L1_error) + __pyx_t_2 = (__pyx_t_9 != 0); + if (__pyx_t_2) { + + /* "dependency_injector/providers.pxd":331 + * + * if name in prefixed: + * value = __get_value_kwargs(kw_injection, prefixed[name]) # <<<<<<<<<<<<<< + * else: + * value = __get_value(kw_injection) + */ + if (unlikely(__pyx_v_prefixed == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + __PYX_ERR(0, 331, __pyx_L1_error) + } + __pyx_t_6 = __Pyx_PyDict_GetItem(__pyx_v_prefixed, __pyx_v_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 331, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (!(likely(PyDict_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_6)->tp_name), 0))) __PYX_ERR(0, 331, __pyx_L1_error) + __pyx_t_8 = __pyx_f_19dependency_injector_9providers___get_value_kwargs(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_kw_injection), ((PyObject*)__pyx_t_6)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 331, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_8); + __pyx_t_8 = 0; + + /* "dependency_injector/providers.pxd":330 + * continue + * + * if name in prefixed: # <<<<<<<<<<<<<< + * value = __get_value_kwargs(kw_injection, prefixed[name]) + * else: + */ + goto __pyx_L9; + } + + /* "dependency_injector/providers.pxd":333 + * value = __get_value_kwargs(kw_injection, prefixed[name]) + * else: + * value = __get_value(kw_injection) # <<<<<<<<<<<<<< + * + * kwargs[name] = value + */ + /*else*/ { + __pyx_t_8 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_kw_injection)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 333, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_8); + __pyx_t_8 = 0; + } + __pyx_L9:; + + /* "dependency_injector/providers.pxd":335 + * value = __get_value(kw_injection) + * + * kwargs[name] = value # <<<<<<<<<<<<<< * * return kwargs */ - __pyx_t_6 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_kw_injection)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 293, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (unlikely(__pyx_v_kwargs == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 293, __pyx_L1_error) - } - if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_v_name, __pyx_t_6) < 0)) __PYX_ERR(0, 293, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "dependency_injector/providers.pxd":292 - * kw_injection = inj_kwargs[index] - * name = __get_name(kw_injection) - * if name not in kwargs: # <<<<<<<<<<<<<< - * kwargs[name] = __get_value(kw_injection) - * - */ + if (unlikely(__pyx_v_kwargs == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + __PYX_ERR(0, 335, __pyx_L1_error) } + if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_v_name, __pyx_v_value) < 0)) __PYX_ERR(0, 335, __pyx_L1_error) + __pyx_L6_continue:; } } __pyx_L3:; - /* "dependency_injector/providers.pxd":295 - * kwargs[name] = __get_value(kw_injection) + /* "dependency_injector/providers.pxd":337 + * kwargs[name] = value * * return kwargs # <<<<<<<<<<<<<< * @@ -67366,33 +67935,38 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid __pyx_r = __pyx_v_kwargs; goto __pyx_L0; - /* "dependency_injector/providers.pxd":276 + /* "dependency_injector/providers.pxd":303 * @cython.boundscheck(False) * @cython.wraparound(False) - * cdef inline dict __provide_keyword_args(dict kwargs, # <<<<<<<<<<<<<< - * tuple inj_kwargs, - * int inj_kwargs_len): + * cdef inline dict __provide_keyword_args( # <<<<<<<<<<<<<< + * dict kwargs, + * tuple inj_kwargs, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("dependency_injector.providers.__provide_keyword_args", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_name); + __Pyx_XDECREF(__pyx_v_value); + __Pyx_XDECREF(__pyx_v_prefixed); __Pyx_XDECREF((PyObject *)__pyx_v_kw_injection); + __Pyx_XDECREF(__pyx_v_kwargs); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "dependency_injector/providers.pxd":300 +/* "dependency_injector/providers.pxd":342 * @cython.boundscheck(False) * @cython.wraparound(False) - * cdef inline object __inject_attributes(object instance, # <<<<<<<<<<<<<< - * tuple attributes, - * int attributes_len): + * cdef inline object __inject_attributes( # <<<<<<<<<<<<<< + * object instance, + * tuple attributes, */ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___inject_attributes(PyObject *__pyx_v_instance, PyObject *__pyx_v_attributes, int __pyx_v_attributes_len) { @@ -67411,8 +67985,8 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___inject int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__inject_attributes", 0); - /* "dependency_injector/providers.pxd":304 - * int attributes_len): + /* "dependency_injector/providers.pxd":348 + * ): * cdef NamedInjection attr_injection * for index in range(attributes_len): # <<<<<<<<<<<<<< * attr_injection = attributes[index] @@ -67423,7 +67997,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___inject for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_index = __pyx_t_3; - /* "dependency_injector/providers.pxd":305 + /* "dependency_injector/providers.pxd":349 * cdef NamedInjection attr_injection * for index in range(attributes_len): * attr_injection = attributes[index] # <<<<<<<<<<<<<< @@ -67432,51 +68006,51 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___inject */ if (unlikely(__pyx_v_attributes == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 305, __pyx_L1_error) + __PYX_ERR(0, 349, __pyx_L1_error) } __pyx_t_4 = PyTuple_GET_ITEM(__pyx_v_attributes, __pyx_v_index); __Pyx_INCREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_attr_injection, ((struct __pyx_obj_19dependency_injector_9providers_NamedInjection *)__pyx_t_4)); __pyx_t_4 = 0; - /* "dependency_injector/providers.pxd":307 + /* "dependency_injector/providers.pxd":351 * attr_injection = attributes[index] * setattr(instance, * __get_name(attr_injection), # <<<<<<<<<<<<<< * __get_value(attr_injection)) * */ - __pyx_t_4 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_attr_injection); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 307, __pyx_L1_error) + __pyx_t_4 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_attr_injection); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - /* "dependency_injector/providers.pxd":308 + /* "dependency_injector/providers.pxd":352 * setattr(instance, * __get_name(attr_injection), * __get_value(attr_injection)) # <<<<<<<<<<<<<< * * */ - __pyx_t_5 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_attr_injection)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 308, __pyx_L1_error) + __pyx_t_5 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_attr_injection)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - /* "dependency_injector/providers.pxd":306 + /* "dependency_injector/providers.pxd":350 * for index in range(attributes_len): * attr_injection = attributes[index] * setattr(instance, # <<<<<<<<<<<<<< * __get_name(attr_injection), * __get_value(attr_injection)) */ - __pyx_t_6 = PyObject_SetAttr(__pyx_v_instance, __pyx_t_4, __pyx_t_5); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 306, __pyx_L1_error) + __pyx_t_6 = PyObject_SetAttr(__pyx_v_instance, __pyx_t_4, __pyx_t_5); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 350, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } - /* "dependency_injector/providers.pxd":300 + /* "dependency_injector/providers.pxd":342 * @cython.boundscheck(False) * @cython.wraparound(False) - * cdef inline object __inject_attributes(object instance, # <<<<<<<<<<<<<< - * tuple attributes, - * int attributes_len): + * cdef inline object __inject_attributes( # <<<<<<<<<<<<<< + * object instance, + * tuple attributes, */ /* function exit code */ @@ -67494,7 +68068,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___inject return __pyx_r; } -/* "dependency_injector/providers.pxd":311 +/* "dependency_injector/providers.pxd":355 * * * cdef inline object __callable_call(Callable self, tuple args, dict kwargs): # <<<<<<<<<<<<<< @@ -67514,7 +68088,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___callab int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__callable_call", 0); - /* "dependency_injector/providers.pxd":316 + /* "dependency_injector/providers.pxd":360 * * positional_args = __provide_positional_args(args, * self.__args, # <<<<<<<<<<<<<< @@ -67524,20 +68098,20 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___callab __pyx_t_1 = __pyx_v_self->__pyx___args; __Pyx_INCREF(__pyx_t_1); - /* "dependency_injector/providers.pxd":315 + /* "dependency_injector/providers.pxd":359 * cdef dict keyword_args * * positional_args = __provide_positional_args(args, # <<<<<<<<<<<<<< * self.__args, * self.__args_len) */ - __pyx_t_2 = __pyx_f_19dependency_injector_9providers___provide_positional_args(__pyx_v_args, ((PyObject*)__pyx_t_1), __pyx_v_self->__pyx___args_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 315, __pyx_L1_error) + __pyx_t_2 = __pyx_f_19dependency_injector_9providers___provide_positional_args(__pyx_v_args, ((PyObject*)__pyx_t_1), __pyx_v_self->__pyx___args_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 359, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_positional_args = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "dependency_injector/providers.pxd":319 + /* "dependency_injector/providers.pxd":363 * self.__args_len) * keyword_args = __provide_keyword_args(kwargs, * self.__kwargs, # <<<<<<<<<<<<<< @@ -67547,20 +68121,20 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___callab __pyx_t_2 = __pyx_v_self->__pyx___kwargs; __Pyx_INCREF(__pyx_t_2); - /* "dependency_injector/providers.pxd":318 + /* "dependency_injector/providers.pxd":362 * self.__args, * self.__args_len) * keyword_args = __provide_keyword_args(kwargs, # <<<<<<<<<<<<<< * self.__kwargs, * self.__kwargs_len) */ - __pyx_t_1 = __pyx_f_19dependency_injector_9providers___provide_keyword_args(__pyx_v_kwargs, ((PyObject*)__pyx_t_2), __pyx_v_self->__pyx___kwargs_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 318, __pyx_L1_error) + __pyx_t_1 = __pyx_f_19dependency_injector_9providers___provide_keyword_args(__pyx_v_kwargs, ((PyObject*)__pyx_t_2), __pyx_v_self->__pyx___kwargs_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_keyword_args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "dependency_injector/providers.pxd":322 + /* "dependency_injector/providers.pxd":366 * self.__kwargs_len) * * return self.__provides(*positional_args, **keyword_args) # <<<<<<<<<<<<<< @@ -67570,19 +68144,19 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___callab __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_positional_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - __PYX_ERR(0, 322, __pyx_L1_error) + __PYX_ERR(0, 366, __pyx_L1_error) } if (unlikely(__pyx_v_keyword_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); - __PYX_ERR(0, 322, __pyx_L1_error) + __PYX_ERR(0, 366, __pyx_L1_error) } - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_self->__pyx___provides, __pyx_v_positional_args, __pyx_v_keyword_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 322, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_self->__pyx___provides, __pyx_v_positional_args, __pyx_v_keyword_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "dependency_injector/providers.pxd":311 + /* "dependency_injector/providers.pxd":355 * * * cdef inline object __callable_call(Callable self, tuple args, dict kwargs): # <<<<<<<<<<<<<< @@ -67604,7 +68178,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___callab return __pyx_r; } -/* "dependency_injector/providers.pxd":325 +/* "dependency_injector/providers.pxd":369 * * * cdef inline object __factory_call(Factory self, tuple args, dict kwargs): # <<<<<<<<<<<<<< @@ -67624,7 +68198,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__factory_call", 0); - /* "dependency_injector/providers.pxd":328 + /* "dependency_injector/providers.pxd":372 * cdef object instance * * instance = __callable_call(self.__instantiator, args, kwargs) # <<<<<<<<<<<<<< @@ -67633,13 +68207,13 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor */ __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx___instantiator); __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = __pyx_f_19dependency_injector_9providers___callable_call(((struct __pyx_obj_19dependency_injector_9providers_Callable *)__pyx_t_1), __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 328, __pyx_L1_error) + __pyx_t_2 = __pyx_f_19dependency_injector_9providers___callable_call(((struct __pyx_obj_19dependency_injector_9providers_Callable *)__pyx_t_1), __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_instance = __pyx_t_2; __pyx_t_2 = 0; - /* "dependency_injector/providers.pxd":330 + /* "dependency_injector/providers.pxd":374 * instance = __callable_call(self.__instantiator, args, kwargs) * * if self.__attributes_len > 0: # <<<<<<<<<<<<<< @@ -67649,7 +68223,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor __pyx_t_3 = ((__pyx_v_self->__pyx___attributes_len > 0) != 0); if (__pyx_t_3) { - /* "dependency_injector/providers.pxd":332 + /* "dependency_injector/providers.pxd":376 * if self.__attributes_len > 0: * __inject_attributes(instance, * self.__attributes, # <<<<<<<<<<<<<< @@ -67659,19 +68233,19 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor __pyx_t_2 = __pyx_v_self->__pyx___attributes; __Pyx_INCREF(__pyx_t_2); - /* "dependency_injector/providers.pxd":331 + /* "dependency_injector/providers.pxd":375 * * if self.__attributes_len > 0: * __inject_attributes(instance, # <<<<<<<<<<<<<< * self.__attributes, * self.__attributes_len) */ - __pyx_t_1 = __pyx_f_19dependency_injector_9providers___inject_attributes(__pyx_v_instance, ((PyObject*)__pyx_t_2), __pyx_v_self->__pyx___attributes_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error) + __pyx_t_1 = __pyx_f_19dependency_injector_9providers___inject_attributes(__pyx_v_instance, ((PyObject*)__pyx_t_2), __pyx_v_self->__pyx___attributes_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 375, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "dependency_injector/providers.pxd":330 + /* "dependency_injector/providers.pxd":374 * instance = __callable_call(self.__instantiator, args, kwargs) * * if self.__attributes_len > 0: # <<<<<<<<<<<<<< @@ -67680,7 +68254,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor */ } - /* "dependency_injector/providers.pxd":335 + /* "dependency_injector/providers.pxd":379 * self.__attributes_len) * * return instance # <<<<<<<<<<<<<< @@ -67690,7 +68264,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor __pyx_r = __pyx_v_instance; goto __pyx_L0; - /* "dependency_injector/providers.pxd":325 + /* "dependency_injector/providers.pxd":369 * * * cdef inline object __factory_call(Factory self, tuple args, dict kwargs): # <<<<<<<<<<<<<< @@ -73029,6 +73603,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_im_func, __pyx_k_im_func, sizeof(__pyx_k_im_func), 0, 0, 1, 1}, {&__pyx_n_s_im_self, __pyx_k_im_self, sizeof(__pyx_k_im_self), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1}, {&__pyx_n_s_iniconfigparser, __pyx_k_iniconfigparser, sizeof(__pyx_k_iniconfigparser), 0, 0, 1, 1}, {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1}, {&__pyx_n_s_inspect, __pyx_k_inspect, sizeof(__pyx_k_inspect), 0, 0, 1, 1}, @@ -73179,7 +73754,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 266, __pyx_L1_error) + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 293, __pyx_L1_error) __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 16, __pyx_L1_error) __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(1, 423, __pyx_L1_error) __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(1, 68, __pyx_L1_error) @@ -73482,6 +74057,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { __pyx_umethod_PyDict_Type_values.type = (PyObject*)&PyDict_Type; if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(1, 1, __pyx_L1_error); __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(1, 1, __pyx_L1_error) + __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(1, 1, __pyx_L1_error) __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(1, 1, __pyx_L1_error) __pyx_int_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) __PYX_ERR(1, 1, __pyx_L1_error) __pyx_int_3297756 = PyInt_FromLong(3297756L); if (unlikely(!__pyx_int_3297756)) __PYX_ERR(1, 1, __pyx_L1_error) @@ -76310,7 +76886,7 @@ if (!__Pyx_RefNanny) { if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_9) < 0) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "dependency_injector/providers.pxd":325 + /* "dependency_injector/providers.pxd":369 * * * cdef inline object __factory_call(Factory self, tuple args, dict kwargs): # <<<<<<<<<<<<<< @@ -78214,6 +78790,232 @@ static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) { } } +/* SliceObject */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj, + Py_ssize_t cstart, Py_ssize_t cstop, + PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice, + int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) { +#if CYTHON_USE_TYPE_SLOTS + PyMappingMethods* mp; +#if PY_MAJOR_VERSION < 3 + PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence; + if (likely(ms && ms->sq_slice)) { + if (!has_cstart) { + if (_py_start && (*_py_start != Py_None)) { + cstart = __Pyx_PyIndex_AsSsize_t(*_py_start); + if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; + } else + cstart = 0; + } + if (!has_cstop) { + if (_py_stop && (*_py_stop != Py_None)) { + cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop); + if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; + } else + cstop = PY_SSIZE_T_MAX; + } + if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) { + Py_ssize_t l = ms->sq_length(obj); + if (likely(l >= 0)) { + if (cstop < 0) { + cstop += l; + if (cstop < 0) cstop = 0; + } + if (cstart < 0) { + cstart += l; + if (cstart < 0) cstart = 0; + } + } else { + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + goto bad; + PyErr_Clear(); + } + } + return ms->sq_slice(obj, cstart, cstop); + } +#endif + mp = Py_TYPE(obj)->tp_as_mapping; + if (likely(mp && mp->mp_subscript)) +#endif + { + PyObject* result; + PyObject *py_slice, *py_start, *py_stop; + if (_py_slice) { + py_slice = *_py_slice; + } else { + PyObject* owned_start = NULL; + PyObject* owned_stop = NULL; + if (_py_start) { + py_start = *_py_start; + } else { + if (has_cstart) { + owned_start = py_start = PyInt_FromSsize_t(cstart); + if (unlikely(!py_start)) goto bad; + } else + py_start = Py_None; + } + if (_py_stop) { + py_stop = *_py_stop; + } else { + if (has_cstop) { + owned_stop = py_stop = PyInt_FromSsize_t(cstop); + if (unlikely(!py_stop)) { + Py_XDECREF(owned_start); + goto bad; + } + } else + py_stop = Py_None; + } + py_slice = PySlice_New(py_start, py_stop, Py_None); + Py_XDECREF(owned_start); + Py_XDECREF(owned_stop); + if (unlikely(!py_slice)) goto bad; + } +#if CYTHON_USE_TYPE_SLOTS + result = mp->mp_subscript(obj, py_slice); +#else + result = PyObject_GetItem(obj, py_slice); +#endif + if (!_py_slice) { + Py_DECREF(py_slice); + } + return result; + } + PyErr_Format(PyExc_TypeError, + "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name); +bad: + return NULL; +} + +/* PyIntBinop */ +#if !CYTHON_COMPILING_IN_PYPY +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) { + (void)inplace; + (void)zerodivision_check; + #if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(op1))) { + const long b = intval; + long x; + long a = PyInt_AS_LONG(op1); + x = (long)((unsigned long)a + b); + if (likely((x^a) >= 0 || (x^b) >= 0)) + return PyInt_FromLong(x); + return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + #endif + #if CYTHON_USE_PYLONG_INTERNALS + if (likely(PyLong_CheckExact(op1))) { + const long b = intval; + long a, x; +#ifdef HAVE_LONG_LONG + const PY_LONG_LONG llb = intval; + PY_LONG_LONG lla, llx; +#endif + const digit* digits = ((PyLongObject*)op1)->ob_digit; + const Py_ssize_t size = Py_SIZE(op1); + if (likely(__Pyx_sst_abs(size) <= 1)) { + a = likely(size) ? digits[0] : 0; + if (size == -1) a = -a; + } else { + switch (size) { + case -2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case -3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case -4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + default: return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + } + x = a + b; + return PyLong_FromLong(x); +#ifdef HAVE_LONG_LONG + long_long: + llx = lla + llb; + return PyLong_FromLongLong(llx); +#endif + + + } + #endif + if (PyFloat_CheckExact(op1)) { + const long b = intval; + double a = PyFloat_AS_DOUBLE(op1); + double result; + PyFPE_START_PROTECT("add", return NULL) + result = ((double)a) + (double)b; + PyFPE_END_PROTECT(result) + return PyFloat_FromDouble(result); + } + return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); +} +#endif + +/* RaiseNoneIterError */ +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + /* PyObject_GenericGetAttrNoDict */ #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { diff --git a/src/dependency_injector/providers.pxd b/src/dependency_injector/providers.pxd index 5aa88553..b8057e4f 100644 --- a/src/dependency_injector/providers.pxd +++ b/src/dependency_injector/providers.pxd @@ -250,11 +250,38 @@ cdef inline object __get_value(Injection self): return self.__value() +cdef inline object __get_value_kwargs(Injection self, dict kwargs): + if self.__call == 0: + return self.__value + return self.__value(**kwargs) + + +cdef inline tuple __separate_prefixed_kwargs(dict kwargs): + cdef dict plain_kwargs = {} + cdef dict prefixed_kwargs = {} + + for key, value in kwargs.items(): + if '__' not in key: + plain_kwargs[key] = value + continue + + index = key.index('__') + prefix, name = key[:index], key[index+2:] + + if prefix not in prefixed_kwargs: + prefixed_kwargs[prefix] = {} + prefixed_kwargs[prefix][name] = value + + return plain_kwargs, prefixed_kwargs + + @cython.boundscheck(False) @cython.wraparound(False) -cdef inline tuple __provide_positional_args(tuple args, - tuple inj_args, - int inj_args_len): +cdef inline tuple __provide_positional_args( + tuple args, + tuple inj_args, + int inj_args_len, +): cdef int index cdef list positional_args cdef PositionalInjection injection @@ -273,11 +300,15 @@ cdef inline tuple __provide_positional_args(tuple args, @cython.boundscheck(False) @cython.wraparound(False) -cdef inline dict __provide_keyword_args(dict kwargs, - tuple inj_kwargs, - int inj_kwargs_len): +cdef inline dict __provide_keyword_args( + dict kwargs, + tuple inj_kwargs, + int inj_kwargs_len, +): cdef int index cdef object name + cdef object value + cdef dict prefixed cdef NamedInjection kw_injection if len(kwargs) == 0: @@ -286,20 +317,33 @@ cdef inline dict __provide_keyword_args(dict kwargs, name = __get_name(kw_injection) kwargs[name] = __get_value(kw_injection) else: + kwargs, prefixed = __separate_prefixed_kwargs(kwargs) + + for index in range(inj_kwargs_len): kw_injection = inj_kwargs[index] name = __get_name(kw_injection) - if name not in kwargs: - kwargs[name] = __get_value(kw_injection) + + if name in kwargs: + continue + + if name in prefixed: + value = __get_value_kwargs(kw_injection, prefixed[name]) + else: + value = __get_value(kw_injection) + + kwargs[name] = value return kwargs @cython.boundscheck(False) @cython.wraparound(False) -cdef inline object __inject_attributes(object instance, - tuple attributes, - int attributes_len): +cdef inline object __inject_attributes( + object instance, + tuple attributes, + int attributes_len, +): cdef NamedInjection attr_injection for index in range(attributes_len): attr_injection = attributes[index] diff --git a/tests/unit/providers/test_factories_py2_py3.py b/tests/unit/providers/test_factories_py2_py3.py index d8be19fb..af2342dc 100644 --- a/tests/unit/providers/test_factories_py2_py3.py +++ b/tests/unit/providers/test_factories_py2_py3.py @@ -166,6 +166,45 @@ class FactoryTests(unittest.TestCase): self.assertEqual(instance.init_arg3, 33) self.assertEqual(instance.init_arg4, 44) + def test_call_with_deep_context_kwargs(self): + """`Factory` providers deep init injections example.""" + class Regularizer: + def __init__(self, alpha): + self.alpha = alpha + + class Loss: + def __init__(self, regularizer): + self.regularizer = regularizer + + class ClassificationTask: + def __init__(self, loss): + self.loss = loss + + class Algorithm: + def __init__(self, task): + self.task = task + + algorithm_factory = providers.Factory( + Algorithm, + task=providers.Factory( + ClassificationTask, + loss=providers.Factory( + Loss, + regularizer=providers.Factory( + Regularizer, + ), + ), + ), + ) + + algorithm_1 = algorithm_factory(task__loss__regularizer__alpha=0.5) + algorithm_2 = algorithm_factory(task__loss__regularizer__alpha=0.7) + algorithm_3 = algorithm_factory(task__loss__regularizer=Regularizer(alpha=0.8)) + + self.assertEqual(algorithm_1.task.loss.regularizer.alpha, 0.5) + self.assertEqual(algorithm_2.task.loss.regularizer.alpha, 0.7) + self.assertEqual(algorithm_3.task.loss.regularizer.alpha, 0.8) + def test_fluent_interface(self): provider = providers.Factory(Example) \ .add_args(1, 2) \