summaryrefslogtreecommitdiff
path: root/constructor.py
diff options
context:
space:
mode:
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):