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>
This commit is contained in:
Pablo Galindo 2021-07-02 15:10:11 +01:00 committed by GitHub
parent 943e77d42d
commit 98eee94421
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 7630 additions and 5185 deletions

View file

@ -218,6 +218,8 @@ struct _PyCodeConstructor {
PyObject *code;
int firstlineno;
PyObject *linetable;
PyObject *endlinetable;
PyObject *columntable;
/* used by the code */
PyObject *consts;