[Python-checkins] bpo-44964: Correct the note about the f_lasti field (GH-28208) (GH-28276)

ambv webhook-mailer at python.org
Fri Sep 10 12:17:00 EDT 2021


https://github.com/python/cpython/commit/b045174a6dbf1060f092265853f0c78f0704a21a
commit: b045174a6dbf1060f092265853f0c78f0704a21a
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: ambv <lukasz at langa.pl>
date: 2021-09-10T18:16:51+02:00
summary:

bpo-44964: Correct the note about the f_lasti field (GH-28208) (GH-28276)

(cherry picked from commit ab327f2929589407595a3de95727c8ab34ddd4af)

Co-authored-by: Pablo Galindo Salgado <Pablogsal at gmail.com>

files:
M Doc/reference/datamodel.rst
M Doc/whatsnew/3.10.rst

diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index 7b54f441b6a4a..d3cf9836e3356 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1034,9 +1034,8 @@ 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 (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).
+      :attr:`f_lasti` gives the precise instruction (this is an index into the
+      bytecode string of the code object).
 
       Accessing ``f_code`` raises an :ref:`auditing event <auditing>`
       ``object.__getattr__`` with arguments ``obj`` and ``"f_code"``.
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index 5a5f4a360fb9a..2f08b9f9e3e61 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -1948,7 +1948,8 @@ Changes in the C API
     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.
+    ``f_lasti`` member of ``FrameObject`` objects is not considered stable: please
+    use :c:func:`PyFrame_GetLineNumber` instead.
 
 CPython bytecode changes
 ========================



More information about the Python-checkins mailing list