Ticket #147 (closed defect: fixed)

Opened 2 years ago

Last modified 12 months ago

Loader and Dumper leave circular references around

Reported by: kristjan@… Owned by: xi
Priority: normal Component: pyyaml
Severity: normal Keywords:
Cc:

Description

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.

Attachments

Change History

Changed 12 months ago by xi

  • status changed from new to closed
  • resolution set to fixed

Fixed in [377].

Add/Change #147 (Loader and Dumper leave circular references around)

Author


E-mail address and user name can be saved in the Preferences.


Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.