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

Make annotations less fragile #60

Open
mdickinson opened this issue Dec 20, 2016 · 3 comments
Open

Make annotations less fragile #60

mdickinson opened this issue Dec 20, 2016 · 3 comments

Comments

@mdickinson
Copy link
Owner

The annotations code is somewhat fragile: it makes assumptions that are often violated by real-world code (for example, that every bound method in Python 2 will have a non-None im_class attribute, or that every function will have a __name__ attribute).

It would probably be worth doing an except Exception around each annotation, logging any exceptions, and continuing.

@VojtechFried
Copy link

One more thing to consider: expired weakrefs. E.g.
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

@mdickinson
Copy link
Owner Author

Nice catch; thanks. Do you happen to have a short snippet that reproduces (and that I can turn into a testcase)?

@mdickinson
Copy link
Owner Author

Opened #78 for the bug reported by @VojtechFried.

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

No branches or pull requests

2 participants