Backport of the print function, using a __future__ import.
This work is substantially Anthony Baxter's, from issue
1633807. I just freshened it, made a few minor tweaks,
and added the test cases. I also created issue 2412,
which is to check for 2to3's behavior with the print
function. I also added myself to ACKS.
diff --git a/Include/code.h b/Include/code.h
index 07e3b1f..0e89b88 100644
--- a/Include/code.h
+++ b/Include/code.h
@@ -48,11 +48,12 @@
#define CO_FUTURE_DIVISION 0x2000
#define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 /* do absolute imports by default */
#define CO_FUTURE_WITH_STATEMENT 0x8000
+#define CO_FUTURE_PRINT_FUNCTION 0x10000
/* This should be defined if a future statement modifies the syntax.
For example, when a keyword is added.
*/
-#if 0
+#if 1
#define PY_PARSER_REQUIRES_FUTURE_KEYWORD
#endif
diff --git a/Include/compile.h b/Include/compile.h
index 2bde6fb..d703edb 100644
--- a/Include/compile.h
+++ b/Include/compile.h
@@ -24,6 +24,8 @@
#define FUTURE_DIVISION "division"
#define FUTURE_ABSOLUTE_IMPORT "absolute_import"
#define FUTURE_WITH_STATEMENT "with_statement"
+#define FUTURE_PRINT_FUNCTION "print_function"
+
struct _mod; /* Declare the existence of this type */
PyAPI_FUNC(PyCodeObject *) PyAST_Compile(struct _mod *, const char *,
diff --git a/Include/parsetok.h b/Include/parsetok.h
index 2b4ce1e..808c72c 100644
--- a/Include/parsetok.h
+++ b/Include/parsetok.h
@@ -27,6 +27,10 @@
#define PyPARSE_WITH_IS_KEYWORD 0x0003
#endif
+#define PyPARSE_PRINT_IS_FUNCTION 0x0004
+
+
+
PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int,
perrdetail *);
PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int,
diff --git a/Include/pythonrun.h b/Include/pythonrun.h
index 0164088..f2105b8 100644
--- a/Include/pythonrun.h
+++ b/Include/pythonrun.h
@@ -8,7 +8,7 @@
#endif
#define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \
- CO_FUTURE_WITH_STATEMENT)
+ CO_FUTURE_WITH_STATEMENT|CO_FUTURE_PRINT_FUNCTION)
#define PyCF_MASK_OBSOLETE (CO_NESTED)
#define PyCF_SOURCE_IS_UTF8 0x0100
#define PyCF_DONT_IMPLY_DEDENT 0x0200