From 51e7616d4a4bf899ab3ce84bb919dd3906792856 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Mon, 13 Mar 2017 01:13:57 +0100 Subject: [PATCH 1/7] Document remaining bytecode changes in 3.6 --- Doc/library/dis.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index d37f76fc74ca58..d8f4db45b7a2b2 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -210,6 +210,13 @@ operation is being performed, so the intermediate analysis object isn't useful: This generator function uses the ``co_firstlineno`` and ``co_lnotab`` attributes of the code object *code* to find the offsets which are starts of lines in the source code. They are generated as ``(offset, lineno)`` pairs. + Functions decoding directly ``co_lnotab`` should use a signed + 8-bit integer type for the line number delta. See + ``Objects/lnotab_notes.txt`` for the ``co_lnotab`` format and how to decode + it. + + .. versionchanged:: 3.6 + Added support for negative line number delta. .. function:: findlabels(code) @@ -280,6 +287,7 @@ details of bytecode instructions as :class:`Instruction` instances: The Python compiler currently generates the following bytecode instructions. +Every instruction takes 2 bytes. **General instructions** From 1b1034d26d7ace1f68e8f61b82b371d0931db9a3 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Mon, 13 Mar 2017 09:27:29 +0100 Subject: [PATCH 2/7] Response to Serhiy's review --- Doc/library/dis.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index d8f4db45b7a2b2..d44bee4cc33b11 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -20,6 +20,9 @@ interpreter. between versions of Python. Use of this module should not be considered to work across Python VMs or Python releases. + .. versionchanged:: 3.6 + Use fixed 2 bytes per instruction for all instructions. + Example: Given the function :func:`myfunc`:: @@ -210,10 +213,8 @@ operation is being performed, so the intermediate analysis object isn't useful: This generator function uses the ``co_firstlineno`` and ``co_lnotab`` attributes of the code object *code* to find the offsets which are starts of lines in the source code. They are generated as ``(offset, lineno)`` pairs. - Functions decoding directly ``co_lnotab`` should use a signed - 8-bit integer type for the line number delta. See - ``Objects/lnotab_notes.txt`` for the ``co_lnotab`` format and how to decode - it. + See ``Objects/lnotab_notes.txt`` for the ``co_lnotab`` format and how to + decode it. .. versionchanged:: 3.6 Added support for negative line number delta. @@ -287,7 +288,6 @@ details of bytecode instructions as :class:`Instruction` instances: The Python compiler currently generates the following bytecode instructions. -Every instruction takes 2 bytes. **General instructions** From d72667326caab6dc511c8cd16eb4c921b9726080 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Mon, 13 Mar 2017 12:18:46 +0100 Subject: [PATCH 3/7] Add link to source --- Doc/library/dis.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index d44bee4cc33b11..dbc7c7b3d02c87 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -213,8 +213,8 @@ operation is being performed, so the intermediate analysis object isn't useful: This generator function uses the ``co_firstlineno`` and ``co_lnotab`` attributes of the code object *code* to find the offsets which are starts of lines in the source code. They are generated as ``(offset, lineno)`` pairs. - See ``Objects/lnotab_notes.txt`` for the ``co_lnotab`` format and how to - decode it. + See :source:`Objects/lnotab_notes.txt` for the ``co_lnotab`` format and + how to decode it. .. versionchanged:: 3.6 Added support for negative line number delta. From f1e17fcabe043a641e8d5fcb86eaf17c185f5eea Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Tue, 14 Mar 2017 08:27:38 +0100 Subject: [PATCH 4/7] Response to comments --- Doc/library/dis.rst | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index d44bee4cc33b11..212c63ff304e6a 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -21,7 +21,8 @@ interpreter. work across Python VMs or Python releases. .. versionchanged:: 3.6 - Use fixed 2 bytes per instruction for all instructions. + Use fixed 2 bytes per instruction for all instructions. Instructions + of variable length were used before. Example: Given the function :func:`myfunc`:: @@ -217,7 +218,7 @@ operation is being performed, so the intermediate analysis object isn't useful: decode it. .. versionchanged:: 3.6 - Added support for negative line number delta. + Line numbers can be not monotonically increasing. .. function:: findlabels(code) @@ -1135,8 +1136,13 @@ All of the following opcodes use their arguments. .. opcode:: HAVE_ARGUMENT This is not really an opcode. It identifies the dividing line between - opcodes which don't take arguments ``< HAVE_ARGUMENT`` and those which do - ``>= HAVE_ARGUMENT``. + opcodes which don't use their arguments ``< HAVE_ARGUMENT`` and + those which do ``>= HAVE_ARGUMENT``. + + .. versionchanged:: 3.6 + Now every instruction have an argument, but opcodes ``< HAVE_ARGUMENT`` + ignore it. Before, only opcodes ``>= HAVE_ARGUMENT`` had an argument. + .. _opcode_collections: From 4ebbc2a2fd15db7155be8e1392b2ba5177ddc839 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Tue, 14 Mar 2017 20:29:40 +0100 Subject: [PATCH 5/7] Avoid 'non monotonically' --- 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 1c3b26ebc2780e..8531815298fd7e 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -218,7 +218,7 @@ operation is being performed, so the intermediate analysis object isn't useful: how to decode it. .. versionchanged:: 3.6 - Line numbers can be not monotonically increasing. + Line numbers can be decreasing. Before, they were always increasing. .. function:: findlabels(code) From 400b114eacc6969338cfdcb9c3bead654fef0611 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Sat, 18 Mar 2017 03:25:25 +0100 Subject: [PATCH 6/7] Response to comments --- Doc/library/dis.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 8531815298fd7e..065b91cf235aee 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -21,8 +21,8 @@ interpreter. work across Python VMs or Python releases. .. versionchanged:: 3.6 - Use fixed 2 bytes per instruction for all instructions. Instructions - of variable length were used before. + Use 2 bytes for each instruction. Previously the number of bytes varied + by instruction. Example: Given the function :func:`myfunc`:: @@ -1140,7 +1140,7 @@ All of the following opcodes use their arguments. those which do ``>= HAVE_ARGUMENT``. .. versionchanged:: 3.6 - Now every instruction have an argument, but opcodes ``< HAVE_ARGUMENT`` + Now every instruction has an argument, but opcodes ``< HAVE_ARGUMENT`` ignore it. Before, only opcodes ``>= HAVE_ARGUMENT`` had an argument. From b1034c08eaeb6f8d4c2c818418b0dee80dbe90f2 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 24 Mar 2017 13:31:10 -0700 Subject: [PATCH 7/7] Make a sentence easier to read --- Doc/library/dis.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 065b91cf235aee..f82dc40e0931fe 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1136,8 +1136,8 @@ All of the following opcodes use their arguments. .. opcode:: HAVE_ARGUMENT This is not really an opcode. It identifies the dividing line between - opcodes which don't use their arguments ``< HAVE_ARGUMENT`` and - those which do ``>= HAVE_ARGUMENT``. + opcodes which don't use their argument and those that do + (``< HAVE_ARGUMENT`` and ``>= HAVE_ARGUMENT``, respectively). .. versionchanged:: 3.6 Now every instruction has an argument, but opcodes ``< HAVE_ARGUMENT``