Fix copying of Container provider

This commit is contained in:
Roman Mogylatov 2020-06-21 00:29:17 -04:00
parent 4829efff71
commit 40e3e4c8cc
2 changed files with 776 additions and 386 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2079,6 +2079,30 @@ cdef class List(Provider):
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):
"""Return dependency provider."""
if name.startswith('__') and name.endswith('__'):