Skip to content

Commit 9eef44c

Browse files
author
neal.norwitz
committed
with and as are now keywords. There are some generated files I can't recreate.
git-svn-id: http://svn.python.org/projects/python/trunk@51767 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent b92a416 commit 9eef44c

11 files changed

Lines changed: 35 additions & 35 deletions

File tree

Grammar/Grammar

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ import_stmt: import_name | import_from
6464
import_name: 'import' dotted_as_names
6565
import_from: ('from' ('.'* dotted_name | '.'+)
6666
'import' ('*' | '(' import_as_names ')' | import_as_names))
67-
import_as_name: NAME [('as' | NAME) NAME]
68-
dotted_as_name: dotted_name [('as' | NAME) NAME]
67+
import_as_name: NAME ['as' NAME]
68+
dotted_as_name: dotted_name ['as' NAME]
6969
import_as_names: import_as_name (',' import_as_name)* [',']
7070
dotted_as_names: dotted_as_name (',' dotted_as_name)*
7171
dotted_name: NAME ('.' NAME)*
@@ -83,7 +83,7 @@ try_stmt: ('try' ':' suite
8383
['finally' ':' suite] |
8484
'finally' ':' suite))
8585
with_stmt: 'with' test [ with_var ] ':' suite
86-
with_var: ('as' | NAME) expr
86+
with_var: 'as' expr
8787
# NB compile.c makes sure that the default except clause is last
8888
except_clause: 'except' [test [',' test]]
8989
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT

Include/code.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ typedef struct {
5252
/* This should be defined if a future statement modifies the syntax.
5353
For example, when a keyword is added.
5454
*/
55+
#if 0
5556
#define PY_PARSER_REQUIRES_FUTURE_KEYWORD
57+
#endif
5658

5759
#define CO_MAXBLOCKS 20 /* Max static block nesting within a function */
5860

Include/parsetok.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ typedef struct {
2323

2424
#define PyPARSE_DONT_IMPLY_DEDENT 0x0002
2525

26+
#if 0
2627
#define PyPARSE_WITH_IS_KEYWORD 0x0003
28+
#endif
2729

2830
PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int,
2931
perrdetail *);

Lib/plat-mac/aetools.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def activate(self):
233233
"""Send 'activate' command"""
234234
self.send('misc', 'actv')
235235

236-
def _get(self, _object, as=None, _attributes={}):
236+
def _get(self, _object, asfile=None, _attributes={}):
237237
"""_get: get data from an object
238238
Required argument: the object
239239
Keyword argument _attributes: AppleEvent attribute dictionary
@@ -243,8 +243,8 @@ def _get(self, _object, as=None, _attributes={}):
243243
_subcode = 'getd'
244244

245245
_arguments = {'----':_object}
246-
if as:
247-
_arguments['rtyp'] = mktype(as)
246+
if asfile:
247+
_arguments['rtyp'] = mktype(asfile)
248248

249249
_reply, _arguments, _attributes = self.send(_code, _subcode,
250250
_arguments, _attributes)
@@ -253,8 +253,8 @@ def _get(self, _object, as=None, _attributes={}):
253253

254254
if _arguments.has_key('----'):
255255
return _arguments['----']
256-
if as:
257-
item.__class__ = as
256+
if asfile:
257+
item.__class__ = asfile
258258
return item
259259

260260
get = _get

Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def and_(self, _object, _attributes={}, **_arguments):
300300
if _arguments.has_key('----'):
301301
return _arguments['----']
302302

303-
def as(self, _object, _attributes={}, **_arguments):
303+
def as_(self, _object, _attributes={}, **_arguments):
304304
"""as: Coercion
305305
Required argument: an AE object reference
306306
Keyword argument _attributes: AppleEvent attribute dictionary

Lib/plat-sunos5/STROPTS.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,7 @@ def seg_pages(seg): return \
15501550
AS_PAGLCK = 0x80
15511551
AS_CLAIMGAP = 0x40
15521552
AS_UNMAPWAIT = 0x20
1553-
def AS_TYPE_64BIT(as): return \
1553+
def AS_TYPE_64BIT(as_): return \
15541554

15551555
AS_LREP_LINKEDLIST = 0
15561556
AS_LREP_SKIPLIST = 1

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Core and builtins
3030
required changing the .pyc magic number. This means that .pyc files
3131
generated before 2.5c2 will be regenerated.
3232

33+
- with and as are now keywords.
34+
3335

3436
Library
3537
-------

Parser/parsetok.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ PyParser_ParseFileFlags(FILE *fp, const char *filename, grammar *g, int start,
8989
return parsetok(tok, g, start, err_ret, flags);
9090
}
9191

92-
/* Parse input coming from the given tokenizer structure.
93-
Return error code. */
94-
92+
#if 0
9593
static char with_msg[] =
9694
"%s:%d: Warning: 'with' will become a reserved keyword in Python 2.6\n";
9795

@@ -105,6 +103,10 @@ warn(const char *msg, const char *filename, int lineno)
105103
filename = "<string>";
106104
PySys_WriteStderr(msg, filename, lineno);
107105
}
106+
#endif
107+
108+
/* Parse input coming from the given tokenizer structure.
109+
Return error code. */
108110

109111
static node *
110112
parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,

Python/ast.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,10 +2190,6 @@ alias_for_import_name(struct compiling *c, const node *n)
21902190
case import_as_name:
21912191
str = NULL;
21922192
if (NCH(n) == 3) {
2193-
if (strcmp(STR(CHILD(n, 1)), "as") != 0) {
2194-
ast_error(n, "must use 'as' in import");
2195-
return NULL;
2196-
}
21972193
str = NEW_IDENTIFIER(CHILD(n, 2));
21982194
}
21992195
return alias(NEW_IDENTIFIER(CHILD(n, 0)), str, c->c_arena);
@@ -2206,10 +2202,6 @@ alias_for_import_name(struct compiling *c, const node *n)
22062202
alias_ty a = alias_for_import_name(c, CHILD(n, 0));
22072203
if (!a)
22082204
return NULL;
2209-
if (strcmp(STR(CHILD(n, 1)), "as") != 0) {
2210-
ast_error(n, "must use 'as' in import");
2211-
return NULL;
2212-
}
22132205
assert(!a->asname);
22142206
a->asname = NEW_IDENTIFIER(CHILD(n, 2));
22152207
return a;
@@ -2848,10 +2840,6 @@ static expr_ty
28482840
ast_for_with_var(struct compiling *c, const node *n)
28492841
{
28502842
REQ(n, with_var);
2851-
if (strcmp(STR(CHILD(n, 0)), "as") != 0) {
2852-
ast_error(n, "expected \"with [expr] as [var]\"");
2853-
return NULL;
2854-
}
28552843
return ast_for_expr(c, CHILD(n, 1));
28562844
}
28572845

Python/graminit.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,8 @@ static state states_26[8] = {
551551
static arc arcs_27_0[1] = {
552552
{19, 1},
553553
};
554-
static arc arcs_27_1[3] = {
554+
static arc arcs_27_1[2] = {
555555
{78, 2},
556-
{19, 2},
557556
{0, 1},
558557
};
559558
static arc arcs_27_2[1] = {
@@ -564,16 +563,15 @@ static arc arcs_27_3[1] = {
564563
};
565564
static state states_27[4] = {
566565
{1, arcs_27_0},
567-
{3, arcs_27_1},
566+
{2, arcs_27_1},
568567
{1, arcs_27_2},
569568
{1, arcs_27_3},
570569
};
571570
static arc arcs_28_0[1] = {
572571
{12, 1},
573572
};
574-
static arc arcs_28_1[3] = {
573+
static arc arcs_28_1[2] = {
575574
{78, 2},
576-
{19, 2},
577575
{0, 1},
578576
};
579577
static arc arcs_28_2[1] = {
@@ -584,7 +582,7 @@ static arc arcs_28_3[1] = {
584582
};
585583
static state states_28[4] = {
586584
{1, arcs_28_0},
587-
{3, arcs_28_1},
585+
{2, arcs_28_1},
588586
{1, arcs_28_2},
589587
{1, arcs_28_3},
590588
};
@@ -912,9 +910,8 @@ static state states_40[6] = {
912910
{1, arcs_40_4},
913911
{1, arcs_40_5},
914912
};
915-
static arc arcs_41_0[2] = {
913+
static arc arcs_41_0[1] = {
916914
{78, 1},
917-
{19, 1},
918915
};
919916
static arc arcs_41_1[1] = {
920917
{82, 2},
@@ -923,7 +920,7 @@ static arc arcs_41_2[1] = {
923920
{0, 2},
924921
};
925922
static state states_41[3] = {
926-
{2, arcs_41_0},
923+
{1, arcs_41_0},
927924
{1, arcs_41_1},
928925
{1, arcs_41_2},
929926
};
@@ -1865,7 +1862,7 @@ static dfa dfas[84] = {
18651862
{296, "with_stmt", 0, 6, states_40,
18661863
"\000\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000"},
18671864
{297, "with_var", 0, 3, states_41,
1868-
"\000\000\010\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000"},
1865+
"\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000"},
18691866
{298, "except_clause", 0, 5, states_42,
18701867
"\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"},
18711868
{299, "suite", 0, 5, states_43,

0 commit comments

Comments
 (0)