New submission from Yurii Karabas <[email protected]>:
`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
```
----------
components: Library (Lib)
messages: 382453
nosy: uriyyo
priority: normal
severity: normal
status: open
title: dis failed to parse function that has only annotations
type: behavior
versions: Python 3.10
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue42562>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com