mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
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.
This commit is contained in:
parent
fdd12f66bb
commit
b857ba261f
4 changed files with 17 additions and 52 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue