From a562f3a893ebd6662e23cc54f5120b6257cb090e Mon Sep 17 00:00:00 2001 From: Christopher Chianelli Date: Mon, 8 Aug 2022 13:24:13 -0400 Subject: [PATCH 1/2] Update dis documentation to include changes to jump arguments Since 3.10, the instruction offset is used instead of the byte offset. Thus, for jump instructions, the argument is half of what it would of been in 3.9. For instance, this code: def test(x): return 1 if x else 0 in 3.9 disassembles into 4 0 LOAD_FAST 0 (x) 2 POP_JUMP_IF_FALSE 8 4 LOAD_CONST 1 (1) 6 RETURN_VALUE >> 8 LOAD_CONST 2 (0) 10 RETURN_VALUE but in 3.10 disassembles into 4 0 LOAD_FAST 0 (x) 2 POP_JUMP_IF_FALSE 4 (to 8) 4 LOAD_CONST 1 (1) 6 RETURN_VALUE >> 8 LOAD_CONST 2 (0) 10 RETURN_VALUE --- Doc/library/dis.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 63b064e7b444ec..302684070769e5 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -30,6 +30,11 @@ interpreter. Use 2 bytes for each instruction. Previously the number of bytes varied by instruction. + .. versionchanged:: 3.10 + The argument for instructions that have a jump now use the instruction + offset instead of the byte offset. Because each instruction take two + bytes, the instruction offset is exactly half of the byte offset. + .. versionchanged:: 3.11 Some instructions are accompanied by one or more inline cache entries, which take the form of :opcode:`CACHE` instructions. These instructions From 7feb0ba38933b9dacbe8a8db23d81ae181cf42ff Mon Sep 17 00:00:00 2001 From: Christopher Chianelli Date: Fri, 7 Oct 2022 09:33:52 -0400 Subject: [PATCH 2/2] Rephase 3.10 dis changelog for changes to jump arguments --- Doc/library/dis.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 302684070769e5..d101f3d14132d3 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -31,9 +31,8 @@ interpreter. by instruction. .. versionchanged:: 3.10 - The argument for instructions that have a jump now use the instruction - offset instead of the byte offset. Because each instruction take two - bytes, the instruction offset is exactly half of the byte offset. + The argument of jump, exception handling and loop instructions is now + the instruction offset rather than the byte offset. .. versionchanged:: 3.11 Some instructions are accompanied by one or more inline cache entries,