diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-08-10 21:41:33 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-08-10 21:41:33 (GMT) |
commit | b857ba261fc468d956e350f51469efd7d5773da2 (patch) | |
tree | ae9529e282d8d196eaaab2ab394e395626aca137 /Python/pythonrun.c | |
parent | fdd12f66bb9740c7796441cd19db2a9d1502ee4f (diff) | |
download | cpython-b857ba261fc468d956e350f51469efd7d5773da2.zip cpython-b857ba261fc468d956e350f51469efd7d5773da2.tar.gz cpython-b857ba261fc468d956e350f51469efd7d5773da2.tar.bz2 |
Refactor future feature handling
Replace uses of PyCF_xxx with CO_xxx.
Replace individual feature slots in PyFutureFeatures with single
bitmask ff_features.
When flags must be transfered among the three parts of the interpreter
that care about them -- the pythonrun layer, the compiler, and the
future feature parser -- can simply or (|) the definitions.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 69a7b51..f5fcaf1 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -556,7 +556,7 @@ PyRun_InteractiveOneFlags(FILE *fp, char *filename, PyCompilerFlags *flags) n = PyParser_ParseFileFlags(fp, filename, &_PyParser_Grammar, Py_single_input, ps1, ps2, &err, (flags && - flags->cf_flags & PyCF_GENERATORS) ? + flags->cf_flags & CO_GENERATOR_ALLOWED) ? PyPARSE_YIELD_IS_KEYWORD : 0); Py_XDECREF(v); Py_XDECREF(w); @@ -1009,8 +1009,8 @@ PyRun_StringFlags(char *str, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags) { return run_err_node(PyParser_SimpleParseStringFlags( - str, start, - (flags && flags->cf_flags & PyCF_GENERATORS) ? + str, start, + (flags && flags->cf_flags & CO_GENERATOR_ALLOWED) ? PyPARSE_YIELD_IS_KEYWORD : 0), "<string>", globals, locals, flags); } @@ -1028,7 +1028,7 @@ PyRun_FileExFlags(FILE *fp, char *filename, int start, PyObject *globals, PyObject *locals, int closeit, PyCompilerFlags *flags) { node *n = PyParser_SimpleParseFileFlags(fp, filename, start, - (flags && flags->cf_flags & PyCF_GENERATORS) ? + (flags && flags->cf_flags & CO_GENERATOR_ALLOWED) ? PyPARSE_YIELD_IS_KEYWORD : 0); if (closeit) fclose(fp); @@ -1085,18 +1085,8 @@ run_pyc_file(FILE *fp, char *filename, PyObject *globals, PyObject *locals, } co = (PyCodeObject *)v; v = PyEval_EvalCode(co, globals, locals); - if (v && flags) { - if (co->co_flags & CO_NESTED) - flags->cf_flags |= PyCF_NESTED_SCOPES; - if (co->co_flags & CO_GENERATOR_ALLOWED) - flags->cf_flags |= PyCF_GENERATORS; -#if 0 - fprintf(stderr, "run_pyc_file: nested_scopes: %d\n", - flags->cf_flags & PyCF_NESTED_SCOPES); - fprintf(stderr, "run_pyc_file: generators: %d\n", - flags->cf_flags & PyCF_GENERATORS); -#endif - } + if (v && flags) + flags->cf_flags |= (co->co_flags & PyCF_MASK); Py_DECREF(co); return v; } @@ -1114,7 +1104,7 @@ Py_CompileStringFlags(char *str, char *filename, int start, node *n; PyCodeObject *co; n = PyParser_SimpleParseStringFlags(str, start, - (flags && flags->cf_flags & PyCF_GENERATORS) ? + (flags && flags->cf_flags & CO_GENERATOR_ALLOWED) ? PyPARSE_YIELD_IS_KEYWORD : 0); if (n == NULL) return NULL; |