Skip to content

Commit 490a742

Browse files
bpo-44964: Correct the note about the f_lasti field (GH-28208) (GH-28276)
(cherry picked from commit ab327f2) Co-authored-by: Pablo Galindo Salgado <[email protected]>
1 parent 9d8a64a commit 490a742

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Doc/reference/datamodel.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,9 +1034,8 @@ Internal types
10341034
:attr:`f_code` is the code object being executed in this frame; :attr:`f_locals`
10351035
is the dictionary used to look up local variables; :attr:`f_globals` is used for
10361036
global variables; :attr:`f_builtins` is used for built-in (intrinsic) names;
1037-
:attr:`f_lasti` gives the precise instruction (it represents a wordcode index, which
1038-
means that to get an index into the bytecode string of the code object it needs to be
1039-
multiplied by 2).
1037+
:attr:`f_lasti` gives the precise instruction (this is an index into the
1038+
bytecode string of the code object).
10401039

10411040
Accessing ``f_code`` raises an :ref:`auditing event <auditing>`
10421041
``object.__getattr__`` with arguments ``obj`` and ``"f_code"``.

Doc/whatsnew/3.10.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1959,7 +1959,8 @@ Changes in the C API
19591959
offset instead of a simple offset into the bytecode string. This means that this
19601960
number needs to be multiplied by 2 to be used with APIs that expect a byte offset
19611961
instead (like :c:func:`PyCode_Addr2Line` for example). Notice as well that the
1962-
``f_lasti`` member of ``FrameObject`` objects is not considered stable.
1962+
``f_lasti`` member of ``FrameObject`` objects is not considered stable: please
1963+
use :c:func:`PyFrame_GetLineNumber` instead.
19631964
19641965
CPython bytecode changes
19651966
========================

0 commit comments

Comments
 (0)