Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
2 changes: 1 addition & 1 deletion Lib/dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def _disassemble_bytes(code, lasti=-1, varnames=None, names=None,
constants=None, cells=None, linestarts=None,
*, file=None, line_offset=0):
# Omit the line number column entirely if we have no line number info
show_lineno = linestarts is not None
show_lineno = bool(linestarts)
if show_lineno:
maxlineno = max(linestarts.values()) + line_offset
if maxlineno >= 1000:
Expand Down
16 changes: 16 additions & 0 deletions Lib/test/test_dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,19 @@ def bug1333982(x=[]):
bug1333982.__code__.co_firstlineno + 2,
bug1333982.__code__.co_firstlineno + 1)


def bug42562():
pass


bug42562.__code__ = bug42562.__code__.replace(co_linetable=b'\x04\x80\xff\x80')


dis_bug42562 = """\
0 LOAD_CONST 0 (None)
2 RETURN_VALUE
"""

_BIG_LINENO_FORMAT = """\
%3d 0 LOAD_GLOBAL 0 (spam)
2 POP_TOP
Expand Down Expand Up @@ -520,6 +533,9 @@ def test_bug_1333982(self):

self.do_disassembly_test(bug1333982, dis_bug1333982)

def test_bug_42562(self):
self.do_disassembly_test(bug42562, dis_bug42562)

def test_big_linenos(self):
def func(count):
namespace = {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix issue when dis failed to parse function that has only annotations. Patch
provided by Yurii Karabas.