mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-05-22 21:46:17 +03:00
Fix copying of Container provider
This commit is contained in:
parent
4829efff71
commit
40e3e4c8cc
File diff suppressed because it is too large
Load Diff
|
@ -2079,6 +2079,30 @@ cdef class List(Provider):
|
||||||
|
|
||||||
cdef class Container(Singleton):
|
cdef class Container(Singleton):
|
||||||
|
|
||||||
|
def __deepcopy__(self, memo):
|
||||||
|
"""Create and return full copy of provider."""
|
||||||
|
cdef Container copied
|
||||||
|
|
||||||
|
copied = memo.get(id(self))
|
||||||
|
if copied is not None:
|
||||||
|
return copied
|
||||||
|
|
||||||
|
cls = self.cls
|
||||||
|
if isinstance(cls, Provider):
|
||||||
|
cls = deepcopy(cls, memo)
|
||||||
|
|
||||||
|
copied = self.__class__(cls,
|
||||||
|
*deepcopy(self.args, memo),
|
||||||
|
**deepcopy(self.kwargs, memo))
|
||||||
|
copied.set_attributes(**deepcopy(self.attributes, memo))
|
||||||
|
|
||||||
|
self._copy_overridings(copied, memo)
|
||||||
|
|
||||||
|
if copied.__storage:
|
||||||
|
copied.__storage = deepcopy(copied.__storage, memo)
|
||||||
|
|
||||||
|
return copied
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
"""Return dependency provider."""
|
"""Return dependency provider."""
|
||||||
if name.startswith('__') and name.endswith('__'):
|
if name.startswith('__') and name.endswith('__'):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user