bpo-37221: Add PyCode_NewWithPosOnlyArgs to be used internally and set PyCode_New as a compatibility wrapper (GH-13959)
Add PyCode_NewEx to be used internally and set PyCode_New as a compatibility wrapper
diff --git a/Doc/c-api/code.rst b/Doc/c-api/code.rst
index 7353df5..3c4f669 100644
--- a/Doc/c-api/code.rst
+++ b/Doc/c-api/code.rst
@@ -33,20 +33,21 @@
Return the number of free variables in *co*.
-.. c:function:: PyCodeObject* PyCode_New(int argcount, int posonlyargcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *lnotab)
+.. c:function:: PyCodeObject* PyCode_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, int firstlineno, PyObject *lnotab)
- Return a new code object. If you need a dummy code object to
- create a frame, use :c:func:`PyCode_NewEmpty` instead. Calling
- :c:func:`PyCode_New` directly can bind you to a precise Python
- version since the definition of the bytecode changes often.
-
- .. versionchanged:: 3.8
- An extra parameter is required (*posonlyargcount*) to support :PEP:`570`.
- The first parameter (*argcount*) now represents the total number of positional arguments,
- including positional-only.
+ Return a new code object. If you need a dummy code object to create a frame,
+ use :c:func:`PyCode_NewEmpty` instead. Calling :c:func:`PyCode_New` directly
+ can bind you to a precise Python version since the definition of the bytecode
+ changes often.
.. audit-event:: code.__new__ code,filename,name,argcount,posonlyargcount,kwonlyargcount,nlocals,stacksize,flags c.PyCode_New
+.. c:function:: PyCodeObject* PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *lnotab)
+
+ Similar to :c:func:`PyCode_New`, but with an extra "posonlyargcount" for positonal-only arguments.
+
+ .. versionadded:: 3.8
+
.. c:function:: PyCodeObject* PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
Return a new empty code object with the specified filename,