summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2019-06-23 11:21:11 +0200
committerAnthon van der Neut <anthon@mnt.org>2019-06-23 11:21:11 +0200
commitcb9093c01168221da65f69f91b2c81bc15c471dd (patch)
tree5d89377c1443f2f7cd6861a506e6f65a2bc69fe5
parent58475225b355c32a11c684f46c3711acb89ff713 (diff)
downloadruamel.yaml-cb9093c01168221da65f69f91b2c81bc15c471dd.tar.gz
pass memo on to deepcopy
-rw-r--r--comments.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/comments.py b/comments.py
index 7f3f2d4..063f1c2 100644
--- a/comments.py
+++ b/comments.py
@@ -336,6 +336,7 @@ class CommentedBase(object):
def yaml_set_anchor(self, value, always_dump=False):
# type: (Any, bool) -> None
+ print('xxxxx')
self.anchor.value = value
self.anchor.always_dump = always_dump
@@ -350,14 +351,14 @@ class CommentedBase(object):
# type: (Any) -> None
self.tag.value = value
- def copy_attributes(self, t, deep=False):
+ def copy_attributes(self, t, memo=None):
# type: (Any, bool) -> None
# fmt: off
for a in [Comment.attrib, Format.attrib, LineCol.attrib, Anchor.attrib,
Tag.attrib, merge_attrib]:
if hasattr(self, a):
- if deep:
- setattr(t, a, copy.deepcopy(getattr(self, a)))
+ if memo is not None:
+ setattr(t, a, copy.deepcopy(getattr(self, a, memo)))
else:
setattr(t, a, getattr(self, a))
# fmt: on
@@ -478,8 +479,8 @@ class CommentedSeq(MutableSliceableSequence, list, CommentedBase): # type: igno
res = self.__class__()
memo[id(self)] = res
for k in self:
- res.append(copy.deepcopy(k))
- self.copy_attributes(res, deep=True)
+ res.append(copy.deepcopy(k, memo))
+ self.copy_attributes(res, memo=memo)
return res
def __add__(self, other):
@@ -949,8 +950,8 @@ class CommentedMap(ordereddict, CommentedBase):
res = self.__class__()
memo[id(self)] = res
for k in self:
- res[k] = copy.deepcopy(self[k])
- self.copy_attributes(res, deep=True)
+ res[k] = copy.deepcopy(self[k], memo)
+ self.copy_attributes(res, memo=memo)
return res