Skip to content

Commit aa5c0a9

Browse files
authored
bpo-40421: Cleanup PyFrame C API (GH-32417)
1 parent 7fbc7f6 commit aa5c0a9

File tree

3 files changed

+4
-18
lines changed

3 files changed

+4
-18
lines changed

Doc/c-api/frame.rst

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ See also :ref:`Reflection <reflection>`.
2727
Return a :term:`strong reference`, or ``NULL`` if *frame* has no outer
2828
frame.
2929
30-
*frame* must not be ``NULL``.
31-
3230
.. versionadded:: 3.9
3331
3432
@@ -38,8 +36,6 @@ See also :ref:`Reflection <reflection>`.
3836
3937
Return a :term:`strong reference`. The result cannot be ``NULL``.
4038
41-
*frame* must not be ``NULL``.
42-
4339
.. versionadded:: 3.11
4440
4541
@@ -49,7 +45,7 @@ See also :ref:`Reflection <reflection>`.
4945
5046
Return a :term:`strong reference`.
5147
52-
*frame* must not be ``NULL``. The result (frame code) cannot be ``NULL``.
48+
The result (frame code) cannot be ``NULL``.
5349
5450
.. versionadded:: 3.9
5551
@@ -62,8 +58,6 @@ See also :ref:`Reflection <reflection>`.
6258
6359
Return a :term:`strong reference`, or ``NULL``.
6460
65-
*frame* must not be ``NULL``.
66-
6761
.. versionadded:: 3.11
6862
6963
@@ -73,19 +67,15 @@ See also :ref:`Reflection <reflection>`.
7367
7468
Return a :term:`strong reference`. The result cannot be ``NULL``.
7569
76-
*frame* must not be ``NULL``.
77-
7870
.. versionadded:: 3.11
7971
8072
8173
.. c:function:: int PyFrame_GetLasti(PyFrameObject *frame)
8274
83-
Get the *frame*'s ``f_lasti`` attribute (:class:`dict`).
75+
Get the *frame*'s ``f_lasti`` attribute.
8476
8577
Returns -1 if ``frame.f_lasti`` is ``None``.
8678
87-
*frame* must not be ``NULL``.
88-
8979
.. versionadded:: 3.11
9080
9181
@@ -95,13 +85,9 @@ See also :ref:`Reflection <reflection>`.
9585
9686
Return a :term:`strong reference`.
9787
98-
*frame* must not be ``NULL``.
99-
10088
.. versionadded:: 3.11
10189
10290
10391
.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
10492
10593
Return the line number that *frame* is currently executing.
106-
107-
*frame* must not be ``NULL``.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Add ``PyFrame_GetLasti`` C-API function to access frame object's ``lasti``
1+
Add ``PyFrame_GetLasti`` C-API function to access frame object's ``f_lasti``
22
attribute safely from C code.

Objects/frameobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ PyFrame_GetLasti(PyFrameObject *frame)
11601160
if (lasti < 0) {
11611161
return -1;
11621162
}
1163-
return lasti*2;
1163+
return lasti * sizeof(_Py_CODEUNIT);
11641164
}
11651165

11661166
PyObject *

0 commit comments

Comments
 (0)