mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
move extra arguments to the back of the new.code() arglist
This commit is contained in:
parent
dabed752ed
commit
6fe0a82ecb
2 changed files with 28 additions and 8 deletions
|
@ -66,7 +66,10 @@ verify(g['c'] == 3,
|
||||||
|
|
||||||
# bogus test of new.code()
|
# bogus test of new.code()
|
||||||
print 'new.code()'
|
print 'new.code()'
|
||||||
d = new.code(3, 3, 3, 3, codestr, (), (), (), (), (),
|
d = new.code(3, 3, 3, 3, codestr, (), (), (),
|
||||||
|
"<string>", "<name>", 1, "", (), ())
|
||||||
|
# test backwards-compatibility version with no freevars or cellvars
|
||||||
|
d = new.code(3, 3, 3, 3, codestr, (), (), (),
|
||||||
"<string>", "<name>", 1, "")
|
"<string>", "<name>", 1, "")
|
||||||
if verbose:
|
if verbose:
|
||||||
print d
|
print d
|
||||||
|
|
|
@ -103,7 +103,9 @@ new_function(PyObject* unused, PyObject* args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char new_code_doc[] =
|
static char new_code_doc[] =
|
||||||
"Create a code object from (ARGCOUNT, NLOCALS, STACKSIZE, FLAGS, CODESTRING, CONSTANTS, NAMES, VARNAMES, FREEVARS, CELLVARS, FILENAME, NAME, FIRSTLINENO, LNOTAB).";
|
"Create a code object from (ARGCOUNT, NLOCALS, STACKSIZE, FLAGS, CODESTRING,\n"
|
||||||
|
"CONSTANTS, NAMES, VARNAMES, FILENAME, NAME, FIRSTLINENO, LNOTAB, FREEVARS,\n"
|
||||||
|
"CELLVARS).";
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
new_code(PyObject* unused, PyObject* args)
|
new_code(PyObject* unused, PyObject* args)
|
||||||
|
@ -116,26 +118,41 @@ new_code(PyObject* unused, PyObject* args)
|
||||||
PyObject* consts;
|
PyObject* consts;
|
||||||
PyObject* names;
|
PyObject* names;
|
||||||
PyObject* varnames;
|
PyObject* varnames;
|
||||||
PyObject* freevars;
|
PyObject* freevars = NULL;
|
||||||
PyObject* cellvars;
|
PyObject* cellvars = NULL;
|
||||||
PyObject* filename;
|
PyObject* filename;
|
||||||
PyObject* name;
|
PyObject* name;
|
||||||
int firstlineno;
|
int firstlineno;
|
||||||
PyObject* lnotab;
|
PyObject* lnotab;
|
||||||
PyBufferProcs *pb;
|
PyBufferProcs *pb;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "iiiiOO!O!O!O!O!SSiS:code",
|
if (!PyArg_ParseTuple(args, "iiiiSO!O!O!SSiS|O!O!:code",
|
||||||
&argcount, &nlocals, &stacksize, &flags,
|
&argcount, &nlocals, &stacksize, &flags,
|
||||||
&code,
|
&code,
|
||||||
&PyTuple_Type, &consts,
|
&PyTuple_Type, &consts,
|
||||||
&PyTuple_Type, &names,
|
&PyTuple_Type, &names,
|
||||||
&PyTuple_Type, &varnames,
|
&PyTuple_Type, &varnames,
|
||||||
&PyTuple_Type, &freevars,
|
|
||||||
&PyTuple_Type, &cellvars,
|
|
||||||
&filename, &name,
|
&filename, &name,
|
||||||
&firstlineno, &lnotab))
|
&firstlineno, &lnotab,
|
||||||
|
&PyTuple_Type, &freevars,
|
||||||
|
&PyTuple_Type, &cellvars))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (freevars == NULL || cellvars == NULL) {
|
||||||
|
PyObject *empty = PyTuple_New(0);
|
||||||
|
if (empty == NULL)
|
||||||
|
return NULL;
|
||||||
|
if (freevars == NULL) {
|
||||||
|
freevars = empty;
|
||||||
|
Py_INCREF(freevars);
|
||||||
|
}
|
||||||
|
if (cellvars == NULL) {
|
||||||
|
cellvars = empty;
|
||||||
|
Py_INCREF(cellvars);
|
||||||
|
}
|
||||||
|
Py_DECREF(empty);
|
||||||
|
}
|
||||||
|
|
||||||
pb = code->ob_type->tp_as_buffer;
|
pb = code->ob_type->tp_as_buffer;
|
||||||
if (pb == NULL ||
|
if (pb == NULL ||
|
||||||
pb->bf_getreadbuffer == NULL ||
|
pb->bf_getreadbuffer == NULL ||
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue