tatsu.ast.AST objects don't pickle/unpickle properly
fizbin opened this issue · comments
Daniel Martin commented
Observe:
>>> from tatsu.ast import AST
>>> a=AST(parseinfo=('Some parseinfo'))
>>> a
{'parseinfo': 'Some parseinfo'}
>>> import pickle
>>> pickle.loads(pickle.dumps(a))
{'parseinfo_': 'Some parseinfo'}
Note that after pickling/unpickling, the AST object is different.
I believe that this can be fixed by changing __reduce__
to:
def __reduce__(self):
return (AST, (list(self.items()),))
Juancarlo Añez commented