mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
Patch #1444529: the builtin compile() now accepts keyword arguments.
(backport)
This commit is contained in:
parent
5dc4fe09b7
commit
5240d7416c
4 changed files with 23 additions and 9 deletions
|
@ -402,7 +402,7 @@ a common type, using the same rules as used by arithmetic operations.\n\
|
|||
If coercion is not possible, raise TypeError.");
|
||||
|
||||
static PyObject *
|
||||
builtin_compile(PyObject *self, PyObject *args)
|
||||
builtin_compile(PyObject *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
char *str;
|
||||
char *filename;
|
||||
|
@ -413,9 +413,12 @@ builtin_compile(PyObject *self, PyObject *args)
|
|||
PyCompilerFlags cf;
|
||||
PyObject *result = NULL, *cmd, *tmp = NULL;
|
||||
Py_ssize_t length;
|
||||
static char *kwlist[] = {"source", "filename", "mode", "flags",
|
||||
"dont_inherit", NULL};
|
||||
|
||||
if (!PyArg_ParseTuple(args, "Oss|ii:compile", &cmd, &filename,
|
||||
&startstr, &supplied_flags, &dont_inherit))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "Oss|ii:compile",
|
||||
kwlist, &cmd, &filename, &startstr,
|
||||
&supplied_flags, &dont_inherit))
|
||||
return NULL;
|
||||
|
||||
cf.cf_flags = supplied_flags;
|
||||
|
@ -2237,7 +2240,7 @@ static PyMethodDef builtin_methods[] = {
|
|||
{"chr", builtin_chr, METH_VARARGS, chr_doc},
|
||||
{"cmp", builtin_cmp, METH_VARARGS, cmp_doc},
|
||||
{"coerce", builtin_coerce, METH_VARARGS, coerce_doc},
|
||||
{"compile", builtin_compile, METH_VARARGS, compile_doc},
|
||||
{"compile", (PyCFunction)builtin_compile, METH_VARARGS | METH_KEYWORDS, compile_doc},
|
||||
{"delattr", builtin_delattr, METH_VARARGS, delattr_doc},
|
||||
{"dir", builtin_dir, METH_VARARGS, dir_doc},
|
||||
{"divmod", builtin_divmod, METH_VARARGS, divmod_doc},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue