mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-23 01:56:58 +03:00
Merge branch 'release/3.14.3' into master
This commit is contained in:
commit
5cf5bdda24
|
@ -7,6 +7,13 @@ that were made in every particular version.
|
||||||
From version 0.7.6 *Dependency Injector* framework strictly
|
From version 0.7.6 *Dependency Injector* framework strictly
|
||||||
follows `Semantic versioning`_
|
follows `Semantic versioning`_
|
||||||
|
|
||||||
|
3.14.3
|
||||||
|
------
|
||||||
|
- Fix issue with copying providers that have system streams injections
|
||||||
|
(``sys.stdin``, ``sys.stdout`` and ``sys.stderr``).
|
||||||
|
- Add support of six 1.12.0.
|
||||||
|
- Regenerate C sources using Cython 0.29.2.
|
||||||
|
|
||||||
3.14.2
|
3.14.2
|
||||||
------
|
------
|
||||||
- Set Cython ``language_level=2``.
|
- Set Cython ``language_level=2``.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
cython==0.29
|
cython==0.29.2
|
||||||
tox
|
tox
|
||||||
unittest2
|
unittest2
|
||||||
coverage
|
coverage
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
six>=1.7.0,<=1.11.0
|
six>=1.7.0,<=1.12.0
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Dependency injector top-level package."""
|
"""Dependency injector top-level package."""
|
||||||
|
|
||||||
__version__ = '3.14.2'
|
__version__ = '3.14.3'
|
||||||
"""Version number that follows semantic versioning.
|
"""Version number that follows semantic versioning.
|
||||||
|
|
||||||
:type: str
|
:type: str
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Generated by Cython 0.29 */
|
/* Generated by Cython 0.29.2 */
|
||||||
|
|
||||||
#define PY_SSIZE_T_CLEAN
|
#define PY_SSIZE_T_CLEAN
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
|
@ -7,8 +7,8 @@
|
||||||
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
|
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
|
||||||
#error Cython requires Python 2.6+ or Python 3.3+.
|
#error Cython requires Python 2.6+ or Python 3.3+.
|
||||||
#else
|
#else
|
||||||
#define CYTHON_ABI "0_29"
|
#define CYTHON_ABI "0_29_2"
|
||||||
#define CYTHON_HEX_VERSION 0x001D00F0
|
#define CYTHON_HEX_VERSION 0x001D02F0
|
||||||
#define CYTHON_FUTURE_DIVISION 0
|
#define CYTHON_FUTURE_DIVISION 0
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#ifndef offsetof
|
#ifndef offsetof
|
||||||
|
@ -197,6 +197,9 @@
|
||||||
#undef SHIFT
|
#undef SHIFT
|
||||||
#undef BASE
|
#undef BASE
|
||||||
#undef MASK
|
#undef MASK
|
||||||
|
#ifdef SIZEOF_VOID_P
|
||||||
|
enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef __has_attribute
|
#ifndef __has_attribute
|
||||||
#define __has_attribute(x) 0
|
#define __has_attribute(x) 0
|
||||||
|
@ -1902,7 +1905,7 @@ static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args,
|
||||||
#include "frameobject.h"
|
#include "frameobject.h"
|
||||||
#define __Pxy_PyFrame_Initialize_Offsets()\
|
#define __Pxy_PyFrame_Initialize_Offsets()\
|
||||||
((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
|
((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
|
||||||
(void)(__pyx_pyframe_localsplus_offset = PyFrame_Type.tp_basicsize - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
|
(void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
|
||||||
#define __Pyx_PyFrame_GetLocalsplus(frame)\
|
#define __Pyx_PyFrame_GetLocalsplus(frame)\
|
||||||
(assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
|
(assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
|
||||||
#endif
|
#endif
|
||||||
|
@ -10325,17 +10328,6 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
|
||||||
__Pyx_GOTREF(__pyx_slice_);
|
__Pyx_GOTREF(__pyx_slice_);
|
||||||
__Pyx_GIVEREF(__pyx_slice_);
|
__Pyx_GIVEREF(__pyx_slice_);
|
||||||
|
|
||||||
/* "dependency_injector/containers.pyx":338
|
|
||||||
* raise Error('Container {0} is not overridden'.format(cls))
|
|
||||||
*
|
|
||||||
* cls.overridden = cls.overridden[:-1] # <<<<<<<<<<<<<<
|
|
||||||
*
|
|
||||||
* for provider in six.itervalues(cls.providers):
|
|
||||||
*/
|
|
||||||
__pyx_slice_ = PySlice_New(Py_None, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_slice_)) __PYX_ERR(0, 338, __pyx_L1_error)
|
|
||||||
__Pyx_GOTREF(__pyx_slice_);
|
|
||||||
__Pyx_GIVEREF(__pyx_slice_);
|
|
||||||
|
|
||||||
/* "dependency_injector/containers.pyx":365
|
/* "dependency_injector/containers.pyx":365
|
||||||
* :rtype: callable(:py:class:`DeclarativeContainer`)
|
* :rtype: callable(:py:class:`DeclarativeContainer`)
|
||||||
* """
|
* """
|
||||||
|
@ -10876,11 +10868,13 @@ static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
|
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
|
||||||
PyObject *value = PyObject_GetAttrString(spec, from_name);
|
PyObject *value = PyObject_GetAttrString(spec, from_name);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if (likely(value)) {
|
if (likely(value)) {
|
||||||
result = PyDict_SetItemString(moddict, to_name, value);
|
if (allow_none || value != Py_None) {
|
||||||
|
result = PyDict_SetItemString(moddict, to_name, value);
|
||||||
|
}
|
||||||
Py_DECREF(value);
|
Py_DECREF(value);
|
||||||
} else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
} else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
|
@ -10902,10 +10896,10 @@ static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNU
|
||||||
if (unlikely(!module)) goto bad;
|
if (unlikely(!module)) goto bad;
|
||||||
moddict = PyModule_GetDict(module);
|
moddict = PyModule_GetDict(module);
|
||||||
if (unlikely(!moddict)) goto bad;
|
if (unlikely(!moddict)) goto bad;
|
||||||
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
|
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
|
||||||
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
|
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
|
||||||
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
|
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
|
||||||
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
|
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
|
||||||
return module;
|
return module;
|
||||||
bad:
|
bad:
|
||||||
Py_XDECREF(module);
|
Py_XDECREF(module);
|
||||||
|
@ -14608,7 +14602,7 @@ void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
|
||||||
#define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
|
#define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
|
||||||
static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
|
static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
|
||||||
const char *msg;
|
const char *msg;
|
||||||
if (0) {
|
if ((0)) {
|
||||||
#ifdef __Pyx_Coroutine_USED
|
#ifdef __Pyx_Coroutine_USED
|
||||||
} else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
|
} else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
|
||||||
msg = "coroutine already executing";
|
msg = "coroutine already executing";
|
||||||
|
@ -14625,7 +14619,7 @@ static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineOb
|
||||||
#define __Pyx_Coroutine_NotStartedError(gen) (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
|
#define __Pyx_Coroutine_NotStartedError(gen) (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
|
||||||
static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
|
static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
|
||||||
const char *msg;
|
const char *msg;
|
||||||
if (0) {
|
if ((0)) {
|
||||||
#ifdef __Pyx_Coroutine_USED
|
#ifdef __Pyx_Coroutine_USED
|
||||||
} else if (__Pyx_Coroutine_Check(gen)) {
|
} else if (__Pyx_Coroutine_Check(gen)) {
|
||||||
msg = "can't send non-None value to a just-started coroutine";
|
msg = "can't send non-None value to a just-started coroutine";
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2075,4 +2075,19 @@ cpdef str represent_provider(object provider, object provides):
|
||||||
|
|
||||||
cpdef object deepcopy(object instance, dict memo=None):
|
cpdef object deepcopy(object instance, dict memo=None):
|
||||||
"""Return full copy of provider or container with providers."""
|
"""Return full copy of provider or container with providers."""
|
||||||
|
if memo is None:
|
||||||
|
memo = dict()
|
||||||
|
|
||||||
|
__add_sys_streams(memo)
|
||||||
|
|
||||||
return copy.deepcopy(instance, memo)
|
return copy.deepcopy(instance, memo)
|
||||||
|
|
||||||
|
def __add_sys_streams(memo):
|
||||||
|
"""Add system streams to memo dictionary.
|
||||||
|
|
||||||
|
This helps to avoid copying of system streams while making a deepcopy of
|
||||||
|
objects graph.
|
||||||
|
"""
|
||||||
|
memo[id(sys.stdin)] = sys.stdin
|
||||||
|
memo[id(sys.stdout)] = sys.stdout
|
||||||
|
memo[id(sys.stderr)] = sys.stderr
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
"""Dependency injector callable providers unit tests."""
|
"""Dependency injector callable providers unit tests."""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
import unittest2 as unittest
|
import unittest2 as unittest
|
||||||
|
|
||||||
from dependency_injector import (
|
from dependency_injector import (
|
||||||
|
@ -167,6 +169,18 @@ class CallableTests(unittest.TestCase):
|
||||||
self.assertIsNot(object_provider, object_provider_copy)
|
self.assertIsNot(object_provider, object_provider_copy)
|
||||||
self.assertIsInstance(object_provider_copy, providers.Object)
|
self.assertIsInstance(object_provider_copy, providers.Object)
|
||||||
|
|
||||||
|
def test_deepcopy_with_sys_streams(self):
|
||||||
|
provider = providers.Callable(_example)
|
||||||
|
provider.add_args(sys.stdin)
|
||||||
|
provider.add_kwargs(a2=sys.stdout)
|
||||||
|
|
||||||
|
provider_copy = providers.deepcopy(provider)
|
||||||
|
|
||||||
|
self.assertIsNot(provider, provider_copy)
|
||||||
|
self.assertIsInstance(provider_copy, providers.Callable)
|
||||||
|
self.assertIs(provider.args[0], sys.stdin)
|
||||||
|
self.assertIs(provider.kwargs['a2'], sys.stdout)
|
||||||
|
|
||||||
def test_repr(self):
|
def test_repr(self):
|
||||||
provider = providers.Callable(_example)
|
provider = providers.Callable(_example)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
"""Dependency injector factory providers unit tests."""
|
"""Dependency injector factory providers unit tests."""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
import unittest2 as unittest
|
import unittest2 as unittest
|
||||||
|
|
||||||
from dependency_injector import (
|
from dependency_injector import (
|
||||||
|
@ -321,6 +323,20 @@ class FactoryTests(unittest.TestCase):
|
||||||
self.assertIsNot(object_provider, object_provider_copy)
|
self.assertIsNot(object_provider, object_provider_copy)
|
||||||
self.assertIsInstance(object_provider_copy, providers.Object)
|
self.assertIsInstance(object_provider_copy, providers.Object)
|
||||||
|
|
||||||
|
def test_deepcopy_with_sys_streams(self):
|
||||||
|
provider = providers.Factory(Example)
|
||||||
|
provider.add_args(sys.stdin)
|
||||||
|
provider.add_kwargs(a2=sys.stdout)
|
||||||
|
provider.add_attributes(a3=sys.stderr)
|
||||||
|
|
||||||
|
provider_copy = providers.deepcopy(provider)
|
||||||
|
|
||||||
|
self.assertIsNot(provider, provider_copy)
|
||||||
|
self.assertIsInstance(provider_copy, providers.Factory)
|
||||||
|
self.assertIs(provider.args[0], sys.stdin)
|
||||||
|
self.assertIs(provider.kwargs['a2'], sys.stdout)
|
||||||
|
self.assertIs(provider.attributes['a3'], sys.stderr)
|
||||||
|
|
||||||
def test_repr(self):
|
def test_repr(self):
|
||||||
provider = providers.Factory(Example)
|
provider = providers.Factory(Example)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
"""Dependency injector singleton providers unit tests."""
|
"""Dependency injector singleton providers unit tests."""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
import unittest2 as unittest
|
import unittest2 as unittest
|
||||||
|
|
||||||
from dependency_injector import (
|
from dependency_injector import (
|
||||||
|
@ -322,6 +324,20 @@ class _BaseSingletonTestCase(object):
|
||||||
self.assertIsNot(object_provider, object_provider_copy)
|
self.assertIsNot(object_provider, object_provider_copy)
|
||||||
self.assertIsInstance(object_provider_copy, providers.Object)
|
self.assertIsInstance(object_provider_copy, providers.Object)
|
||||||
|
|
||||||
|
def test_deepcopy_with_sys_streams(self):
|
||||||
|
provider = providers.Singleton(Example)
|
||||||
|
provider.add_args(sys.stdin)
|
||||||
|
provider.add_kwargs(a2=sys.stdout)
|
||||||
|
provider.add_attributes(a3=sys.stderr)
|
||||||
|
|
||||||
|
provider_copy = providers.deepcopy(provider)
|
||||||
|
|
||||||
|
self.assertIsNot(provider, provider_copy)
|
||||||
|
self.assertIsInstance(provider_copy, providers.Singleton)
|
||||||
|
self.assertIs(provider.args[0], sys.stdin)
|
||||||
|
self.assertIs(provider.kwargs['a2'], sys.stdout)
|
||||||
|
self.assertIs(provider.attributes['a3'], sys.stderr)
|
||||||
|
|
||||||
def test_reset(self):
|
def test_reset(self):
|
||||||
provider = self.singleton_cls(object)
|
provider = self.singleton_cls(object)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user