Message365367
The documentation of dis.findlabels says:
> dis.findlabels(code)
> Detect all offsets in the code object code which are jump targets, and return a list of these offsets.
But the implementation actually expects a raw compiled bytecode.
>>> def f():pass
>>> dis.findlabels(f.__code__)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/laike9m/.pyenv/versions/3.7.4/lib/python3.7/dis.py", line 424, in findlabels
for offset, op, arg in _unpack_opargs(code):
File "/Users/laike9m/.pyenv/versions/3.7.4/lib/python3.7/dis.py", line 408, in _unpack_opargs
for i in range(0, len(code), 2):
TypeError: object of type 'code' has no len()
>>> dis.findlabels(f.__code__.co_code)
[]
Since the other functions in the dis module all accept a code object rather than compiled code, I would suggest change the code instead of documentation.
Plus, this function does not seem to be tested anywhere. I can make a PR if this issue is confirmed. |
|
Date |
User |
Action |
Args |
2020-03-31 06:33:39 | laike9m | set | recipients:
+ laike9m, serhiy.storchaka |
2020-03-31 06:33:39 | laike9m | set | messageid: <1585636419.17.0.745722185034.issue40122@roundup.psfhosted.org> |
2020-03-31 06:33:39 | laike9m | link | issue40122 messages |
2020-03-31 06:33:38 | laike9m | create | |
|