]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-43950: Add code.co_positions (PEP 657) (GH-26955)
authorPablo Galindo <Pablogsal@gmail.com>
Fri, 2 Jul 2021 14:10:11 +0000 (15:10 +0100)
committerGitHub <noreply@github.com>
Fri, 2 Jul 2021 14:10:11 +0000 (15:10 +0100)
commit98eee94421dcb42c15f2d7fc4cd21357722fbe2a
tree45a158d1e97f0b29d24ded80122559b50cc858f5
parent943e77d42d3f84b581f32c05f1fc8c05366b8ed3
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>
15 files changed:
Include/cpython/code.h
Include/internal/pycore_code.h
Lib/ctypes/test/test_values.py
Lib/importlib/_bootstrap_external.py
Lib/test/test_code.py
Lib/test/test_compile.py
Objects/clinic/codeobject.c.h
Objects/codeobject.c
Programs/test_frozenmain.h
Python/compile.c
Python/frozen_hello.h
Python/importlib.h
Python/importlib_external.h
Python/importlib_zipimport.h
Python/marshal.c