summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
Diffstat (limited to 'Include')
-rw-r--r--Include/Python.h2
-rw-r--r--Include/ceval.h6
-rw-r--r--Include/compile.h8
-rw-r--r--Include/pythonrun.h7
4 files changed, 20 insertions, 3 deletions
diff --git a/Include/Python.h b/Include/Python.h
index 5d91125..24d33b2 100644
--- a/Include/Python.h
+++ b/Include/Python.h
@@ -96,8 +96,8 @@
#include "pystate.h"
#include "modsupport.h"
-#include "ceval.h"
#include "pythonrun.h"
+#include "ceval.h"
#include "sysmodule.h"
#include "intrcheck.h"
#include "import.h"
diff --git a/Include/ceval.h b/Include/ceval.h
index 19ac064..0fc5cba 100644
--- a/Include/ceval.h
+++ b/Include/ceval.h
@@ -31,7 +31,11 @@ DL_IMPORT(PyObject *) PyEval_GetLocals(void);
DL_IMPORT(PyObject *) PyEval_GetOwner(void);
DL_IMPORT(PyObject *) PyEval_GetFrame(void);
DL_IMPORT(int) PyEval_GetRestricted(void);
-DL_IMPORT(int) PyEval_GetNestedScopes(void);
+
+/* Look at the current frame's (if any) code's co_flags, and turn on
+ the corresponding compiler flags in cf->cf_flags. Return 1 if any
+ flag was set, else return 0. */
+DL_IMPORT(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
DL_IMPORT(int) Py_FlushLine(void);
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 *);
diff --git a/Include/pythonrun.h b/Include/pythonrun.h
index e7274ec..3877a82 100644
--- a/Include/pythonrun.h
+++ b/Include/pythonrun.h
@@ -7,8 +7,13 @@
extern "C" {
#endif
+/* These flags are named after the __future__ statements that introduced
+ them. May not remain true for later additions, so fiddle this comment
+ accordingly then. */
+#define PyCF_NESTED_SCOPES (0x00000001UL)
+#define PyCF_GENERATORS (0x00000002UL)
typedef struct {
- int cf_nested_scopes;
+ unsigned long cf_flags; /* bitmask of PyCF_xxx flags */
} PyCompilerFlags;
DL_IMPORT(void) Py_SetProgramName(char *);