From 8559119d3c2572c782b76806686a3fc7a51ee5cb Mon Sep 17 00:00:00 2001 From: Bogdan Romanyuk <65823030+wrongnull@users.noreply.github.com> Date: Mon, 19 Feb 2024 16:32:05 +0300 Subject: [PATCH 1/4] Add docs for public c-api function --- Doc/c-api/code.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Doc/c-api/code.rst b/Doc/c-api/code.rst index 382cfbff864072..42a23e976c4424 100644 --- a/Doc/c-api/code.rst +++ b/Doc/c-api/code.rst @@ -30,10 +30,14 @@ bound into a function. Return true if *co* is a :ref:`code object `. This function always succeeds. -.. c:function:: int PyCode_GetNumFree(PyCodeObject *co) +.. c:function:: Py_ssize_t PyCode_GetNumFree(PyCodeObject *co) Return the number of free variables in *co*. +.. c:function:: int PyCode_GetFirstFree(PyCodeObject *co) + + Return the number of local + cell variables in *co* + .. c:function:: PyCodeObject* PyUnstable_Code_New(int argcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, PyObject *qualname, int firstlineno, PyObject *linetable, PyObject *exceptiontable) Return a new code object. If you need a dummy code object to create a frame, From 56f4c39605ae0ab383ab18c14a67b9685add8e0a Mon Sep 17 00:00:00 2001 From: Bogdan Romanyuk <65823030+wrongnull@users.noreply.github.com> Date: Mon, 19 Feb 2024 16:38:28 +0300 Subject: [PATCH 2/4] add missed period --- Doc/c-api/code.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/code.rst b/Doc/c-api/code.rst index 42a23e976c4424..0e053ef05469b2 100644 --- a/Doc/c-api/code.rst +++ b/Doc/c-api/code.rst @@ -36,7 +36,7 @@ bound into a function. .. c:function:: int PyCode_GetFirstFree(PyCodeObject *co) - Return the number of local + cell variables in *co* + Return the number of local + cell variables in *co*. .. c:function:: PyCodeObject* PyUnstable_Code_New(int argcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, PyObject *qualname, int firstlineno, PyObject *linetable, PyObject *exceptiontable) From 6619bb969caa57d174b8e843a83b3078e2c70987 Mon Sep 17 00:00:00 2001 From: Bogdan Romanyuk <65823030+wrongnull@users.noreply.github.com> Date: Wed, 21 Feb 2024 01:45:49 +0300 Subject: [PATCH 3/4] Change the wording of the function documentation --- Doc/c-api/code.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/code.rst b/Doc/c-api/code.rst index 0e053ef05469b2..0f9831c454d256 100644 --- a/Doc/c-api/code.rst +++ b/Doc/c-api/code.rst @@ -36,7 +36,7 @@ bound into a function. .. c:function:: int PyCode_GetFirstFree(PyCodeObject *co) - Return the number of local + cell variables in *co*. + Return the position of first free variable in *co*. .. c:function:: PyCodeObject* PyUnstable_Code_New(int argcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, PyObject *qualname, int firstlineno, PyObject *linetable, PyObject *exceptiontable) From 2af8bee322ff82b2a2abeeae0b8a47a3aab2d4ef Mon Sep 17 00:00:00 2001 From: Bogdan Romanyuk <65823030+wrongnull@users.noreply.github.com> Date: Wed, 21 Feb 2024 11:54:18 +0300 Subject: [PATCH 4/4] Eleminate abbreviation and add article --- Doc/c-api/code.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/code.rst b/Doc/c-api/code.rst index 0f9831c454d256..f6fdd7574323c7 100644 --- a/Doc/c-api/code.rst +++ b/Doc/c-api/code.rst @@ -32,11 +32,11 @@ bound into a function. .. c:function:: Py_ssize_t PyCode_GetNumFree(PyCodeObject *co) - Return the number of free variables in *co*. + Return the number of free variables in a code object. .. c:function:: int PyCode_GetFirstFree(PyCodeObject *co) - Return the position of first free variable in *co*. + Return the position of the first free variable in a code object. .. c:function:: PyCodeObject* PyUnstable_Code_New(int argcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, PyObject *qualname, int firstlineno, PyObject *linetable, PyObject *exceptiontable)