summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Python/ceval.c4
-rw-r--r--Python/compile.c31
-rw-r--r--Python/future.c10
-rw-r--r--Python/pythonrun.c24
4 files changed, 17 insertions, 52 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 583d7e3..bf85f11 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2937,11 +2937,11 @@ PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
const int codeflags = current_frame->f_code->co_flags;
if (codeflags & CO_NESTED) {
result = 1;
- cf->cf_flags |= PyCF_NESTED_SCOPES;
+ cf->cf_flags |= CO_NESTED;
}
if (codeflags & CO_GENERATOR_ALLOWED) {
result = 1;
- cf->cf_flags |= PyCF_GENERATORS;
+ cf->cf_flags |= CO_GENERATOR_ALLOWED;
}
}
return result;
diff --git a/Python/compile.c b/Python/compile.c
index d310e35..66cd00a 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -3967,22 +3967,8 @@ jcompile(node *n, char *filename, struct compiling *base,
com_free(&sc);
return NULL;
}
- if (flags) {
- if (flags->cf_flags & PyCF_NESTED_SCOPES)
- sc.c_future->ff_nested_scopes = 1;
- else if (sc.c_future->ff_nested_scopes)
- flags->cf_flags |= PyCF_NESTED_SCOPES;
-
- if (flags->cf_flags & PyCF_GENERATORS)
- sc.c_future->ff_generators = 1;
- else if (sc.c_future->ff_generators)
- flags->cf_flags |= PyCF_GENERATORS;
-
- if (flags->cf_flags & PyCF_DIVISION)
- sc.c_future->ff_division = 1;
- else if (sc.c_future->ff_division)
- flags->cf_flags |= PyCF_DIVISION;
- }
+ if (flags)
+ sc.c_future->ff_features |= flags->cf_flags;
if (symtable_build(&sc, n) < 0) {
com_free(&sc);
return NULL;
@@ -4150,8 +4136,6 @@ symtable_build(struct compiling *c, node *n)
if ((c->c_symtable = symtable_init()) == NULL)
return -1;
c->c_symtable->st_future = c->c_future;
- if (c->c_future->ff_nested_scopes)
- c->c_symtable->st_nested_scopes = 1;
c->c_symtable->st_filename = c->c_filename;
symtable_enter_scope(c->c_symtable, TOP, TYPE(n), n->n_lineno);
if (c->c_symtable->st_errors > 0)
@@ -4451,14 +4435,8 @@ static int
symtable_update_flags(struct compiling *c, PySymtableEntryObject *ste,
struct symbol_info *si)
{
- if (c->c_future) {
- if (c->c_future->ff_nested_scopes)
- c->c_flags |= CO_NESTED;
- if (c->c_future->ff_generators)
- c->c_flags |= CO_GENERATOR_ALLOWED;
- if (c->c_future->ff_division)
- c->c_flags |= CO_FUTURE_DIVISION;
- }
+ if (c->c_future)
+ c->c_flags |= c->c_future->ff_features;
if (ste->ste_generator)
c->c_flags |= CO_GENERATOR;
if (ste->ste_type != TYPE_MODULE)
@@ -4617,7 +4595,6 @@ symtable_init()
if (st == NULL)
return NULL;
st->st_pass = 1;
- st->st_nested_scopes = NESTED_SCOPES_DEFAULT;
st->st_filename = NULL;
if ((st->st_stack = PyList_New(0)) == NULL)
goto fail;
diff --git a/Python/future.c b/Python/future.c
index db62b5b..6b1c0c5 100644
--- a/Python/future.c
+++ b/Python/future.c
@@ -30,11 +30,11 @@ future_check_features(PyFutureFeatures *ff, node *n, char *filename)
REQ(ch, import_as_name);
feature = STR(CHILD(ch, 0));
if (strcmp(feature, FUTURE_NESTED_SCOPES) == 0) {
- ff->ff_nested_scopes = 1;
+ continue;
} else if (strcmp(feature, FUTURE_GENERATORS) == 0) {
- ff->ff_generators = 1;
+ ff->ff_features |= CO_GENERATOR_ALLOWED;
} else if (strcmp(feature, FUTURE_DIVISION) == 0) {
- ff->ff_division = 1;
+ ff->ff_features |= CO_FUTURE_DIVISION;
} else if (strcmp(feature, "braces") == 0) {
PyErr_SetString(PyExc_SyntaxError,
"not a chance");
@@ -234,9 +234,7 @@ PyNode_Future(node *n, char *filename)
return NULL;
ff->ff_found_docstring = 0;
ff->ff_last_lineno = -1;
- ff->ff_nested_scopes = 0;
- ff->ff_generators = 0;
- ff->ff_division = 0;
+ ff->ff_features = 0;
if (future_parse(ff, n, filename) < 0) {
PyMem_Free((void *)ff);
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;