niolabs / safepickle

Provides an alternative to using Python's unsafe pickle module
Apache License 2.0
1 stars 1 forks source link

Nested defaultdicts do not load correctly #11

Open shadetree01010100 opened 6 years ago

shadetree01010100 commented 6 years ago

py 3.6, safepickle 0.2.0

>>> def newdd():
...     return defaultdict(list)
...
>>> foo=defaultdict(newdd)
>>> foo['bar']['baz'] = 'w00t'
>>> pickle.loads(pickle.dumps(foo))
defaultdict(<function newdd at 0x000000000291C158>, {'bar': defaultdict(<class 'list'>, {'baz': 'w00t'})})
>>> safepickle.loads(safepickle.dumps(foo))
defaultdict(None, {'bar': defaultdict(<class 'list'>, {'baz': 'w00t'})})