Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expired weak references can cause annotation to fail. #78

Open
mdickinson opened this issue Jul 25, 2017 · 2 comments
Open

Expired weak references can cause annotation to fail. #78

mdickinson opened this issue Jul 25, 2017 · 2 comments
Labels

Comments

@mdickinson
Copy link
Owner

Broken out from the issue 60 discussion: see #60 (comment)

File "C:\Python36\lib\site-packages\refcycle\object_graph.py", line 339, in export_json
self.annotated().export_json(filename=filename)
File "C:\Python36\lib\site-packages\refcycle\object_graph.py", line 279, in annotated
for vertex in self.vertices
File "C:\Python36\lib\site-packages\refcycle\object_graph.py", line 279, in 
for vertex in self.vertices
File "C:\Python36\lib\site-packages\refcycle\annotations.py", line 172, in object_annotation
if isinstance(obj, BASE_TYPES):
ReferenceError: weakly-referenced object no longer exists
@VojtechFried
Copy link

VojtechFried commented Jul 25, 2017

This should trigger the bug:

import gc
import refcycle
import weakref

class Item:
  def __init__( self ):
    self.text = "item"

class Cycle:
  def __init__( self, item ):
    self.self = self
    self.item = weakref.proxy( item )

def create_cycle():
  item = Item()
  return Cycle( item )

def main():
  gc.disable()
  gc.collect()
  create_cycle()
  garbage = refcycle.garbage()
  garbage.export_image()

if __name__ == '__main__':
    main()

@mdickinson
Copy link
Owner Author

@VojtechFried: Confirmed. Much appreciated - thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants