]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Document PyCode_Addr2Line function. (GH-25111)
authorMark Shannon <mark@hotpy.org>
Fri, 2 Apr 2021 12:24:57 +0000 (13:24 +0100)
committerGitHub <noreply@github.com>
Fri, 2 Apr 2021 12:24:57 +0000 (13:24 +0100)
* Document PyCode_Addr2Line function.

* Clarify when to use PEP 626 line iterators.

Doc/c-api/code.rst

index b3a17f1898e8e19974741b4f10c1b1a235d0fa54..6e18a4225e8f4335d4d739a0537758cd3adefbaa 100644 (file)
@@ -51,3 +51,11 @@ bound into a function.
    Return a new empty code object with the specified filename,
    function name, and first line number.  It is illegal to
    :func:`exec` or :func:`eval` the resulting code object.
+
+.. c:function:: int PyCode_Addr2Line(PyCodeObject *co, int byte_offset)
+
+    Return the line number of the instruction that occurs on or before ``byte_offset`` and ends after it.
+    If you just need the line number of a frame, use :c:func:`PyFrame_GetLineNumber` instead.
+
+    For efficiently iterating over the line numbers in a code object, use `the API described in PEP 626
+    <https://www.python.org/dev/peps/pep-0626/#out-of-process-debuggers-and-profilers>`_.