summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2019-07-01 10:35:05 (GMT)
committerPetr Viktorin <pviktori@redhat.com>2019-07-01 10:35:05 (GMT)
commit4a2edc34a405150d0b23ecfdcb401e7cf59f4650 (patch)
treed4d88459768f103b76ce92536ba047b305ae0d24 /Objects
parentfc1fbe6099e826e8304eadf781af7c10d739fc40 (diff)
downloadcpython-4a2edc34a405150d0b23ecfdcb401e7cf59f4650.zip
cpython-4a2edc34a405150d0b23ecfdcb401e7cf59f4650.tar.gz
cpython-4a2edc34a405150d0b23ecfdcb401e7cf59f4650.tar.bz2
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
Diffstat (limited to 'Objects')
-rw-r--r--Objects/codeobject.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index 1333cc83..39bf6fc 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -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,