diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2008-03-31 04:20:05 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2008-03-31 04:20:05 (GMT) |
commit | db4115ffc063f20da2c6078bb93187ee8753d4ec (patch) | |
tree | aefc108acfa75b71a627cb7fa3c0cfd6428a8e07 /Python/bltinmodule.c | |
parent | 9367c78c84efaa3f2d6797ca7e18dc78e838c531 (diff) | |
download | cpython-db4115ffc063f20da2c6078bb93187ee8753d4ec.zip cpython-db4115ffc063f20da2c6078bb93187ee8753d4ec.tar.gz cpython-db4115ffc063f20da2c6078bb93187ee8753d4ec.tar.bz2 |
Merged revisions 62039-62042 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62039 | georg.brandl | 2008-03-29 06:24:23 -0700 (Sat, 29 Mar 2008) | 3 lines
Properly check for consistency with the third argument of
compile() when compiling an AST node.
........
r62040 | amaury.forgeotdarc | 2008-03-29 06:47:05 -0700 (Sat, 29 Mar 2008) | 5 lines
The buildbot "x86 W2k8 trunk" seems to hang in test_socket.
http://www.python.org/dev/buildbot/trunk/x86%20W2k8%20trunk/builds/255/step-test/0
Temporarily increase verbosity of this test.
........
r62042 | amaury.forgeotdarc | 2008-03-29 07:53:05 -0700 (Sat, 29 Mar 2008) | 3 lines
Still investigating on the hanging test_socket.
the test itself doesn't do anything on windows, focus on setUp and tearDown.
........
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index ccfce06..199ebc0 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -513,13 +513,14 @@ builtin_compile(PyObject *self, PyObject *args, PyObject *kwds) char *str; char *filename; char *startstr; - int start; + int mode = -1; int dont_inherit = 0; int supplied_flags = 0; PyCompilerFlags cf; PyObject *cmd; static char *kwlist[] = {"source", "filename", "mode", "flags", "dont_inherit", NULL}; + int start[] = {Py_file_input, Py_eval_input, Py_single_input}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "Oss|ii:compile", kwlist, &cmd, &filename, &startstr, @@ -541,6 +542,18 @@ builtin_compile(PyObject *self, PyObject *args, PyObject *kwds) PyEval_MergeCompilerFlags(&cf); } + if (strcmp(startstr, "exec") == 0) + mode = 0; + else if (strcmp(startstr, "eval") == 0) + mode = 1; + else if (strcmp(startstr, "single") == 0) + mode = 2; + else { + PyErr_SetString(PyExc_ValueError, + "compile() arg 3 must be 'exec', 'eval' or 'single'"); + return NULL; + } + if (PyAST_Check(cmd)) { PyObject *result; if (supplied_flags & PyCF_ONLY_AST) { @@ -552,7 +565,7 @@ builtin_compile(PyObject *self, PyObject *args, PyObject *kwds) mod_ty mod; arena = PyArena_New(); - mod = PyAST_obj2mod(cmd, arena); + mod = PyAST_obj2mod(cmd, arena, mode); if (mod == NULL) { PyArena_Free(arena); return NULL; @@ -564,25 +577,11 @@ builtin_compile(PyObject *self, PyObject *args, PyObject *kwds) return result; } - /* XXX: is it possible to pass start to the PyAST_ branch? */ - if (strcmp(startstr, "exec") == 0) - start = Py_file_input; - else if (strcmp(startstr, "eval") == 0) - start = Py_eval_input; - else if (strcmp(startstr, "single") == 0) - start = Py_single_input; - else { - PyErr_SetString(PyExc_ValueError, - "compile() arg 3 must be 'exec'" - "or 'eval' or 'single'"); - return NULL; - } - str = source_as_string(cmd); if (str == NULL) return NULL; - return Py_CompileStringFlags(str, filename, start, &cf); + return Py_CompileStringFlags(str, filename, start[mode], &cf); } PyDoc_STRVAR(compile_doc, |