]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-121367: [doc] BUILD_TUPLE arg can be 0 (#122663)
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>
Mon, 5 Aug 2024 09:17:55 +0000 (10:17 +0100)
committerGitHub <noreply@github.com>
Mon, 5 Aug 2024 09:17:55 +0000 (10:17 +0100)
Doc/library/dis.rst

index 26b13c8718100034c915128cc109f7194ee794f0..440ca233584e57b81f1fb8c9c0a08cce9d095e1c 100644 (file)
@@ -1081,11 +1081,15 @@ iterations of the loop.
 .. opcode:: BUILD_TUPLE (count)
 
    Creates a tuple consuming *count* items from the stack, and pushes the
-   resulting tuple onto the stack.::
+   resulting tuple onto the stack::
 
-      assert count > 0
-      STACK, values = STACK[:-count], STACK[-count:]
-      STACK.append(tuple(values))
+      if count == 0:
+          value = ()
+      else:
+          STACK = STACK[:-count]
+          value = tuple(STACK[-count:])
+
+      STACK.append(value)
 
 
 .. opcode:: BUILD_LIST (count)