diff options
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 0412b7e..1d20deb 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -533,6 +533,7 @@ PyRun_InteractiveOneFlags(FILE *fp, char *filename, PyCompilerFlags *flags) node *n; perrdetail err; char *ps1 = "", *ps2 = ""; + v = PySys_GetObject("ps1"); if (v != NULL) { v = PyObject_Str(v); @@ -549,8 +550,11 @@ PyRun_InteractiveOneFlags(FILE *fp, char *filename, PyCompilerFlags *flags) else if (PyString_Check(w)) ps2 = PyString_AsString(w); } - n = PyParser_ParseFile(fp, filename, &_PyParser_Grammar, - Py_single_input, ps1, ps2, &err); + n = PyParser_ParseFileFlags(fp, filename, &_PyParser_Grammar, + Py_single_input, ps1, ps2, &err, + (flags && + flags->cf_flags & PyCF_GENERATORS) ? + PyPARSE_YIELD_IS_KEYWORD : 0); Py_XDECREF(v); Py_XDECREF(w); if (n == NULL) { @@ -1017,7 +1021,9 @@ PyObject * PyRun_FileExFlags(FILE *fp, char *filename, int start, PyObject *globals, PyObject *locals, int closeit, PyCompilerFlags *flags) { - node *n = PyParser_SimpleParseFile(fp, filename, start); + node *n = PyParser_SimpleParseFileFlags(fp, filename, start, + (flags && flags->cf_flags & PyCF_GENERATORS) ? + PyPARSE_YIELD_IS_KEYWORD : 0); if (closeit) fclose(fp); return run_err_node(n, filename, globals, locals, flags); @@ -1101,7 +1107,9 @@ Py_CompileStringFlags(char *str, char *filename, int start, { node *n; PyCodeObject *co; - n = PyParser_SimpleParseString(str, start); + n = PyParser_SimpleParseStringFlags(str, start, + (flags && flags->cf_flags & PyCF_GENERATORS) ? + PyPARSE_YIELD_IS_KEYWORD : 0); if (n == NULL) return NULL; co = PyNode_CompileFlags(n, filename, flags); @@ -1125,30 +1133,43 @@ Py_SymtableString(char *str, char *filename, int start) /* Simplified interface to parsefile -- return node or set exception */ node * -PyParser_SimpleParseFile(FILE *fp, char *filename, int start) +PyParser_SimpleParseFileFlags(FILE *fp, char *filename, int start, int flags) { node *n; perrdetail err; - n = PyParser_ParseFile(fp, filename, &_PyParser_Grammar, start, - (char *)0, (char *)0, &err); + n = PyParser_ParseFileFlags(fp, filename, &_PyParser_Grammar, start, + (char *)0, (char *)0, &err, flags); if (n == NULL) err_input(&err); return n; } +node * +PyParser_SimpleParseFile(FILE *fp, char *filename, int start) +{ + return PyParser_SimpleParseFileFlags(fp, filename, start, 0); +} + /* Simplified interface to parsestring -- return node or set exception */ node * -PyParser_SimpleParseString(char *str, int start) +PyParser_SimpleParseStringFlags(char *str, int start, int flags) { node *n; perrdetail err; - n = PyParser_ParseString(str, &_PyParser_Grammar, start, &err); + n = PyParser_ParseStringFlags(str, &_PyParser_Grammar, start, &err, + flags); if (n == NULL) err_input(&err); return n; } +node * +PyParser_SimpleParseString(char *str, int start) +{ + return PyParser_SimpleParseStringFlags(str, start, 0); +} + /* Set the error appropriate to the given input error code (see errcode.h) */ static void |