Index: Python/future.c =================================================================== --- Python/future.c (revision 53285) +++ Python/future.c (working copy) @@ -33,6 +33,8 @@ ff->ff_features |= CO_FUTURE_ABSOLUTE_IMPORT; } else if (strcmp(feature, FUTURE_WITH_STATEMENT) == 0) { ff->ff_features |= CO_FUTURE_WITH_STATEMENT; + } else if (strcmp(feature, FUTURE_PRINT_FUNCTION) == 0) { + ff->ff_features |= CO_FUTURE_PRINT_FUNCTION; } else if (strcmp(feature, "braces") == 0) { PyErr_SetString(PyExc_SyntaxError, "not a chance"); Index: Include/code.h =================================================================== --- Include/code.h (revision 53285) +++ Include/code.h (working copy) @@ -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 Index: Include/parsetok.h =================================================================== --- Include/parsetok.h (revision 53285) +++ Include/parsetok.h (working copy) @@ -23,7 +23,7 @@ #define PyPARSE_DONT_IMPLY_DEDENT 0x0002 -#if 0 +#if 1 #define PyPARSE_WITH_IS_KEYWORD 0x0003 #endif Index: Include/pythonrun.h =================================================================== --- Include/pythonrun.h (revision 53285) +++ Include/pythonrun.h (working copy) @@ -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 Index: Include/compile.h =================================================================== --- Include/compile.h (revision 53285) +++ Include/compile.h (working copy) @@ -24,6 +24,7 @@ #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 *, Index: Parser/parsetok.c =================================================================== --- Parser/parsetok.c (revision 53285) +++ Parser/parsetok.c (working copy) @@ -173,6 +173,7 @@ len == 6 && str[0] == 'i' && strcmp(str, "import") == 0) handling_import = 1; +#if 0 /* Warn about with as NAME */ if (type == NAME && !(ps->p_flags & CO_FUTURE_WITH_STATEMENT)) { @@ -188,6 +189,7 @@ len == 4 && str[0] == 'w' && strcmp(str, "with") == 0) handling_with = 1; #endif +#endif if (a >= tok->line_start) col_offset = a - tok->line_start; else Index: Parser/parser.c =================================================================== --- Parser/parser.c (revision 53285) +++ Parser/parser.c (working copy) @@ -149,13 +152,20 @@ strcmp(l->lb_str, s) != 0) continue; #ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD + if ((ps->p_flags & CO_FUTURE_PRINT_FUNCTION) && + s[0] == 'p' && strcmp(s, "print") == 0) { + break; /* no longer a keyword */ + } +#if 0 if (!(ps->p_flags & CO_FUTURE_WITH_STATEMENT)) { if (s[0] == 'w' && strcmp(s, "with") == 0) break; /* not a keyword yet */ else if (s[0] == 'a' && strcmp(s, "as") == 0) break; /* not a keyword yet */ - } + + } #endif +#endif D(printf("It's a keyword\n")); return n - i; } @@ -208,6 +218,10 @@ strcmp(STR(CHILD(cch, 0)), "with_statement") == 0) { ps->p_flags |= CO_FUTURE_WITH_STATEMENT; break; + } else if (NCH(cch) >= 1 && TYPE(CHILD(cch, 0)) == NAME && + strcmp(STR(CHILD(cch, 0)), "print_function") == 0) { + ps->p_flags |= CO_FUTURE_PRINT_FUNCTION; + break; } } } Index: Lib/__future__.py =================================================================== --- Lib/__future__.py (revision 53285) +++ Lib/__future__.py (working copy) @@ -53,6 +53,7 @@ "division", "absolute_import", "with_statement", + "print_function", ] __all__ = ["all_feature_names"] + all_feature_names @@ -66,6 +67,7 @@ CO_FUTURE_DIVISION = 0x2000 # division CO_FUTURE_ABSOLUTE_IMPORT = 0x4000 # perform absolute imports by default CO_FUTURE_WITH_STATEMENT = 0x8000 # with statement +CO_FUTURE_PRINT_FUNCTION = 0x10000 # with statement class _Feature: def __init__(self, optionalRelease, mandatoryRelease, compiler_flag): @@ -114,3 +116,7 @@ with_statement = _Feature((2, 5, 0, "alpha", 1), (2, 6, 0, "alpha", 0), CO_FUTURE_WITH_STATEMENT) + +print_function = _Feature((2, 6, 0, "alpha", 1), + (3, 0, 0, "alpha", 0), + CO_FUTURE_PRINT_FUNCTION)