Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
Add comment explaining how get_code_lines() works.
Browse files Browse the repository at this point in the history
  • Loading branch information
int19h committed Feb 15, 2019
1 parent 93225fd commit e64430a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ptvsd/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,14 @@ def get_code_lines(code):
return None
else:
def get_code_lines(code):
# First, get all line starts for this code object. This does not include
# bodies of nested class and function definitions, as they have their
# own objects.
for _, lineno in dis.findlinestarts(code):
yield lineno

# For nested class and function definitions, their respective code objects
# are constants referenced by this object.
for const in code.co_consts:
if isinstance(const, types.CodeType) and const.co_filename == code.co_filename:
for lineno in get_code_lines(const):
Expand Down

0 comments on commit e64430a

Please sign in to comment.