]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-44964: Add a note explaining the new semantics of f_last_i in frame objects ...
authorPablo Galindo Salgado <Pablogsal@gmail.com>
Tue, 7 Sep 2021 11:18:54 +0000 (12:18 +0100)
committerGitHub <noreply@github.com>
Tue, 7 Sep 2021 11:18:54 +0000 (12:18 +0100)
Doc/reference/datamodel.rst
Doc/whatsnew/3.10.rst

index 2c76e5656b0e63718712a559e80286ef783ddb26..46d9c3a95473cf11209ec67459e8cebfbacd8267 100644 (file)
@@ -1069,8 +1069,9 @@ Internal types
       :attr:`f_code` is the code object being executed in this frame; :attr:`f_locals`
       is the dictionary used to look up local variables; :attr:`f_globals` is used for
       global variables; :attr:`f_builtins` is used for built-in (intrinsic) names;
-      :attr:`f_lasti` gives the precise instruction (this is an index into the
-      bytecode string of the code object).
+      :attr:`f_lasti` gives the precise instruction (it represents a wordcode index, which
+      means that to get an index into the bytecode string of the code object it needs to be
+      multiplied by 2).
 
       Accessing ``f_code`` raises an :ref:`auditing event <auditing>`
       ``object.__getattr__`` with arguments ``obj`` and ``"f_code"``.
index 19ef629b45f486ae027d01d8b231fa0018f44c67..8b0d38b598706d4a5dccf5e525e7d4c54c02bfda 100644 (file)
@@ -1948,6 +1948,12 @@ Changes in the C API
        source_buf = PyBytes_AsString(source_bytes_object);
        code = Py_CompileString(source_buf, filename, Py_file_input);
 
+  * For ``FrameObject`` objects, the ``f_lasti`` member now represents a wordcode
+    offset instead of a simple offset into the bytecode string. This means that this
+    number needs to be multiplied by 2 to be used with APIs that expect a byte offset
+    instead (like :c:func:`PyCode_Addr2Line` for example). Notice as well that the
+    ``f_lasti`` member of ``FrameObject`` objects is not considered stable.
+
 CPython bytecode changes
 ========================