cpython
cpython copied to clipboard
dis: BUILD_LIST docs incorrectly say count must be > 0
Documentation
The dis module docs for BUILD_LIST (and BUILD_SET and BUILD_TUPLE) say that the count argument must be > 0:
https://github.com/python/cpython/blob/17d5b9df10f53ae3c09c8b22f27d25d9e83b4b7e/Doc/library/dis.rst?plain=1#L1081-L1098
But the code [] generates the instruction BUILD_LIST 0. godbolt repro
I assume either the docs are meant to say assert count >= 0 or maybe the assert is only valid for BUILD_TUPLE?
Hello! Thanks for the report. https://github.com/python/cpython/pull/96462#discussion_r1068267879 says that count should not be zero, but actually it can:
dis.dis("[]")
>>> dis.dis('[]')
0 RESUME 0
1 BUILD_LIST 0
RETURN_VALUE
>>>
cc @markshannon