summaryrefslogtreecommitdiff
path: root/constructor.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2018-09-26 23:05:03 +0200
committerAnthon van der Neut <anthon@mnt.org>2018-09-26 23:05:03 +0200
commitbce1095295d4a058ed665efde34b22c83b77c8fe (patch)
tree5d16180f55626eff1038df1e91459b90f816fc80 /constructor.py
parent946e383b47a227032e92d432c85568caed8065e2 (diff)
downloadruamel.yaml-bce1095295d4a058ed665efde34b22c83b77c8fe.tar.gz
fix issue #238 construct recursive objects0.15.71
*When this change indeed resolves your problem, please **Close** this issue*. *(You can do so using the WorkFlow pull-down (close to the top right of this page))*
Diffstat (limited to 'constructor.py')
-rw-r--r--constructor.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/constructor.py b/constructor.py
index 6448067..245e9f7 100644
--- a/constructor.py
+++ b/constructor.py
@@ -133,9 +133,10 @@ class BaseConstructor(object):
old_deep = self.deep_construct
self.deep_construct = True
if node in self.recursive_objects:
- raise ConstructorError(
- None, None, 'found unconstructable recursive node', node.start_mark
- )
+ return self.recursive_objects[node]
+ # raise ConstructorError(
+ # None, None, 'found unconstructable recursive node', node.start_mark
+ # )
self.recursive_objects[node] = None
constructor = None # type: Any
tag_suffix = None
@@ -914,9 +915,10 @@ class Constructor(SafeConstructor):
# Format:
# !!python/object:module.name { ... state ... }
instance = self.make_python_instance(suffix, node, newobj=True)
+ self.recursive_objects[node] = instance
yield instance
- # deep = hasattr(instance, '__setstate__')
- state = self.construct_mapping(node, deep=False)
+ deep = hasattr(instance, '__setstate__')
+ state = self.construct_mapping(node, deep=deep)
self.set_python_instance_state(instance, state)
def construct_python_object_apply(self, suffix, node, newobj=False):