cpython icon indicating copy to clipboard operation
cpython copied to clipboard

dis: BUILD_LIST docs incorrectly say count must be > 0

Open frigus02 opened this issue 1 year ago • 1 comments

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?

frigus02 avatar Jul 04 '24 15:07 frigus02

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

Eclips4 avatar Jul 04 '24 19:07 Eclips4