-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Details
See tests/unit/json_serialize/serializable_dataclass/test_serializable_dataclass.py, test_cyclic_references.
In cases with cyclic references, we should at minimum throw an exception -- in an ideal world, we could have some way of encoding references to an already-serialized object, but this sounds much harder.
This test below reproduces the issue, hanging forever. Currently will be skipped.
def test_cyclic_references():
"""Test handling of cyclic references"""
@serializable_dataclass
class Node(SerializableDataclass):
value: str
next: Optional['Node'] = serializable_field(default=None)
# Create a cycle
node1 = Node("one")
node2 = Node("two")
node1.next = node2
node2.next = node1
# Ensure we can serialize without infinite recursion
serialized = node1.serialize()
loaded = Node.load(serialized)
assert loaded.value == "one"
assert loaded.next.value == "two"
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working