diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-02-01 19:50:29 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-02-01 19:50:29 (GMT) |
commit | 6fe0a82ecbd3bdbb028ae2041595bce3fd8b25fb (patch) | |
tree | b8e59d9bd7f69f48313daecaf720ced8e628265c /Modules/newmodule.c | |
parent | dabed752ed2b35f5df0948ab4ee5cd99e9cb0272 (diff) | |
download | cpython-6fe0a82ecbd3bdbb028ae2041595bce3fd8b25fb.zip cpython-6fe0a82ecbd3bdbb028ae2041595bce3fd8b25fb.tar.gz cpython-6fe0a82ecbd3bdbb028ae2041595bce3fd8b25fb.tar.bz2 |
move extra arguments to the back of the new.code() arglist
Diffstat (limited to 'Modules/newmodule.c')
-rw-r--r-- | Modules/newmodule.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/Modules/newmodule.c b/Modules/newmodule.c index 7c7bee7..7b91fb8 100644 --- a/Modules/newmodule.c +++ b/Modules/newmodule.c @@ -103,7 +103,9 @@ new_function(PyObject* unused, PyObject* args) } 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 * new_code(PyObject* unused, PyObject* args) @@ -116,26 +118,41 @@ new_code(PyObject* unused, PyObject* args) PyObject* consts; PyObject* names; PyObject* varnames; - PyObject* freevars; - PyObject* cellvars; + PyObject* freevars = NULL; + PyObject* cellvars = NULL; PyObject* filename; PyObject* name; int firstlineno; PyObject* lnotab; 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, &code, &PyTuple_Type, &consts, &PyTuple_Type, &names, &PyTuple_Type, &varnames, - &PyTuple_Type, &freevars, - &PyTuple_Type, &cellvars, &filename, &name, - &firstlineno, &lnotab)) + &firstlineno, &lnotab, + &PyTuple_Type, &freevars, + &PyTuple_Type, &cellvars)) 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; if (pb == NULL || pb->bf_getreadbuffer == NULL || |