提交 ebddcf3f authored 作者: Frederic's avatar Frederic

Fix the new deep copy. I was not passing and using correctly the memo.

上级 25ef10c8
......@@ -319,18 +319,23 @@ class Container(object):
return "<" + repr(self.storage[0]) + ">"
def __deepcopy__(self, memo):
data_was_in_memo = id(self.storage[0]) in memo
r = type(self)(
deepcopy(self.type, memo),
deepcopy(self.storage),
deepcopy(self.readonly),
deepcopy(self.strict),
deepcopy(self.allow_downcast),
deepcopy(self.storage, memo=memo),
deepcopy(self.readonly, memo=memo),
deepcopy(self.strict, memo=memo),
deepcopy(self.allow_downcast, memo=memo),
deepcopy(self.name, memo),
)
# To force the call to filter. This is a work around NumPy
# deepcopy of ndarray with 0 dimention that don't return an
# ndarray.
r.data = r.data
# Work around NumPy deepcopy of ndarray with 0 dimention that
# don't return an ndarray.
if (r.storage[0] is not None and
not self.type.is_valid_value(r.storage[0])):
assert not data_was_in_memo
r.data = r.storage[0]
memo[id(self.storage[0])] = r.storage[0]
return r
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论