Modify

Ticket #147 (closed defect: fixed)

Opened 4 years ago

Last modified 3 years 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

comment:1 Changed 3 years ago by xi

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in [377].

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


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

 
Note: See TracTickets for help on using tickets.