[Python-checkins] bpo-40421: Cleanup PyFrame C API (GH-32417)
vstinner
webhook-mailer at python.org
Tue Apr 19 03:53:26 EDT 2022
https://github.com/python/cpython/commit/aa5c0a9f8dd935a7afff07abb5a60d492c40f2cb
commit: aa5c0a9f8dd935a7afff07abb5a60d492c40f2cb
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2022-04-19T09:53:10+02:00
summary:
bpo-40421: Cleanup PyFrame C API (GH-32417)
files:
M Doc/c-api/frame.rst
M Misc/NEWS.d/next/C API/2022-04-08-11-29-36.bpo-40421.H0ORmT.rst
M Objects/frameobject.c
diff --git a/Doc/c-api/frame.rst b/Doc/c-api/frame.rst
index 68e5dc6daeaec..46ce700abf147 100644
--- a/Doc/c-api/frame.rst
+++ b/Doc/c-api/frame.rst
@@ -27,8 +27,6 @@ See also :ref:`Reflection <reflection>`.
Return a :term:`strong reference`, or ``NULL`` if *frame* has no outer
frame.
- *frame* must not be ``NULL``.
-
.. versionadded:: 3.9
@@ -38,8 +36,6 @@ See also :ref:`Reflection <reflection>`.
Return a :term:`strong reference`. The result cannot be ``NULL``.
- *frame* must not be ``NULL``.
-
.. versionadded:: 3.11
@@ -49,7 +45,7 @@ See also :ref:`Reflection <reflection>`.
Return a :term:`strong reference`.
- *frame* must not be ``NULL``. The result (frame code) cannot be ``NULL``.
+ The result (frame code) cannot be ``NULL``.
.. versionadded:: 3.9
@@ -62,8 +58,6 @@ See also :ref:`Reflection <reflection>`.
Return a :term:`strong reference`, or ``NULL``.
- *frame* must not be ``NULL``.
-
.. versionadded:: 3.11
@@ -73,19 +67,15 @@ See also :ref:`Reflection <reflection>`.
Return a :term:`strong reference`. The result cannot be ``NULL``.
- *frame* must not be ``NULL``.
-
.. versionadded:: 3.11
.. c:function:: int PyFrame_GetLasti(PyFrameObject *frame)
- Get the *frame*'s ``f_lasti`` attribute (:class:`dict`).
+ Get the *frame*'s ``f_lasti`` attribute.
Returns -1 if ``frame.f_lasti`` is ``None``.
- *frame* must not be ``NULL``.
-
.. versionadded:: 3.11
@@ -95,13 +85,9 @@ See also :ref:`Reflection <reflection>`.
Return a :term:`strong reference`.
- *frame* must not be ``NULL``.
-
.. versionadded:: 3.11
.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
Return the line number that *frame* is currently executing.
-
- *frame* must not be ``NULL``.
diff --git a/Misc/NEWS.d/next/C API/2022-04-08-11-29-36.bpo-40421.H0ORmT.rst b/Misc/NEWS.d/next/C API/2022-04-08-11-29-36.bpo-40421.H0ORmT.rst
index 2e10c2394c933..d4a1dbecf2867 100644
--- a/Misc/NEWS.d/next/C API/2022-04-08-11-29-36.bpo-40421.H0ORmT.rst
+++ b/Misc/NEWS.d/next/C API/2022-04-08-11-29-36.bpo-40421.H0ORmT.rst
@@ -1,2 +1,2 @@
-Add ``PyFrame_GetLasti`` C-API function to access frame object's ``lasti``
+Add ``PyFrame_GetLasti`` C-API function to access frame object's ``f_lasti``
attribute safely from C code.
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index dc4ef8bcda541..e65395ee5f20e 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -1160,7 +1160,7 @@ PyFrame_GetLasti(PyFrameObject *frame)
if (lasti < 0) {
return -1;
}
- return lasti*2;
+ return lasti * sizeof(_Py_CODEUNIT);
}
PyObject *
More information about the Python-checkins
mailing list