diff options
author | Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> | 2022-08-04 13:53:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-04 13:53:31 (GMT) |
commit | 42b102bbf9a9ae6fae8f6710202fb7afeeac277c (patch) | |
tree | 40cd485e5df107445183aa3a25b4998f1727cba3 /Doc/c-api/code.rst | |
parent | 0342c93a6b866118c894c4e1120fb4db316adebb (diff) | |
download | cpython-42b102bbf9a9ae6fae8f6710202fb7afeeac277c.zip cpython-42b102bbf9a9ae6fae8f6710202fb7afeeac277c.tar.gz cpython-42b102bbf9a9ae6fae8f6710202fb7afeeac277c.tar.bz2 |
gh-94936: C getters: co_varnames, co_cellvars, co_freevars (#95008)
Diffstat (limited to 'Doc/c-api/code.rst')
-rw-r--r-- | Doc/c-api/code.rst | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Doc/c-api/code.rst b/Doc/c-api/code.rst index 7915b81..d4a3c4a 100644 --- a/Doc/c-api/code.rst +++ b/Doc/c-api/code.rst @@ -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 |