mirror of
https://github.com/python/cpython.git
synced 2025-07-28 13:44:43 +00:00
gh-94936: C getters: co_varnames, co_cellvars, co_freevars (#95008)
This commit is contained in:
parent
0342c93a6b
commit
42b102bbf9
6 changed files with 128 additions and 15 deletions
|
@ -90,3 +90,28 @@ bound into a function.
|
|||
|
||||
.. versionadded:: 3.11
|
||||
|
||||
.. c:function:: PyObject* PyCode_GetVarnames(PyCodeObject *co)
|
||||
|
||||
Equivalent to the Python code ``getattr(co, 'co_varnames')``.
|
||||
Returns a new reference to a :c:type:`PyTupleObject` containing the names of
|
||||
the local variables. On error, ``NULL`` is returned and an exception
|
||||
is raised.
|
||||
|
||||
.. versionadded:: 3.11
|
||||
|
||||
.. c:function:: PyObject* PyCode_GetCellvars(PyCodeObject *co)
|
||||
|
||||
Equivalent to the Python code ``getattr(co, 'co_cellvars')``.
|
||||
Returns a new reference to a :c:type:`PyTupleObject` containing the names of
|
||||
the local variables that are referenced by nested functions. On error, ``NULL``
|
||||
is returned and an exception is raised.
|
||||
|
||||
.. versionadded:: 3.11
|
||||
|
||||
.. c:function:: PyObject* PyCode_GetFreevars(PyCodeObject *co)
|
||||
|
||||
Equivalent to the Python code ``getattr(co, 'co_freevars')``.
|
||||
Returns a new reference to a :c:type:`PyTupleObject` containing the names of
|
||||
the free variables. On error, ``NULL`` is returned and an exception is raised.
|
||||
|
||||
.. versionadded:: 3.11
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue