summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-03-13 20:46:32 (GMT)
committerGeorg Brandl <georg@python.org>2007-03-13 20:46:32 (GMT)
commit5240d7416c739e22298463cb08ba8aad7c762a4a (patch)
tree19d10f5e864c314c645a9020616626ef54ce638f /Python/bltinmodule.c
parent5dc4fe09b7648f9801558e766b21a3d3b2dcad3b (diff)
downloadcpython-5240d7416c739e22298463cb08ba8aad7c762a4a.zip
cpython-5240d7416c739e22298463cb08ba8aad7c762a4a.tar.gz
cpython-5240d7416c739e22298463cb08ba8aad7c762a4a.tar.bz2
Patch #1444529: the builtin compile() now accepts keyword arguments.
(backport)
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r--Python/bltinmodule.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 082f64c..a846377 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -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},