bpo-40421: Cleanup PyFrame C API (GH-32417)

This commit is contained in:
Victor Stinner 2022-04-19 09:53:10 +02:00 committed by GitHub
parent 7fbc7f6128
commit aa5c0a9f8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 18 deletions

View file

@ -27,8 +27,6 @@ See also :ref:`Reflection <reflection>`.
Return a :term:`strong reference`, or ``NULL`` if *frame* has no outer Return a :term:`strong reference`, or ``NULL`` if *frame* has no outer
frame. frame.
*frame* must not be ``NULL``.
.. versionadded:: 3.9 .. versionadded:: 3.9
@ -38,8 +36,6 @@ See also :ref:`Reflection <reflection>`.
Return a :term:`strong reference`. The result cannot be ``NULL``. Return a :term:`strong reference`. The result cannot be ``NULL``.
*frame* must not be ``NULL``.
.. versionadded:: 3.11 .. versionadded:: 3.11
@ -49,7 +45,7 @@ See also :ref:`Reflection <reflection>`.
Return a :term:`strong reference`. 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 .. versionadded:: 3.9
@ -62,8 +58,6 @@ See also :ref:`Reflection <reflection>`.
Return a :term:`strong reference`, or ``NULL``. Return a :term:`strong reference`, or ``NULL``.
*frame* must not be ``NULL``.
.. versionadded:: 3.11 .. versionadded:: 3.11
@ -73,19 +67,15 @@ See also :ref:`Reflection <reflection>`.
Return a :term:`strong reference`. The result cannot be ``NULL``. Return a :term:`strong reference`. The result cannot be ``NULL``.
*frame* must not be ``NULL``.
.. versionadded:: 3.11 .. versionadded:: 3.11
.. c:function:: int PyFrame_GetLasti(PyFrameObject *frame) .. 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``. Returns -1 if ``frame.f_lasti`` is ``None``.
*frame* must not be ``NULL``.
.. versionadded:: 3.11 .. versionadded:: 3.11
@ -95,13 +85,9 @@ See also :ref:`Reflection <reflection>`.
Return a :term:`strong reference`. Return a :term:`strong reference`.
*frame* must not be ``NULL``.
.. versionadded:: 3.11 .. versionadded:: 3.11
.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame) .. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
Return the line number that *frame* is currently executing. Return the line number that *frame* is currently executing.
*frame* must not be ``NULL``.

View file

@ -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. attribute safely from C code.

View file

@ -1160,7 +1160,7 @@ PyFrame_GetLasti(PyFrameObject *frame)
if (lasti < 0) { if (lasti < 0) {
return -1; return -1;
} }
return lasti*2; return lasti * sizeof(_Py_CODEUNIT);
} }
PyObject * PyObject *