Skip to content

bpo-40421: Cleanup PyFrame C API #32417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions Doc/c-api/frame.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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


Expand All @@ -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

Expand All @@ -62,8 +58,6 @@ See also :ref:`Reflection <reflection>`.

Return a :term:`strong reference`, or ``NULL``.

*frame* must not be ``NULL``.

.. versionadded:: 3.11


Expand All @@ -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


Expand All @@ -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``.
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ PyFrame_GetLasti(PyFrameObject *frame)
if (lasti < 0) {
return -1;
}
return lasti*2;
return lasti * sizeof(_Py_CODEUNIT);
}

PyObject *
Expand Down