Skip to content

dis: BUILD_LIST docs incorrectly say count must be > 0 #121367

Closed
@frigus02

Description

@frigus02

Documentation

The dis module docs for BUILD_LIST (and BUILD_SET and BUILD_TUPLE) say that the count argument must be > 0:

cpython/Doc/library/dis.rst

Lines 1081 to 1098 in 17d5b9d

.. opcode:: BUILD_TUPLE (count)
Creates a tuple consuming *count* items from the stack, and pushes the
resulting tuple onto the stack.::
assert count > 0
STACK, values = STACK[:-count], STACK[-count:]
STACK.append(tuple(values))
.. opcode:: BUILD_LIST (count)
Works as :opcode:`BUILD_TUPLE`, but creates a list.
.. opcode:: BUILD_SET (count)
Works as :opcode:`BUILD_TUPLE`, but creates a set.

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?

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesdocsDocumentation in the Doc dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions