gh-92154: Expose PyCode_GetCode in the C API (GH-92168)

This commit is contained in:
Ken Jin 2022-05-03 20:13:13 +07:00 committed by GitHub
parent 1d4a9a45b7
commit 6c7249f265
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 0 deletions

View file

@ -76,3 +76,17 @@ bound into a function.
information is not available for any particular element.
Returns ``1`` if the function succeeds and 0 otherwise.
.. c:function:: PyObject* PyCode_GetCode(PyCodeObject *co)
Equivalent to the Python code ``getattr(co, 'co_code')``.
Returns a strong reference to a :c:type:`PyBytesObject` representing the
bytecode in a code object. On error, ``NULL`` is returned and an exception
is raised.
This ``PyBytesObject`` may be created on-demand by the interpreter and does
not necessarily represent the bytecode actually executed by CPython. The
primary use case for this function is debuggers and profilers.
.. versionadded:: 3.11