Mercurial > cpython-lru_cache-weakref
annotate Parser/Python.asdl @ 73323:dad02a080bbc
Improve byte-compilation in packaging to be independent of -O or -B.
The code I fixed to comply with PEP 3147 still had one bug: When run
under python -O, some paths for pyc files would be pyo, because I called
imp.cache_from_source without explicit debug_override argument in some
places, and under -O that would return .pyo (this is well explained in
the imp docs). Now all code (util.byte_compile, build_py, install_lib)
can create .pyo files according to options given by users,
without interference from the calling Python’s own optimize mode.
On a related topic, I also removed the code that prevented byte
compilation under python -B. The rationale is that packaging gives
control over the creation of pyc files to the user with its own explicit
option, and the behavior should not be changed if the calling Python
happens to run with -B for whatever reason. I will argue that this is a
bug fix and ask to be allowed to backport this change to distutils.
Finally, I moved one nugget of information about the --compile and
--optimize options from the source into the doc. It clears up a
misunderstanding that I (and maybe other people) had.
| author | Éric Araujo <merwok@netwok.org> |
|---|---|
| date | Thu, 03 Nov 2011 05:08:28 +0100 |
| parents | f578ca44193d |
| children | d64ac9ab4cd0 |
| rev | line source |
|---|---|
|
71792
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71363
diff
changeset
|
1 -- ASDL's five builtin types are identifier, int, string, bytes, object |
| 35742 | 2 |
|
68412
0daa6ba25d9b
convert ast versioning to mercurial
Benjamin Peterson <benjamin@python.org>
parents:
62447
diff
changeset
|
3 module Python |
| 35742 | 4 { |
| 5 mod = Module(stmt* body) | |
| 6 | Interactive(stmt* body) | |
| 7 | Expression(expr body) | |
| 8 | |
| 9 -- not really an actual node but useful in Jython's typesystem. | |
| 10 | Suite(stmt* body) | |
| 11 | |
| 12 stmt = FunctionDef(identifier name, arguments args, | |
|
41824
24b60622b944
Merged revisions 55407-55513 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41717
diff
changeset
|
13 stmt* body, expr* decorator_list, expr? returns) |
|
41226
19f7ff443718
Implement PEP 3115 -- new metaclass syntax and semantics.
Guido van Rossum <guido@python.org>
parents:
40965
diff
changeset
|
14 | ClassDef(identifier name, |
|
19f7ff443718
Implement PEP 3115 -- new metaclass syntax and semantics.
Guido van Rossum <guido@python.org>
parents:
40965
diff
changeset
|
15 expr* bases, |
|
19f7ff443718
Implement PEP 3115 -- new metaclass syntax and semantics.
Guido van Rossum <guido@python.org>
parents:
40965
diff
changeset
|
16 keyword* keywords, |
|
19f7ff443718
Implement PEP 3115 -- new metaclass syntax and semantics.
Guido van Rossum <guido@python.org>
parents:
40965
diff
changeset
|
17 expr? starargs, |
|
19f7ff443718
Implement PEP 3115 -- new metaclass syntax and semantics.
Guido van Rossum <guido@python.org>
parents:
40965
diff
changeset
|
18 expr? kwargs, |
|
41824
24b60622b944
Merged revisions 55407-55513 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41717
diff
changeset
|
19 stmt* body, |
|
62447
4e24dfedf80c
Merged revisions 82160 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54918
diff
changeset
|
20 expr* decorator_list) |
| 35742 | 21 | Return(expr? value) |
| 22 | |
| 23 | Delete(expr* targets) | |
| 24 | Assign(expr* targets, expr value) | |
| 25 | AugAssign(expr target, operator op, expr value) | |
| 26 | |
| 27 -- use 'orelse' because else is a keyword in target languages | |
| 28 | For(expr target, expr iter, stmt* body, stmt* orelse) | |
| 29 | While(expr test, stmt* body, stmt* orelse) | |
| 30 | If(expr test, stmt* body, stmt* orelse) | |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68412
diff
changeset
|
31 | With(withitem* items, stmt* body) |
| 35742 | 32 |
|
43102
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42193
diff
changeset
|
33 | Raise(expr? exc, expr? cause) |
|
70499
e0e663132363
unify TryExcept and TryFinally (closes #12199)
Benjamin Peterson <benjamin@python.org>
parents:
70438
diff
changeset
|
34 | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody) |
| 35742 | 35 | Assert(expr test, expr? msg) |
| 36 | |
| 37 | Import(alias* names) | |
|
54918
0704f15b4682
Merged revisions 73376,73393,73398,73400,73404-73405,73409,73419-73421,73432,73457,73460,73485-73486,73488-73489,73501-73502,73513-73514 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
50076
diff
changeset
|
38 | ImportFrom(identifier? module, alias* names, int? level) |
| 35742 | 39 |
| 40 | Global(identifier* names) | |
|
40965
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40940
diff
changeset
|
41 | Nonlocal(identifier* names) |
| 35742 | 42 | Expr(expr value) |
| 43 | Pass | Break | Continue | |
| 44 | |
| 45 -- XXX Jython will be different | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36712
diff
changeset
|
46 -- col_offset is the byte offset in the utf8 string the parser uses |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36712
diff
changeset
|
47 attributes (int lineno, int col_offset) |
| 35742 | 48 |
| 49 -- BoolOp() can use left & right? | |
| 50 expr = BoolOp(boolop op, expr* values) | |
| 51 | BinOp(expr left, operator op, expr right) | |
| 52 | UnaryOp(unaryop op, expr operand) | |
| 53 | Lambda(arguments args, expr body) | |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36418
diff
changeset
|
54 | IfExp(expr test, expr body, expr orelse) |
| 35742 | 55 | Dict(expr* keys, expr* values) |
|
39693
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39678
diff
changeset
|
56 | Set(expr* elts) |
| 35742 | 57 | ListComp(expr elt, comprehension* generators) |
|
42193
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41824
diff
changeset
|
58 | SetComp(expr elt, comprehension* generators) |
|
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41824
diff
changeset
|
59 | DictComp(expr key, expr value, comprehension* generators) |
| 35742 | 60 | GeneratorExp(expr elt, comprehension* generators) |
|
36418
a625e8876407
Improved handling of syntax errors.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
35871
diff
changeset
|
61 -- the grammar constrains where yield expressions can occur |
| 35742 | 62 | Yield(expr? value) |
| 63 -- need sequences for compare to distinguish between | |
| 64 -- x < 4 < 3 and (x < 4) < 3 | |
| 65 | Compare(expr left, cmpop* ops, expr* comparators) | |
| 66 | Call(expr func, expr* args, keyword* keywords, | |
| 67 expr? starargs, expr? kwargs) | |
| 68 | Num(object n) -- a number as a PyObject. | |
| 69 | Str(string s) -- need to specify raw, unicode, etc? | |
|
71792
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71363
diff
changeset
|
70 | Bytes(bytes s) |
|
39783
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
71 | Ellipsis |
| 35742 | 72 -- other literals? bools? |
| 73 | |
| 74 -- the following expression can appear in assignment context | |
| 75 | Attribute(expr value, identifier attr, expr_context ctx) | |
| 76 | Subscript(expr value, slice slice, expr_context ctx) | |
|
41699
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41464
diff
changeset
|
77 | Starred(expr value, expr_context ctx) |
| 35742 | 78 | Name(identifier id, expr_context ctx) |
| 79 | List(expr* elts, expr_context ctx) | |
|
40893
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40788
diff
changeset
|
80 | Tuple(expr* elts, expr_context ctx) |
| 35742 | 81 |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36712
diff
changeset
|
82 -- col_offset is the byte offset in the utf8 string the parser uses |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36712
diff
changeset
|
83 attributes (int lineno, int col_offset) |
| 35742 | 84 |
| 85 expr_context = Load | Store | Del | AugLoad | AugStore | Param | |
| 86 | |
|
39783
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
87 slice = Slice(expr? lower, expr? upper, expr? step) |
| 35742 | 88 | ExtSlice(slice* dims) |
| 89 | Index(expr value) | |
| 90 | |
| 91 boolop = And | Or | |
| 92 | |
| 93 operator = Add | Sub | Mult | Div | Mod | Pow | LShift | |
| 94 | RShift | BitOr | BitXor | BitAnd | FloorDiv | |
| 95 | |
| 96 unaryop = Invert | Not | UAdd | USub | |
| 97 | |
| 98 cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn | |
| 99 | |
| 100 comprehension = (expr target, expr iter, expr* ifs) | |
| 101 | |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
43102
diff
changeset
|
102 excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body) |
|
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
43102
diff
changeset
|
103 attributes (int lineno, int col_offset) |
| 35742 | 104 |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
105 arguments = (arg* args, identifier? vararg, expr? varargannotation, |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
106 arg* kwonlyargs, identifier? kwarg, |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
107 expr? kwargannotation, expr* defaults, |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
108 expr* kw_defaults) |
|
41717
9ad84070b22d
Merged revisions 55328-55341 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41699
diff
changeset
|
109 arg = (identifier arg, expr? annotation) |
| 35742 | 110 |
| 111 -- keyword arguments supplied to call | |
| 112 keyword = (identifier arg, expr value) | |
| 113 | |
| 114 -- import name with optional 'as' alias. | |
| 115 alias = (identifier name, identifier? asname) | |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68412
diff
changeset
|
116 |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68412
diff
changeset
|
117 withitem = (expr context_expr, expr? optional_vars) |
| 35742 | 118 } |
|
40895
bd1419e94773
Touch file to regenerate Python-ast.[ch]
Thomas Wouters <thomas@python.org>
parents:
40894
diff
changeset
|
119 |
