From 6f2dabd8b06575eff8fa2db291d2022b71f7cfcd Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Sun, 4 Aug 2024 12:01:02 +0100 Subject: [PATCH 1/2] gh-121367: [doc] BUILD_TUPLE arg can be 0 --- Doc/library/dis.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 26b13c87181000..11d64d1ef0c1de 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1083,9 +1083,13 @@ iterations of the loop. 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)) + if count == 0: + value = () + else: + STACK = STACK[:-count] + value = tuple(STACK[-count:]) + + STACK.append(value) .. opcode:: BUILD_LIST (count) From 74c24ee0a7a72a9288daf7f7c35ec1f34bd9ad27 Mon Sep 17 00:00:00 2001 From: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Date: Sun, 4 Aug 2024 14:04:41 +0100 Subject: [PATCH 2/2] Update Doc/library/dis.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- Doc/library/dis.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 11d64d1ef0c1de..440ca233584e57 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1081,7 +1081,7 @@ 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:: if count == 0: value = ()