Skip to content

Commit

Permalink
Clear __dict__ to break some cycles.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Koval authored and es92 committed Nov 21, 2014
1 parent 44afbe6 commit d9dd207
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/prpy/bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ def get_storage_methods(cls, target):
# the environment.
def cleanup_callback(owner, flag):
if flag == 0: # removed
# Clear any attributes that the user might have bound to
# the object. This is necessary to clear cycles.
canonical_instance = InstanceDeduplicator.get_canonical(owner)
if canonical_instance is not None:
canonical_dict = object.__getattribute__(canonical_instance, '__dict__')
canonical_dict.clear()

# Remove any storage (e.g. canonical_instance) bound to
# this object.
cls.remove_storage(owner)

if hasattr(env, 'RegisterBodyCallback'):
Expand Down

0 comments on commit d9dd207

Please sign in to comment.