Author uriyyo
Recipients uriyyo
Date 2020-12-03.20:38:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1607027897.93.0.00454445674539.issue42562@roundup.psfhosted.org>
In-reply-to
Content
`dis` module failed when trying to parse function that has only annotations at the function body:
```
def foo():
    a: int
```

Failed with stacktrace:
```
  1           0 LOAD_CONST               0 (<code object foo at 0x10847ebe0, file "test.py", line 1>)
              2 LOAD_CONST               1 ('foo')
              4 MAKE_FUNCTION            0
              6 STORE_NAME               0 (foo)
              8 LOAD_CONST               2 (None)
             10 RETURN_VALUE

Disassembly of <code object foo at 0x10847ebe0, file "test.py", line 1>:
Traceback (most recent call last):
  File "/Users/yuriikarabas/my-projects/temp-cpython/Lib/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/yuriikarabas/my-projects/temp-cpython/Lib/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/yuriikarabas/my-projects/temp-cpython/Lib/dis.py", line 536, in <module>
    _test()
  File "/Users/yuriikarabas/my-projects/temp-cpython/Lib/dis.py", line 533, in _test
    dis(code)
  File "/Users/yuriikarabas/my-projects/temp-cpython/Lib/dis.py", line 79, in dis
    _disassemble_recursive(x, file=file, depth=depth)
  File "/Users/yuriikarabas/my-projects/temp-cpython/Lib/dis.py", line 381, in _disassemble_recursive
    _disassemble_recursive(x, file=file, depth=depth)
  File "/Users/yuriikarabas/my-projects/temp-cpython/Lib/dis.py", line 373, in _disassemble_recursive
    disassemble(co, file=file)
  File "/Users/yuriikarabas/my-projects/temp-cpython/Lib/dis.py", line 369, in disassemble
    _disassemble_bytes(co.co_code, lasti, co.co_varnames, co.co_names,
  File "/Users/yuriikarabas/my-projects/temp-cpython/Lib/dis.py", line 389, in _disassemble_bytes
    maxlineno = max(linestarts.values()) + line_offset
ValueError: max() arg is an empty sequence
```
History
Date User Action Args
2020-12-03 20:38:17uriyyosetrecipients: + uriyyo
2020-12-03 20:38:17uriyyosetmessageid: <1607027897.93.0.00454445674539.issue42562@roundup.psfhosted.org>
2020-12-03 20:38:17uriyyolinkissue42562 messages
2020-12-03 20:38:17uriyyocreate