In 3.12 findlinestarts seems to return None for line more often (#1721)

This commit is contained in:
Rich Chiodo 2024-11-04 11:19:37 -08:00 committed by GitHub
parent 6a7f7c0f2d
commit 740fa9dd5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 4 deletions

View file

@ -83,7 +83,8 @@ else:
# bodies of nested class and function definitions, as they have their
# own objects.
for _, lineno in dis.findlinestarts(code):
yield lineno
if lineno is not None:
yield lineno
# For nested class and function definitions, their respective code objects
# are constants referenced by this object.

View file

@ -59,7 +59,8 @@ def _get_code_line_info(code_obj):
last_line = None
for offset, line in dis.findlinestarts(code_obj):
line_to_offset[line] = offset
if line is not None and offset is not None:
line_to_offset[line] = offset
if line_to_offset:
first_line = min(line_to_offset)

View file

@ -791,10 +791,10 @@ class PyDB(object):
max_line = -1
min_line = sys.maxsize
for _, line in dis.findlinestarts(code_obj):
if line > max_line:
if line is not None and line > max_line:
max_line = line
if line < min_line:
if line is not None and line < min_line:
min_line = line
try_except_infos = [x for x in try_except_infos if min_line <= x.try_line <= max_line]