Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions refcycle/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,14 @@ def add_frame_references(obj, references):
add_attr(obj, "f_trace", references)
# The f_locals dictionary is only created on demand,
# and then cached.
f_locals = obj.f_locals
add_attr(obj, "f_locals", references)
for name, local in six.iteritems(obj.f_locals):
references[local].append("local {!r}".format(name))
# Some badly-behaved code replaces the f_locals dict with
# something that doesn't support the full dict interface. So we
# only continue with the annotation if f_locals is a Python dict.
if type(f_locals) is dict:
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops; this change wasn't intended to be included in this PR.

for name, local in six.iteritems(obj.f_locals):
references[local].append("local {!r}".format(name))


def add_getset_descriptor_references(obj, references):
Expand Down Expand Up @@ -200,7 +205,7 @@ def object_annotation(obj):
filename = "..." + filename[-(FRAME_FILENAME_LIMIT-3):]
return "frame\\n{}:{}".format(
filename,
obj.f_code.co_firstlineno,
obj.f_lineno,
)
else:
return "object\\n{}.{}".format(
Expand Down