diff Python/compile.c @ 19158:97a3d3d7029f legacy-trunk

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.
author Jeremy Hylton <jeremy@alum.mit.edu>
date Fri, 10 Aug 2001 21:41:33 +0000
parents f20727cc3d0f
children 9d024ae05837
line wrap: on
line diff
--- a/Python/compile.c	Fri Aug 10 21:38:04 2001 +0000
+++ b/Python/compile.c	Fri Aug 10 21:41:33 2001 +0000
@@ -3967,22 +3967,8 @@
 			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 @@
 	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 @@
 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 @@
 	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;