Using dict subclass -> ConstructorError: found unconstructable recursive node

Issue #52 new
Fabiano Sidler
created an issue

Using a dict subclass, objects can be dump()ed but not load()ed again:

# setup
from yaml import dump, load

class Mother(object):
  def __init__(self, name):
    self.name = name
    self.children = {}
class Child(object):
  def __init__(self, name, mother):
    self.mother = mother
class Subdict(dict): pass

babs = Mother('babs')
babs.children['dj'] = Child('Deejay', babs)
babs.children['jess'] = Child('Jessica', babs)
mothers1 = {'mothers':{'babs':babs}}
mothers2 = {'mothers':Subdict((('babs',babs),))


# this works
load(dump(mothers1))


# this doesn't: ConstructorError: found unconstructable recursive node
load(dump(mothers2))

Comments (0)

  1. Log in to comment