[Python-checkins] r51767 - in python/trunk: Grammar/Grammar Include/code.h Include/parsetok.h Lib/plat-mac/aetools.py Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py Lib/plat-sunos5/STROPTS.py Misc/NEWS Parser/parsetok.c Python/ast.c Python/graminit.c Python/pythonrun.c

neal.norwitz python-checkins at python.org
Wed Sep 6 08:28:09 CEST 2006


Author: neal.norwitz
Date: Wed Sep  6 08:28:06 2006
New Revision: 51767

Modified:
   python/trunk/Grammar/Grammar
   python/trunk/Include/code.h
   python/trunk/Include/parsetok.h
   python/trunk/Lib/plat-mac/aetools.py
   python/trunk/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py
   python/trunk/Lib/plat-sunos5/STROPTS.py
   python/trunk/Misc/NEWS
   python/trunk/Parser/parsetok.c
   python/trunk/Python/ast.c
   python/trunk/Python/graminit.c
   python/trunk/Python/pythonrun.c
Log:
with and as are now keywords.  There are some generated files I can't recreate.

Modified: python/trunk/Grammar/Grammar
==============================================================================
--- python/trunk/Grammar/Grammar	(original)
+++ python/trunk/Grammar/Grammar	Wed Sep  6 08:28:06 2006
@@ -64,8 +64,8 @@
 import_name: 'import' dotted_as_names
 import_from: ('from' ('.'* dotted_name | '.'+)
               'import' ('*' | '(' import_as_names ')' | import_as_names))
-import_as_name: NAME [('as' | NAME) NAME]
-dotted_as_name: dotted_name [('as' | NAME) NAME]
+import_as_name: NAME ['as' NAME]
+dotted_as_name: dotted_name ['as' NAME]
 import_as_names: import_as_name (',' import_as_name)* [',']
 dotted_as_names: dotted_as_name (',' dotted_as_name)*
 dotted_name: NAME ('.' NAME)*
@@ -83,7 +83,7 @@
 	    ['finally' ':' suite] |
 	   'finally' ':' suite))
 with_stmt: 'with' test [ with_var ] ':' suite
-with_var: ('as' | NAME) expr
+with_var: 'as' expr
 # NB compile.c makes sure that the default except clause is last
 except_clause: 'except' [test [',' test]]
 suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT

Modified: python/trunk/Include/code.h
==============================================================================
--- python/trunk/Include/code.h	(original)
+++ python/trunk/Include/code.h	Wed Sep  6 08:28:06 2006
@@ -52,7 +52,9 @@
 /* This should be defined if a future statement modifies the syntax.
    For example, when a keyword is added.
 */
+#if 0
 #define PY_PARSER_REQUIRES_FUTURE_KEYWORD
+#endif
 
 #define CO_MAXBLOCKS 20 /* Max static block nesting within a function */
 

Modified: python/trunk/Include/parsetok.h
==============================================================================
--- python/trunk/Include/parsetok.h	(original)
+++ python/trunk/Include/parsetok.h	Wed Sep  6 08:28:06 2006
@@ -23,7 +23,9 @@
 
 #define PyPARSE_DONT_IMPLY_DEDENT	0x0002
 
+#if 0
 #define PyPARSE_WITH_IS_KEYWORD		0x0003
+#endif
 
 PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int,
                                               perrdetail *);

Modified: python/trunk/Lib/plat-mac/aetools.py
==============================================================================
--- python/trunk/Lib/plat-mac/aetools.py	(original)
+++ python/trunk/Lib/plat-mac/aetools.py	Wed Sep  6 08:28:06 2006
@@ -233,7 +233,7 @@
         """Send 'activate' command"""
         self.send('misc', 'actv')
 
-    def _get(self, _object, as=None, _attributes={}):
+    def _get(self, _object, asfile=None, _attributes={}):
         """_get: get data from an object
         Required argument: the object
         Keyword argument _attributes: AppleEvent attribute dictionary
@@ -243,8 +243,8 @@
         _subcode = 'getd'
 
         _arguments = {'----':_object}
-        if as:
-            _arguments['rtyp'] = mktype(as)
+        if asfile:
+            _arguments['rtyp'] = mktype(asfile)
 
         _reply, _arguments, _attributes = self.send(_code, _subcode,
                 _arguments, _attributes)
@@ -253,8 +253,8 @@
 
         if _arguments.has_key('----'):
             return _arguments['----']
-            if as:
-                item.__class__ = as
+            if asfile:
+                item.__class__ = asfile
             return item
 
     get = _get

Modified: python/trunk/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py
==============================================================================
--- python/trunk/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py	(original)
+++ python/trunk/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py	Wed Sep  6 08:28:06 2006
@@ -300,7 +300,7 @@
         if _arguments.has_key('----'):
             return _arguments['----']
 
-    def as(self, _object, _attributes={}, **_arguments):
+    def as_(self, _object, _attributes={}, **_arguments):
         """as: Coercion
         Required argument: an AE object reference
         Keyword argument _attributes: AppleEvent attribute dictionary

Modified: python/trunk/Lib/plat-sunos5/STROPTS.py
==============================================================================
--- python/trunk/Lib/plat-sunos5/STROPTS.py	(original)
+++ python/trunk/Lib/plat-sunos5/STROPTS.py	Wed Sep  6 08:28:06 2006
@@ -1550,7 +1550,7 @@
 AS_PAGLCK = 0x80
 AS_CLAIMGAP = 0x40
 AS_UNMAPWAIT = 0x20
-def AS_TYPE_64BIT(as): return \
+def AS_TYPE_64BIT(as_): return \
 
 AS_LREP_LINKEDLIST = 0
 AS_LREP_SKIPLIST = 1

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Wed Sep  6 08:28:06 2006
@@ -30,6 +30,8 @@
   required changing the .pyc magic number.  This means that .pyc files
   generated before 2.5c2 will be regenerated.
 
+- with and as are now keywords.
+
 
 Library
 -------

Modified: python/trunk/Parser/parsetok.c
==============================================================================
--- python/trunk/Parser/parsetok.c	(original)
+++ python/trunk/Parser/parsetok.c	Wed Sep  6 08:28:06 2006
@@ -89,9 +89,7 @@
 	return parsetok(tok, g, start, err_ret, flags);
 }
 
-/* Parse input coming from the given tokenizer structure.
-   Return error code. */
-
+#if 0
 static char with_msg[] =
 "%s:%d: Warning: 'with' will become a reserved keyword in Python 2.6\n";
 
@@ -105,6 +103,10 @@
 		filename = "<string>";
 	PySys_WriteStderr(msg, filename, lineno);
 }
+#endif
+
+/* Parse input coming from the given tokenizer structure.
+   Return error code. */
 
 static node *
 parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,

Modified: python/trunk/Python/ast.c
==============================================================================
--- python/trunk/Python/ast.c	(original)
+++ python/trunk/Python/ast.c	Wed Sep  6 08:28:06 2006
@@ -2190,10 +2190,6 @@
         case import_as_name:
             str = NULL;
             if (NCH(n) == 3) {
-                if (strcmp(STR(CHILD(n, 1)), "as") != 0) {
-                    ast_error(n, "must use 'as' in import");
-                    return NULL;
-                }
                 str = NEW_IDENTIFIER(CHILD(n, 2));
             }
             return alias(NEW_IDENTIFIER(CHILD(n, 0)), str, c->c_arena);
@@ -2206,10 +2202,6 @@
                 alias_ty a = alias_for_import_name(c, CHILD(n, 0));
                 if (!a)
                     return NULL;
-                if (strcmp(STR(CHILD(n, 1)), "as") != 0) {
-                    ast_error(n, "must use 'as' in import");
-                    return NULL;
-                }
                 assert(!a->asname);
                 a->asname = NEW_IDENTIFIER(CHILD(n, 2));
                 return a;
@@ -2848,10 +2840,6 @@
 ast_for_with_var(struct compiling *c, const node *n)
 {
     REQ(n, with_var);
-    if (strcmp(STR(CHILD(n, 0)), "as") != 0) {
-        ast_error(n, "expected \"with [expr] as [var]\"");
-        return NULL;
-    }
     return ast_for_expr(c, CHILD(n, 1));
 }
 

Modified: python/trunk/Python/graminit.c
==============================================================================
--- python/trunk/Python/graminit.c	(original)
+++ python/trunk/Python/graminit.c	Wed Sep  6 08:28:06 2006
@@ -551,9 +551,8 @@
 static arc arcs_27_0[1] = {
 	{19, 1},
 };
-static arc arcs_27_1[3] = {
+static arc arcs_27_1[2] = {
 	{78, 2},
-	{19, 2},
 	{0, 1},
 };
 static arc arcs_27_2[1] = {
@@ -564,16 +563,15 @@
 };
 static state states_27[4] = {
 	{1, arcs_27_0},
-	{3, arcs_27_1},
+	{2, arcs_27_1},
 	{1, arcs_27_2},
 	{1, arcs_27_3},
 };
 static arc arcs_28_0[1] = {
 	{12, 1},
 };
-static arc arcs_28_1[3] = {
+static arc arcs_28_1[2] = {
 	{78, 2},
-	{19, 2},
 	{0, 1},
 };
 static arc arcs_28_2[1] = {
@@ -584,7 +582,7 @@
 };
 static state states_28[4] = {
 	{1, arcs_28_0},
-	{3, arcs_28_1},
+	{2, arcs_28_1},
 	{1, arcs_28_2},
 	{1, arcs_28_3},
 };
@@ -912,9 +910,8 @@
 	{1, arcs_40_4},
 	{1, arcs_40_5},
 };
-static arc arcs_41_0[2] = {
+static arc arcs_41_0[1] = {
 	{78, 1},
-	{19, 1},
 };
 static arc arcs_41_1[1] = {
 	{82, 2},
@@ -923,7 +920,7 @@
 	{0, 2},
 };
 static state states_41[3] = {
-	{2, arcs_41_0},
+	{1, arcs_41_0},
 	{1, arcs_41_1},
 	{1, arcs_41_2},
 };
@@ -1865,7 +1862,7 @@
 	{296, "with_stmt", 0, 6, states_40,
 	 "\000\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000"},
 	{297, "with_var", 0, 3, states_41,
-	 "\000\000\010\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000"},
 	{298, "except_clause", 0, 5, states_42,
 	 "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"},
 	{299, "suite", 0, 5, states_43,

Modified: python/trunk/Python/pythonrun.c
==============================================================================
--- python/trunk/Python/pythonrun.c	(original)
+++ python/trunk/Python/pythonrun.c	Wed Sep  6 08:28:06 2006
@@ -725,9 +725,16 @@
 /* compute parser flags based on compiler flags */
 #define PARSER_FLAGS(flags) \
 	((flags) ? ((((flags)->cf_flags & PyCF_DONT_IMPLY_DEDENT) ? \
+		      PyPARSE_DONT_IMPLY_DEDENT : 0)) : 0)
+
+#if 0
+/* Keep an example of flags with future keyword support. */
+#define PARSER_FLAGS(flags) \
+	((flags) ? ((((flags)->cf_flags & PyCF_DONT_IMPLY_DEDENT) ? \
 		      PyPARSE_DONT_IMPLY_DEDENT : 0) \
 		    | ((flags)->cf_flags & CO_FUTURE_WITH_STATEMENT ? \
 		       PyPARSE_WITH_IS_KEYWORD : 0)) : 0)
+#endif
 
 int
 PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)


More information about the Python-checkins mailing list