summaryrefslogtreecommitdiffstats
path: root/Include/compile.h
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-07-16 02:29:45 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-07-16 02:29:45 (GMT)
commit5ba58662817b708a453020f0425fe4747ea6d5cb (patch)
tree7d53f1d02fdcc9f6ce4bd1e5130ba1f57269bb3f /Include/compile.h
parent4dbf87152eb69e8c8c87d3081630c4bc02d7cace (diff)
downloadcpython-5ba58662817b708a453020f0425fe4747ea6d5cb.zip
cpython-5ba58662817b708a453020f0425fe4747ea6d5cb.tar.gz
cpython-5ba58662817b708a453020f0425fe4747ea6d5cb.tar.bz2
Part way to allowing "from __future__ import generators" to communicate
that info to code dynamically compiled *by* code compiled with generators enabled. Doesn't yet work because there's still no way to tell the parser that "yield" is OK (unlike nested_scopes, the parser has its fingers in this too). Replaced PyEval_GetNestedScopes by a more-general PyEval_MergeCompilerFlags. Perhaps I should not have? I doubted it was *intended* to be part of the public API, so just did.
Diffstat (limited to 'Include/compile.h')
-rw-r--r--Include/compile.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/Include/compile.h b/Include/compile.h
index 5e6e572..89c5ba4 100644
--- a/Include/compile.h
+++ b/Include/compile.h
@@ -34,6 +34,13 @@ typedef struct {
#define CO_VARKEYWORDS 0x0008
#define CO_NESTED 0x0010
#define CO_GENERATOR 0x0020
+/* XXX Temporary hack. Until generators are a permanent part of the
+ language, we need a way for a code object to record that generators
+ were *possible* when it was compiled. This is so code dynamically
+ compiled *by* a code object knows whether to allow yield stmts. In
+ effect, this passes on the "from __future__ import generators" state
+ in effect when the code block was compiled. */
+#define CO_GENERATOR_ALLOWED 0x1000
extern DL_IMPORT(PyTypeObject) PyCode_Type;
@@ -56,6 +63,7 @@ typedef struct {
int ff_found_docstring;
int ff_last_lineno;
int ff_nested_scopes;
+ int ff_generators;
} PyFutureFeatures;
DL_IMPORT(PyFutureFeatures *) PyNode_Future(struct _node *, char *);