mirror of
https://github.com/python/cpython.git
synced 2025-09-22 16:33:26 +00:00
bpo-37221: Add PyCode_NewWithPosOnlyArgs to be used internally and set PyCode_New as a compatibility wrapper (GH-13959) (#14505)
Add PyCode_NewEx to be used internally and set PyCode_New as a compatibility wrapper
(cherry picked from commit 4a2edc34a4
)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
parent
f22c4cf11d
commit
cb083f7cdf
8 changed files with 79 additions and 34 deletions
|
@ -102,14 +102,13 @@ intern_string_constants(PyObject *tuple)
|
|||
return modified;
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
PyCodeObject *co;
|
||||
Py_ssize_t *cell2arg = NULL;
|
||||
|
@ -243,6 +242,20 @@ PyCode_New(int argcount, int posonlyargcount, int kwonlyargcount,
|
|||
return co;
|
||||
}
|
||||
|
||||
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 PyCode_NewWithPosOnlyArgs(argcount, 0, kwonlyargcount, nlocals,
|
||||
stacksize, flags, code, consts, names,
|
||||
varnames, freevars, cellvars, filename,
|
||||
name, firstlineno, lnotab);
|
||||
}
|
||||
|
||||
int
|
||||
_PyCode_InitOpcache(PyCodeObject *co)
|
||||
{
|
||||
|
@ -311,7 +324,8 @@ PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
|
|||
if (filename_ob == NULL)
|
||||
goto failed;
|
||||
|
||||
result = PyCode_New(0, /* argcount */
|
||||
result = PyCode_NewWithPosOnlyArgs(
|
||||
0, /* argcount */
|
||||
0, /* posonlyargcount */
|
||||
0, /* kwonlyargcount */
|
||||
0, /* nlocals */
|
||||
|
@ -492,12 +506,14 @@ code_new(PyTypeObject *type, PyObject *args, PyObject *kw)
|
|||
if (ourcellvars == NULL)
|
||||
goto cleanup;
|
||||
|
||||
co = (PyObject *)PyCode_New(argcount, posonlyargcount, kwonlyargcount,
|
||||
nlocals, stacksize, flags,
|
||||
code, consts, ournames, ourvarnames,
|
||||
ourfreevars, ourcellvars, filename,
|
||||
name, firstlineno, lnotab);
|
||||
cleanup:
|
||||
co = (PyObject *)PyCode_NewWithPosOnlyArgs(argcount, posonlyargcount,
|
||||
kwonlyargcount,
|
||||
nlocals, stacksize, flags,
|
||||
code, consts, ournames,
|
||||
ourvarnames, ourfreevars,
|
||||
ourcellvars, filename,
|
||||
name, firstlineno, lnotab);
|
||||
cleanup:
|
||||
Py_XDECREF(ournames);
|
||||
Py_XDECREF(ourvarnames);
|
||||
Py_XDECREF(ourfreevars);
|
||||
|
@ -625,7 +641,7 @@ code_replace_impl(PyCodeObject *self, int co_argcount,
|
|||
|
||||
#undef CHECK_INT_ARG
|
||||
|
||||
return (PyObject *)PyCode_New(
|
||||
return (PyObject *)PyCode_NewWithPosOnlyArgs(
|
||||
co_argcount, co_posonlyargcount, co_kwonlyargcount, co_nlocals,
|
||||
co_stacksize, co_flags, (PyObject*)co_code, co_consts, co_names,
|
||||
co_varnames, co_freevars, co_cellvars, co_filename, co_name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue