summaryrefslogtreecommitdiff
path: root/Lib/importlib/_bootstrap_external.py
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2021-07-02 15:10:11 +0100
committerGitHub <noreply@github.com>2021-07-02 15:10:11 +0100
commit98eee94421dcb42c15f2d7fc4cd21357722fbe2a (patch)
tree45a158d1e97f0b29d24ded80122559b50cc858f5 /Lib/importlib/_bootstrap_external.py
parent943e77d42d3f84b581f32c05f1fc8c05366b8ed3 (diff)
downloadcpython-git-98eee94421dcb42c15f2d7fc4cd21357722fbe2a.tar.gz
bpo-43950: Add code.co_positions (PEP 657) (GH-26955)
This PR is part of PEP 657 and augments the compiler to emit ending line numbers as well as starting and ending columns from the AST into compiled code objects. This allows bytecodes to be correlated to the exact source code ranges that generated them. This information is made available through the following public APIs: * The `co_positions` method on code objects. * The C API function `PyCode_Addr2Location`. Co-authored-by: Batuhan Taskaya <isidentical@gmail.com> Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
Diffstat (limited to 'Lib/importlib/_bootstrap_external.py')
-rw-r--r--Lib/importlib/_bootstrap_external.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index c3ce4703a2..21449cb415 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -361,6 +361,7 @@ _code_type = type(_write_atomic.__code__)
# Python 3.11a1 3456 (interleave cell args bpo-43693)
# Python 3.11a1 3457 (Change localsplus to a bytes object bpo-43693)
# Python 3.11a1 3458 (imported objects now don't use LOAD_METHOD/CALL_METHOD)
+# Python 3.11a1 3459 (PEP 657: add end line numbers and column offsets for instructions)
#
# MAGIC must change whenever the bytecode emitted by the compiler may no
@@ -370,7 +371,7 @@ _code_type = type(_write_atomic.__code__)
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
# in PC/launcher.c must also be updated.
-MAGIC_NUMBER = (3458).to_bytes(2, 'little') + b'\r\n'
+MAGIC_NUMBER = (3459).to_bytes(2, 'little') + b'\r\n'
_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c
_PYCACHE = '__pycache__'