Add a fix to Configuration provider

This commit is contained in:
Roman Mogylatov 2020-06-21 00:10:47 -04:00
parent fd46b6ace5
commit 4829efff71
2 changed files with 56 additions and 35 deletions

View File

@ -2571,6 +2571,7 @@ static const char __pyx_k_dict[] = "__dict__";
static const char __pyx_k_exit[] = "__exit__";
static const char __pyx_k_init[] = "__init__";
static const char __pyx_k_join[] = "join";
static const char __pyx_k_keys[] = "keys";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_memo[] = "memo";
static const char __pyx_k_name[] = "__name__";
@ -2933,6 +2934,7 @@ static PyObject *__pyx_n_s_is_coroutine_marker;
static PyObject *__pyx_n_s_iscoroutinefunction;
static PyObject *__pyx_n_s_items;
static PyObject *__pyx_n_s_join;
static PyObject *__pyx_n_s_keys;
static PyObject *__pyx_n_s_kwargs;
static PyObject *__pyx_n_s_lambda;
static PyObject *__pyx_n_s_last_overriding;
@ -20451,7 +20453,7 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_13Configuration_10ove
* if not isinstance(value, dict):
* return # <<<<<<<<<<<<<<
*
* for name in value:
* for name in value.keys():
*/
__Pyx_XDECREF(__pyx_r);
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
@ -20469,40 +20471,58 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_13Configuration_10ove
/* "dependency_injector/providers.pyx":1100
* return
*
* for name in value: # <<<<<<<<<<<<<<
* for name in value.keys(): # <<<<<<<<<<<<<<
* child_provider = self.__children.get(name)
* if child_provider is None:
*/
if (likely(PyList_CheckExact(__pyx_v_value)) || PyTuple_CheckExact(__pyx_v_value)) {
__pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1100, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = NULL;
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
__pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
if (likely(__pyx_t_3)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
__Pyx_INCREF(__pyx_t_3);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_2, function);
}
}
__pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1100, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
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_6 = 0;
__pyx_t_7 = NULL;
} else {
__pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1100, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1100, __pyx_L1_error)
__pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1100, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1100, __pyx_L1_error)
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
for (;;) {
if (likely(!__pyx_t_7)) {
if (likely(PyList_CheckExact(__pyx_t_1))) {
if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
if (likely(PyList_CheckExact(__pyx_t_2))) {
if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(1, 1100, __pyx_L1_error)
__pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(1, 1100, __pyx_L1_error)
#else
__pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1100, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1100, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
#endif
} else {
if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(1, 1100, __pyx_L1_error)
__pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(1, 1100, __pyx_L1_error)
#else
__pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1100, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1100, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
#endif
}
} else {
__pyx_t_2 = __pyx_t_7(__pyx_t_1);
if (unlikely(!__pyx_t_2)) {
__pyx_t_1 = __pyx_t_7(__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();
@ -20510,14 +20530,14 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_13Configuration_10ove
}
break;
}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GOTREF(__pyx_t_1);
}
__Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_2);
__pyx_t_2 = 0;
__Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_1);
__pyx_t_1 = 0;
/* "dependency_injector/providers.pyx":1101
*
* for name in value:
* for name in value.keys():
* child_provider = self.__children.get(name) # <<<<<<<<<<<<<<
* if child_provider is None:
* continue
@ -20526,13 +20546,13 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_13Configuration_10ove
PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get");
__PYX_ERR(1, 1101, __pyx_L1_error)
}
__pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->__pyx___children, __pyx_v_name, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1101, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_XDECREF_SET(__pyx_v_child_provider, __pyx_t_2);
__pyx_t_2 = 0;
__pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->__pyx___children, __pyx_v_name, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1101, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_XDECREF_SET(__pyx_v_child_provider, __pyx_t_1);
__pyx_t_1 = 0;
/* "dependency_injector/providers.pyx":1102
* for name in value:
* for name in value.keys():
* child_provider = self.__children.get(name)
* if child_provider is None: # <<<<<<<<<<<<<<
* continue
@ -20552,7 +20572,7 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_13Configuration_10ove
goto __pyx_L4_continue;
/* "dependency_injector/providers.pyx":1102
* for name in value:
* for name in value.keys():
* child_provider = self.__children.get(name)
* if child_provider is None: # <<<<<<<<<<<<<<
* continue
@ -20596,24 +20616,24 @@ static PyObject *__pyx_pf_19dependency_injector_9providers_13Configuration_10ove
__Pyx_DECREF_SET(__pyx_t_3, function);
}
}
__pyx_t_2 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8);
__pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8);
__Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1104, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1104, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "dependency_injector/providers.pyx":1100
* return
*
* for name in value: # <<<<<<<<<<<<<<
* for name in value.keys(): # <<<<<<<<<<<<<<
* child_provider = self.__children.get(name)
* if child_provider is None:
*/
__pyx_L4_continue:;
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "dependency_injector/providers.pyx":1106
* child_provider.override(value.get(name))
@ -61719,6 +61739,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s_iscoroutinefunction, __pyx_k_iscoroutinefunction, sizeof(__pyx_k_iscoroutinefunction), 0, 0, 1, 1},
{&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
{&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
{&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1},
{&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
{&__pyx_n_s_lambda, __pyx_k_lambda, sizeof(__pyx_k_lambda), 0, 0, 1, 1},
{&__pyx_n_s_last_overriding, __pyx_k_last_overriding, sizeof(__pyx_k_last_overriding), 0, 0, 1, 1},

View File

@ -1097,7 +1097,7 @@ cdef class Configuration(Object):
if not isinstance(value, dict):
return
for name in value:
for name in value.keys():
child_provider = self.__children.get(name)
if child_provider is None:
continue