Ticket #147 (closed defect: fixed)
Loader and Dumper leave circular references around
|Reported by:||kristjan@…||Owned by:||xi|
In an environment where the gc module is turned off, having circular references is evil. When yaml.Loader and yaml.Dumper have finished processing a stream, they leave a bound method in their .state attribute. This causes the loaders and dumpers to stick around. We have patched this locally by doing, for example:
dumper=Dumper() dumper.open() try: for data in documents: dumper.represent(data) dumper.close() finally: dumpter.state = dumper.states = None
Maybe there is a better way. Perhaps the Dumper and Loader should both have close() methods that clear the state. Another way would be to not keep instancemethods in state, but rather class methods and bind them to self at runtime.