Mercurial > cpython-lru_cache-weakref
annotate Python/Python-ast.c @ 84852:d14f40c87438 3.3
Parser/asdl_c.py: use Py_CLEAR()
| author | Victor Stinner <victor.stinner@gmail.com> |
|---|---|
| date | Sat, 27 Jul 2013 00:03:47 +0200 |
| parents | f2d557484906 |
| children | 65121aa79ab3 9d26379db328 |
| rev | line source |
|---|---|
|
40893
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40819
diff
changeset
|
1 /* File automatically generated by Parser/asdl_c.py. */ |
|
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40819
diff
changeset
|
2 |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
3 #include <stddef.h> |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
4 |
| 35742 | 5 #include "Python.h" |
| 6 #include "Python-ast.h" | |
| 7 | |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
8 static PyTypeObject AST_type; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
9 static PyTypeObject *mod_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
10 static PyObject* ast2obj_mod(void*); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
11 static PyTypeObject *Module_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
12 _Py_IDENTIFIER(body); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
13 static char *Module_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
14 "body", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
15 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
16 static PyTypeObject *Interactive_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
17 static char *Interactive_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
18 "body", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
19 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
20 static PyTypeObject *Expression_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
21 static char *Expression_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
22 "body", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
23 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
24 static PyTypeObject *Suite_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
25 static char *Suite_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
26 "body", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
27 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
28 static PyTypeObject *stmt_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
29 _Py_IDENTIFIER(lineno); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
30 _Py_IDENTIFIER(col_offset); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
31 static char *stmt_attributes[] = { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
32 "lineno", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
33 "col_offset", |
| 36669 | 34 }; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
35 static PyObject* ast2obj_stmt(void*); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
36 static PyTypeObject *FunctionDef_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
37 _Py_IDENTIFIER(name); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
38 _Py_IDENTIFIER(args); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
39 _Py_IDENTIFIER(decorator_list); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
40 _Py_IDENTIFIER(returns); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
41 static char *FunctionDef_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
42 "name", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
43 "args", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
44 "body", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
45 "decorator_list", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
46 "returns", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
47 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
48 static PyTypeObject *ClassDef_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
49 _Py_IDENTIFIER(bases); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
50 _Py_IDENTIFIER(keywords); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
51 _Py_IDENTIFIER(starargs); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
52 _Py_IDENTIFIER(kwargs); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
53 static char *ClassDef_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
54 "name", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
55 "bases", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
56 "keywords", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
57 "starargs", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
58 "kwargs", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
59 "body", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
60 "decorator_list", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
61 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
62 static PyTypeObject *Return_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
63 _Py_IDENTIFIER(value); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
64 static char *Return_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
65 "value", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
66 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
67 static PyTypeObject *Delete_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
68 _Py_IDENTIFIER(targets); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
69 static char *Delete_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
70 "targets", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
71 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
72 static PyTypeObject *Assign_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
73 static char *Assign_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
74 "targets", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
75 "value", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
76 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
77 static PyTypeObject *AugAssign_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
78 _Py_IDENTIFIER(target); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
79 _Py_IDENTIFIER(op); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
80 static char *AugAssign_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
81 "target", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
82 "op", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
83 "value", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
84 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
85 static PyTypeObject *For_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
86 _Py_IDENTIFIER(iter); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
87 _Py_IDENTIFIER(orelse); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
88 static char *For_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
89 "target", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
90 "iter", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
91 "body", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
92 "orelse", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
93 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
94 static PyTypeObject *While_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
95 _Py_IDENTIFIER(test); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
96 static char *While_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
97 "test", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
98 "body", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
99 "orelse", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
100 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
101 static PyTypeObject *If_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
102 static char *If_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
103 "test", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
104 "body", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
105 "orelse", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
106 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
107 static PyTypeObject *With_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
108 _Py_IDENTIFIER(items); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
109 static char *With_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
110 "items", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
111 "body", |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
112 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
113 static PyTypeObject *Raise_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
114 _Py_IDENTIFIER(exc); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
115 _Py_IDENTIFIER(cause); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
116 static char *Raise_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
117 "exc", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
118 "cause", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
119 }; |
|
70499
e0e663132363
unify TryExcept and TryFinally (closes #12199)
Benjamin Peterson <benjamin@python.org>
parents:
70439
diff
changeset
|
120 static PyTypeObject *Try_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
121 _Py_IDENTIFIER(handlers); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
122 _Py_IDENTIFIER(finalbody); |
|
70499
e0e663132363
unify TryExcept and TryFinally (closes #12199)
Benjamin Peterson <benjamin@python.org>
parents:
70439
diff
changeset
|
123 static char *Try_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
124 "body", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
125 "handlers", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
126 "orelse", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
127 "finalbody", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
128 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
129 static PyTypeObject *Assert_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
130 _Py_IDENTIFIER(msg); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
131 static char *Assert_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
132 "test", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
133 "msg", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
134 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
135 static PyTypeObject *Import_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
136 _Py_IDENTIFIER(names); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
137 static char *Import_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
138 "names", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
139 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
140 static PyTypeObject *ImportFrom_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
141 _Py_IDENTIFIER(module); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
142 _Py_IDENTIFIER(level); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
143 static char *ImportFrom_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
144 "module", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
145 "names", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
146 "level", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
147 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
148 static PyTypeObject *Global_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
149 static char *Global_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
150 "names", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
151 }; |
|
40965
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
152 static PyTypeObject *Nonlocal_type; |
|
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
153 static char *Nonlocal_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
154 "names", |
|
40965
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
155 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
156 static PyTypeObject *Expr_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
157 static char *Expr_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
158 "value", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
159 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
160 static PyTypeObject *Pass_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
161 static PyTypeObject *Break_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
162 static PyTypeObject *Continue_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
163 static PyTypeObject *expr_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
164 static char *expr_attributes[] = { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
165 "lineno", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
166 "col_offset", |
| 36669 | 167 }; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
168 static PyObject* ast2obj_expr(void*); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
169 static PyTypeObject *BoolOp_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
170 _Py_IDENTIFIER(values); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
171 static char *BoolOp_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
172 "op", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
173 "values", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
174 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
175 static PyTypeObject *BinOp_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
176 _Py_IDENTIFIER(left); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
177 _Py_IDENTIFIER(right); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
178 static char *BinOp_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
179 "left", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
180 "op", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
181 "right", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
182 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
183 static PyTypeObject *UnaryOp_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
184 _Py_IDENTIFIER(operand); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
185 static char *UnaryOp_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
186 "op", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
187 "operand", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
188 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
189 static PyTypeObject *Lambda_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
190 static char *Lambda_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
191 "args", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
192 "body", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
193 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
194 static PyTypeObject *IfExp_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
195 static char *IfExp_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
196 "test", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
197 "body", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
198 "orelse", |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
199 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
200 static PyTypeObject *Dict_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
201 _Py_IDENTIFIER(keys); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
202 static char *Dict_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
203 "keys", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
204 "values", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
205 }; |
|
39693
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
206 static PyTypeObject *Set_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
207 _Py_IDENTIFIER(elts); |
|
39693
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
208 static char *Set_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
209 "elts", |
|
39693
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
210 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
211 static PyTypeObject *ListComp_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
212 _Py_IDENTIFIER(elt); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
213 _Py_IDENTIFIER(generators); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
214 static char *ListComp_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
215 "elt", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
216 "generators", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
217 }; |
|
41464
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
218 static PyTypeObject *SetComp_type; |
|
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
219 static char *SetComp_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
220 "elt", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
221 "generators", |
|
41464
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
222 }; |
|
42193
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
223 static PyTypeObject *DictComp_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
224 _Py_IDENTIFIER(key); |
|
42193
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
225 static char *DictComp_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
226 "key", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
227 "value", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
228 "generators", |
|
42193
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
229 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
230 static PyTypeObject *GeneratorExp_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
231 static char *GeneratorExp_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
232 "elt", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
233 "generators", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
234 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
235 static PyTypeObject *Yield_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
236 static char *Yield_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
237 "value", |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
238 }; |
|
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
239 static PyTypeObject *YieldFrom_type; |
|
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
240 static char *YieldFrom_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
241 "value", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
242 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
243 static PyTypeObject *Compare_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
244 _Py_IDENTIFIER(ops); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
245 _Py_IDENTIFIER(comparators); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
246 static char *Compare_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
247 "left", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
248 "ops", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
249 "comparators", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
250 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
251 static PyTypeObject *Call_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
252 _Py_IDENTIFIER(func); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
253 static char *Call_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
254 "func", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
255 "args", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
256 "keywords", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
257 "starargs", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
258 "kwargs", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
259 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
260 static PyTypeObject *Num_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
261 _Py_IDENTIFIER(n); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
262 static char *Num_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
263 "n", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
264 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
265 static PyTypeObject *Str_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
266 _Py_IDENTIFIER(s); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
267 static char *Str_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
268 "s", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
269 }; |
| 40894 | 270 static PyTypeObject *Bytes_type; |
| 271 static char *Bytes_fields[]={ | |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
272 "s", |
| 40894 | 273 }; |
|
39783
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
274 static PyTypeObject *Ellipsis_type; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
275 static PyTypeObject *Attribute_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
276 _Py_IDENTIFIER(attr); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
277 _Py_IDENTIFIER(ctx); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
278 static char *Attribute_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
279 "value", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
280 "attr", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
281 "ctx", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
282 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
283 static PyTypeObject *Subscript_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
284 _Py_IDENTIFIER(slice); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
285 static char *Subscript_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
286 "value", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
287 "slice", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
288 "ctx", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
289 }; |
|
41699
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
290 static PyTypeObject *Starred_type; |
|
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
291 static char *Starred_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
292 "value", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
293 "ctx", |
|
41699
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
294 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
295 static PyTypeObject *Name_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
296 _Py_IDENTIFIER(id); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
297 static char *Name_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
298 "id", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
299 "ctx", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
300 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
301 static PyTypeObject *List_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
302 static char *List_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
303 "elts", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
304 "ctx", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
305 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
306 static PyTypeObject *Tuple_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
307 static char *Tuple_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
308 "elts", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
309 "ctx", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
310 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
311 static PyTypeObject *expr_context_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
312 static PyObject *Load_singleton, *Store_singleton, *Del_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
313 *AugLoad_singleton, *AugStore_singleton, *Param_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
314 static PyObject* ast2obj_expr_context(expr_context_ty); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
315 static PyTypeObject *Load_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
316 static PyTypeObject *Store_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
317 static PyTypeObject *Del_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
318 static PyTypeObject *AugLoad_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
319 static PyTypeObject *AugStore_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
320 static PyTypeObject *Param_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
321 static PyTypeObject *slice_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
322 static PyObject* ast2obj_slice(void*); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
323 static PyTypeObject *Slice_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
324 _Py_IDENTIFIER(lower); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
325 _Py_IDENTIFIER(upper); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
326 _Py_IDENTIFIER(step); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
327 static char *Slice_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
328 "lower", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
329 "upper", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
330 "step", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
331 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
332 static PyTypeObject *ExtSlice_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
333 _Py_IDENTIFIER(dims); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
334 static char *ExtSlice_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
335 "dims", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
336 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
337 static PyTypeObject *Index_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
338 static char *Index_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
339 "value", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
340 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
341 static PyTypeObject *boolop_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
342 static PyObject *And_singleton, *Or_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
343 static PyObject* ast2obj_boolop(boolop_ty); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
344 static PyTypeObject *And_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
345 static PyTypeObject *Or_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
346 static PyTypeObject *operator_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
347 static PyObject *Add_singleton, *Sub_singleton, *Mult_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
348 *Div_singleton, *Mod_singleton, *Pow_singleton, *LShift_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
349 *RShift_singleton, *BitOr_singleton, *BitXor_singleton, *BitAnd_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
350 *FloorDiv_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
351 static PyObject* ast2obj_operator(operator_ty); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
352 static PyTypeObject *Add_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
353 static PyTypeObject *Sub_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
354 static PyTypeObject *Mult_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
355 static PyTypeObject *Div_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
356 static PyTypeObject *Mod_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
357 static PyTypeObject *Pow_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
358 static PyTypeObject *LShift_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
359 static PyTypeObject *RShift_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
360 static PyTypeObject *BitOr_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
361 static PyTypeObject *BitXor_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
362 static PyTypeObject *BitAnd_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
363 static PyTypeObject *FloorDiv_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
364 static PyTypeObject *unaryop_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
365 static PyObject *Invert_singleton, *Not_singleton, *UAdd_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
366 *USub_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
367 static PyObject* ast2obj_unaryop(unaryop_ty); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
368 static PyTypeObject *Invert_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
369 static PyTypeObject *Not_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
370 static PyTypeObject *UAdd_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
371 static PyTypeObject *USub_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
372 static PyTypeObject *cmpop_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
373 static PyObject *Eq_singleton, *NotEq_singleton, *Lt_singleton, *LtE_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
374 *Gt_singleton, *GtE_singleton, *Is_singleton, *IsNot_singleton, *In_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
375 *NotIn_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
376 static PyObject* ast2obj_cmpop(cmpop_ty); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
377 static PyTypeObject *Eq_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
378 static PyTypeObject *NotEq_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
379 static PyTypeObject *Lt_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
380 static PyTypeObject *LtE_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
381 static PyTypeObject *Gt_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
382 static PyTypeObject *GtE_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
383 static PyTypeObject *Is_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
384 static PyTypeObject *IsNot_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
385 static PyTypeObject *In_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
386 static PyTypeObject *NotIn_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
387 static PyTypeObject *comprehension_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
388 static PyObject* ast2obj_comprehension(void*); |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
389 _Py_IDENTIFIER(ifs); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
390 static char *comprehension_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
391 "target", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
392 "iter", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
393 "ifs", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
394 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
395 static PyTypeObject *excepthandler_type; |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
396 static char *excepthandler_attributes[] = { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
397 "lineno", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
398 "col_offset", |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
399 }; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
400 static PyObject* ast2obj_excepthandler(void*); |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
401 static PyTypeObject *ExceptHandler_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
402 _Py_IDENTIFIER(type); |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
403 static char *ExceptHandler_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
404 "type", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
405 "name", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
406 "body", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
407 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
408 static PyTypeObject *arguments_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
409 static PyObject* ast2obj_arguments(void*); |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
410 _Py_IDENTIFIER(vararg); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
411 _Py_IDENTIFIER(varargannotation); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
412 _Py_IDENTIFIER(kwonlyargs); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
413 _Py_IDENTIFIER(kwarg); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
414 _Py_IDENTIFIER(kwargannotation); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
415 _Py_IDENTIFIER(defaults); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
416 _Py_IDENTIFIER(kw_defaults); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
417 static char *arguments_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
418 "args", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
419 "vararg", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
420 "varargannotation", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
421 "kwonlyargs", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
422 "kwarg", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
423 "kwargannotation", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
424 "defaults", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
425 "kw_defaults", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
426 }; |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
427 static PyTypeObject *arg_type; |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
428 static PyObject* ast2obj_arg(void*); |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
429 _Py_IDENTIFIER(arg); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
430 _Py_IDENTIFIER(annotation); |
|
41717
9ad84070b22d
Merged revisions 55328-55341 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41699
diff
changeset
|
431 static char *arg_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
432 "arg", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
433 "annotation", |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
434 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
435 static PyTypeObject *keyword_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
436 static PyObject* ast2obj_keyword(void*); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
437 static char *keyword_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
438 "arg", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
439 "value", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
440 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
441 static PyTypeObject *alias_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
442 static PyObject* ast2obj_alias(void*); |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
443 _Py_IDENTIFIER(asname); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
444 static char *alias_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
445 "name", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
446 "asname", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
447 }; |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
448 static PyTypeObject *withitem_type; |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
449 static PyObject* ast2obj_withitem(void*); |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
450 _Py_IDENTIFIER(context_expr); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
451 _Py_IDENTIFIER(optional_vars); |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
452 static char *withitem_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
453 "context_expr", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
454 "optional_vars", |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
455 }; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
456 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
457 |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
458 typedef struct { |
|
75567
6bee4eea1efa
Try to fix compilation of Python-ast.c on Visual Studio 2008
Victor Stinner <victor.stinner@gmail.com>
parents:
75542
diff
changeset
|
459 PyObject_HEAD |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
460 PyObject *dict; |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
461 } AST_object; |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
462 |
| 75686 | 463 static void |
| 464 ast_dealloc(AST_object *self) | |
| 465 { | |
| 466 Py_CLEAR(self->dict); | |
|
77998
048d8d9aecf1
Issue #15291: Fix a memory leak where AST nodes where not properly deallocated.
Antoine Pitrou <solipsis@pitrou.net>
parents:
76964
diff
changeset
|
467 Py_TYPE(self)->tp_free(self); |
| 75686 | 468 } |
| 469 | |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
470 static int |
|
78006
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
471 ast_traverse(AST_object *self, visitproc visit, void *arg) |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
472 { |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
473 Py_VISIT(self->dict); |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
474 return 0; |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
475 } |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
476 |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
477 static void |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
478 ast_clear(AST_object *self) |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
479 { |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
480 Py_CLEAR(self->dict); |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
481 } |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
482 |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
483 static int |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
484 ast_type_init(PyObject *self, PyObject *args, PyObject *kw) |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
485 { |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
486 _Py_IDENTIFIER(_fields); |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
487 Py_ssize_t i, numfields = 0; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
488 int res = -1; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
489 PyObject *key, *value, *fields; |
|
72848
81380082d216
Use identifier API for PyObject_GetAttrString.
Martin v. Löwis <martin@v.loewis.de>
parents:
72195
diff
changeset
|
490 fields = _PyObject_GetAttrId((PyObject*)Py_TYPE(self), &PyId__fields); |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
491 if (!fields) |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
492 PyErr_Clear(); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
493 if (fields) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
494 numfields = PySequence_Size(fields); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
495 if (numfields == -1) |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
496 goto cleanup; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
497 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
498 res = 0; /* if no error occurs, this stays 0 to the end */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
499 if (PyTuple_GET_SIZE(args) > 0) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
500 if (numfields != PyTuple_GET_SIZE(args)) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
501 PyErr_Format(PyExc_TypeError, "%.400s constructor takes %s" |
|
49139
6ae2d4b507a2
Merged revisions 66377 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
502 "%zd positional argument%s", |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
503 Py_TYPE(self)->tp_name, |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
504 numfields == 0 ? "" : "either 0 or ", |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
505 numfields, numfields == 1 ? "" : "s"); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
506 res = -1; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
507 goto cleanup; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
508 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
509 for (i = 0; i < PyTuple_GET_SIZE(args); i++) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
510 /* cannot be reached when fields is NULL */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
511 PyObject *name = PySequence_GetItem(fields, i); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
512 if (!name) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
513 res = -1; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
514 goto cleanup; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
515 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
516 res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i)); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
517 Py_DECREF(name); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
518 if (res < 0) |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
519 goto cleanup; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
520 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
521 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
522 if (kw) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
523 i = 0; /* needed by PyDict_Next */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
524 while (PyDict_Next(kw, &i, &key, &value)) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
525 res = PyObject_SetAttr(self, key, value); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
526 if (res < 0) |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
527 goto cleanup; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
528 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
529 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
530 cleanup: |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
531 Py_XDECREF(fields); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
532 return res; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
533 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
534 |
|
46233
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
535 /* Pickling support */ |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
536 static PyObject * |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
537 ast_type_reduce(PyObject *self, PyObject *unused) |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
538 { |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
539 PyObject *res; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
540 _Py_IDENTIFIER(__dict__); |
|
72848
81380082d216
Use identifier API for PyObject_GetAttrString.
Martin v. Löwis <martin@v.loewis.de>
parents:
72195
diff
changeset
|
541 PyObject *dict = _PyObject_GetAttrId(self, &PyId___dict__); |
|
46233
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
542 if (dict == NULL) { |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
543 if (PyErr_ExceptionMatches(PyExc_AttributeError)) |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
544 PyErr_Clear(); |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
545 else |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
546 return NULL; |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
547 } |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
548 if (dict) { |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
549 res = Py_BuildValue("O()O", Py_TYPE(self), dict); |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
550 Py_DECREF(dict); |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
551 return res; |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
552 } |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
553 return Py_BuildValue("O()", Py_TYPE(self)); |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
554 } |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
555 |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
556 static PyMethodDef ast_type_methods[] = { |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
557 {"__reduce__", ast_type_reduce, METH_NOARGS, NULL}, |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
558 {NULL} |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
559 }; |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
560 |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
561 static PyGetSetDef ast_type_getsets[] = { |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
562 {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict}, |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
563 {NULL} |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
564 }; |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
565 |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
566 static PyTypeObject AST_type = { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
567 PyVarObject_HEAD_INIT(&PyType_Type, 0) |
|
46233
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
568 "_ast.AST", |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
569 sizeof(AST_object), |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
570 0, |
| 75686 | 571 (destructor)ast_dealloc, /* tp_dealloc */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
572 0, /* tp_print */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
573 0, /* tp_getattr */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
574 0, /* tp_setattr */ |
|
51270
debd14c489b9
Issue #1717: rename tp_compare to tp_reserved. I'll change the
Mark Dickinson <dickinsm@gmail.com>
parents:
50076
diff
changeset
|
575 0, /* tp_reserved */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
576 0, /* tp_repr */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
577 0, /* tp_as_number */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
578 0, /* tp_as_sequence */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
579 0, /* tp_as_mapping */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
580 0, /* tp_hash */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
581 0, /* tp_call */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
582 0, /* tp_str */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
583 PyObject_GenericGetAttr, /* tp_getattro */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
584 PyObject_GenericSetAttr, /* tp_setattro */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
585 0, /* tp_as_buffer */ |
|
78006
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
586 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
587 0, /* tp_doc */ |
|
78006
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
588 (traverseproc)ast_traverse, /* tp_traverse */ |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
589 (inquiry)ast_clear, /* tp_clear */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
590 0, /* tp_richcompare */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
591 0, /* tp_weaklistoffset */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
592 0, /* tp_iter */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
593 0, /* tp_iternext */ |
|
46233
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
594 ast_type_methods, /* tp_methods */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
595 0, /* tp_members */ |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
596 ast_type_getsets, /* tp_getset */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
597 0, /* tp_base */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
598 0, /* tp_dict */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
599 0, /* tp_descr_get */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
600 0, /* tp_descr_set */ |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
601 offsetof(AST_object, dict),/* tp_dictoffset */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
602 (initproc)ast_type_init, /* tp_init */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
603 PyType_GenericAlloc, /* tp_alloc */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
604 PyType_GenericNew, /* tp_new */ |
|
78006
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
605 PyObject_GC_Del, /* tp_free */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
606 }; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
607 |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
608 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
609 static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int num_fields) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
610 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
611 PyObject *fnames, *result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
612 int i; |
|
46233
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
613 fnames = PyTuple_New(num_fields); |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
614 if (!fnames) return NULL; |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
615 for (i = 0; i < num_fields; i++) { |
|
42816
872c7c3f0af3
Use unicode for AST attributes
Neal Norwitz <nnorwitz@gmail.com>
parents:
42206
diff
changeset
|
616 PyObject *field = PyUnicode_FromString(fields[i]); |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
617 if (!field) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
618 Py_DECREF(fnames); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
619 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
620 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
621 PyTuple_SET_ITEM(fnames, i, field); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
622 } |
|
62155
600c23127207
Issue #8848: U / U# formats of Py_BuildValue() are just alias to s / s#
Victor Stinner <victor.stinner@haypocalc.com>
parents:
57676
diff
changeset
|
623 result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}", |
| 36669 | 624 type, base, "_fields", fnames, "__module__", "_ast"); |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
625 Py_DECREF(fnames); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
626 return (PyTypeObject*)result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
627 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
628 |
| 36669 | 629 static int add_attributes(PyTypeObject* type, char**attrs, int num_fields) |
| 630 { | |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36794
diff
changeset
|
631 int i, result; |
|
72926
db4aa878cea2
Port SetAttrString/HasAttrString to SetAttrId/GetAttrId.
Martin v. Löwis <martin@v.loewis.de>
parents:
72925
diff
changeset
|
632 _Py_IDENTIFIER(_attributes); |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
633 PyObject *s, *l = PyTuple_New(num_fields); |
|
62566
504c499e8c95
Merged revisions 81465-81466,81468,81679,81735,81760,81868,82183 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
62464
diff
changeset
|
634 if (!l) |
|
504c499e8c95
Merged revisions 81465-81466,81468,81679,81735,81760,81868,82183 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
62464
diff
changeset
|
635 return 0; |
|
504c499e8c95
Merged revisions 81465-81466,81468,81679,81735,81760,81868,82183 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
62464
diff
changeset
|
636 for (i = 0; i < num_fields; i++) { |
|
42816
872c7c3f0af3
Use unicode for AST attributes
Neal Norwitz <nnorwitz@gmail.com>
parents:
42206
diff
changeset
|
637 s = PyUnicode_FromString(attrs[i]); |
| 36669 | 638 if (!s) { |
| 639 Py_DECREF(l); | |
| 640 return 0; | |
| 641 } | |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
642 PyTuple_SET_ITEM(l, i, s); |
| 36669 | 643 } |
|
72926
db4aa878cea2
Port SetAttrString/HasAttrString to SetAttrId/GetAttrId.
Martin v. Löwis <martin@v.loewis.de>
parents:
72925
diff
changeset
|
644 result = _PyObject_SetAttrId((PyObject*)type, &PyId__attributes, l) >= 0; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36794
diff
changeset
|
645 Py_DECREF(l); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36794
diff
changeset
|
646 return result; |
| 36669 | 647 } |
| 648 | |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
649 /* Conversion AST -> Python */ |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
650 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
651 static PyObject* ast2obj_list(asdl_seq *seq, PyObject* (*func)(void*)) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
652 { |
|
76964
c18a1a82bb07
use Py_ssize_t for ast sequence lengths
Benjamin Peterson <benjamin@python.org>
parents:
76948
diff
changeset
|
653 Py_ssize_t i, n = asdl_seq_LEN(seq); |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
654 PyObject *result = PyList_New(n); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
655 PyObject *value; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
656 if (!result) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
657 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
658 for (i = 0; i < n; i++) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
659 value = func(asdl_seq_GET(seq, i)); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
660 if (!value) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
661 Py_DECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
662 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
663 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
664 PyList_SET_ITEM(result, i, value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
665 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
666 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
667 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
668 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
669 static PyObject* ast2obj_object(void *o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
670 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
671 if (!o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
672 o = Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
673 Py_INCREF((PyObject*)o); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
674 return (PyObject*)o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
675 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
676 #define ast2obj_identifier ast2obj_object |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
677 #define ast2obj_string ast2obj_object |
|
71792
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
678 #define ast2obj_bytes ast2obj_object |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
679 |
|
40937
6aa1be5dd009
Merged revisions 53912-53951 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40896
diff
changeset
|
680 static PyObject* ast2obj_int(long b) |
| 36669 | 681 { |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43755
diff
changeset
|
682 return PyLong_FromLong(b); |
| 36669 | 683 } |
| 684 | |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
685 /* Conversion Python -> AST */ |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
686 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
687 static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
688 { |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
689 if (obj == Py_None) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
690 obj = NULL; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
691 if (obj) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
692 PyArena_AddPyObject(arena, obj); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
693 Py_XINCREF(obj); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
694 *out = obj; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
695 return 0; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
696 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
697 |
|
71458
c9ebae3285e3
None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents:
71455
diff
changeset
|
698 static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena) |
|
71454
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
699 { |
|
71458
c9ebae3285e3
None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents:
71455
diff
changeset
|
700 if (!PyUnicode_CheckExact(obj) && obj != Py_None) { |
|
c9ebae3285e3
None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents:
71455
diff
changeset
|
701 PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str"); |
|
71454
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
702 return 1; |
|
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
703 } |
|
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
704 return obj2ast_object(obj, out, arena); |
|
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
705 } |
|
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
706 |
|
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
707 static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena) |
|
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
708 { |
|
72154
c8b6d4417274
accept bytes for the AST 'string' type
Benjamin Peterson <benjamin@python.org>
parents:
71458
diff
changeset
|
709 if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) { |
|
71458
c9ebae3285e3
None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents:
71455
diff
changeset
|
710 PyErr_SetString(PyExc_TypeError, "AST string must be of type str"); |
|
c9ebae3285e3
None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents:
71455
diff
changeset
|
711 return 1; |
|
c9ebae3285e3
None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents:
71455
diff
changeset
|
712 } |
|
c9ebae3285e3
None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents:
71455
diff
changeset
|
713 return obj2ast_object(obj, out, arena); |
|
71454
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
714 } |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
715 |
|
71792
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
716 static int obj2ast_bytes(PyObject* obj, PyObject** out, PyArena* arena) |
|
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
717 { |
|
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
718 if (!PyBytes_CheckExact(obj)) { |
|
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
719 PyErr_SetString(PyExc_TypeError, "AST bytes must be of type bytes"); |
|
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
720 return 1; |
|
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
721 } |
|
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
722 return obj2ast_object(obj, out, arena); |
|
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
723 } |
|
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
724 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
725 static int obj2ast_int(PyObject* obj, int* out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
726 { |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
727 int i; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
728 if (!PyLong_Check(obj)) { |
|
73700
470f7d7c57ce
Issue #13436: commit regenerated Python-ast.c
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
72154
diff
changeset
|
729 PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
730 return 1; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
731 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
732 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
733 i = (int)PyLong_AsLong(obj); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
734 if (i == -1 && PyErr_Occurred()) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
735 return 1; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
736 *out = i; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
737 return 0; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
738 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
739 |
|
49587
f66688e69f66
Merged revisions 66974,66977,66984,66989,66992,66994-66996,66998-67000,67007,67015 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
49583
diff
changeset
|
740 static int add_ast_fields(void) |
|
49583
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
741 { |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
742 PyObject *empty_tuple, *d; |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
743 if (PyType_Ready(&AST_type) < 0) |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
744 return -1; |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
745 d = AST_type.tp_dict; |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
746 empty_tuple = PyTuple_New(0); |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
747 if (!empty_tuple || |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
748 PyDict_SetItemString(d, "_fields", empty_tuple) < 0 || |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
749 PyDict_SetItemString(d, "_attributes", empty_tuple) < 0) { |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
750 Py_XDECREF(empty_tuple); |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
751 return -1; |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
752 } |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
753 Py_DECREF(empty_tuple); |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
754 return 0; |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
755 } |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
756 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
757 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
758 static int init_types(void) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
759 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
760 static int initialized; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
761 if (initialized) return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
762 if (add_ast_fields() < 0) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
763 mod_type = make_type("mod", &AST_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
764 if (!mod_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
765 if (!add_attributes(mod_type, NULL, 0)) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
766 Module_type = make_type("Module", mod_type, Module_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
767 if (!Module_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
768 Interactive_type = make_type("Interactive", mod_type, Interactive_fields, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
769 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
770 if (!Interactive_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
771 Expression_type = make_type("Expression", mod_type, Expression_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
772 if (!Expression_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
773 Suite_type = make_type("Suite", mod_type, Suite_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
774 if (!Suite_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
775 stmt_type = make_type("stmt", &AST_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
776 if (!stmt_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
777 if (!add_attributes(stmt_type, stmt_attributes, 2)) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
778 FunctionDef_type = make_type("FunctionDef", stmt_type, FunctionDef_fields, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
779 5); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
780 if (!FunctionDef_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
781 ClassDef_type = make_type("ClassDef", stmt_type, ClassDef_fields, 7); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
782 if (!ClassDef_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
783 Return_type = make_type("Return", stmt_type, Return_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
784 if (!Return_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
785 Delete_type = make_type("Delete", stmt_type, Delete_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
786 if (!Delete_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
787 Assign_type = make_type("Assign", stmt_type, Assign_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
788 if (!Assign_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
789 AugAssign_type = make_type("AugAssign", stmt_type, AugAssign_fields, 3); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
790 if (!AugAssign_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
791 For_type = make_type("For", stmt_type, For_fields, 4); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
792 if (!For_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
793 While_type = make_type("While", stmt_type, While_fields, 3); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
794 if (!While_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
795 If_type = make_type("If", stmt_type, If_fields, 3); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
796 if (!If_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
797 With_type = make_type("With", stmt_type, With_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
798 if (!With_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
799 Raise_type = make_type("Raise", stmt_type, Raise_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
800 if (!Raise_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
801 Try_type = make_type("Try", stmt_type, Try_fields, 4); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
802 if (!Try_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
803 Assert_type = make_type("Assert", stmt_type, Assert_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
804 if (!Assert_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
805 Import_type = make_type("Import", stmt_type, Import_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
806 if (!Import_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
807 ImportFrom_type = make_type("ImportFrom", stmt_type, ImportFrom_fields, 3); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
808 if (!ImportFrom_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
809 Global_type = make_type("Global", stmt_type, Global_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
810 if (!Global_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
811 Nonlocal_type = make_type("Nonlocal", stmt_type, Nonlocal_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
812 if (!Nonlocal_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
813 Expr_type = make_type("Expr", stmt_type, Expr_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
814 if (!Expr_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
815 Pass_type = make_type("Pass", stmt_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
816 if (!Pass_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
817 Break_type = make_type("Break", stmt_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
818 if (!Break_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
819 Continue_type = make_type("Continue", stmt_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
820 if (!Continue_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
821 expr_type = make_type("expr", &AST_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
822 if (!expr_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
823 if (!add_attributes(expr_type, expr_attributes, 2)) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
824 BoolOp_type = make_type("BoolOp", expr_type, BoolOp_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
825 if (!BoolOp_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
826 BinOp_type = make_type("BinOp", expr_type, BinOp_fields, 3); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
827 if (!BinOp_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
828 UnaryOp_type = make_type("UnaryOp", expr_type, UnaryOp_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
829 if (!UnaryOp_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
830 Lambda_type = make_type("Lambda", expr_type, Lambda_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
831 if (!Lambda_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
832 IfExp_type = make_type("IfExp", expr_type, IfExp_fields, 3); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
833 if (!IfExp_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
834 Dict_type = make_type("Dict", expr_type, Dict_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
835 if (!Dict_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
836 Set_type = make_type("Set", expr_type, Set_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
837 if (!Set_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
838 ListComp_type = make_type("ListComp", expr_type, ListComp_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
839 if (!ListComp_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
840 SetComp_type = make_type("SetComp", expr_type, SetComp_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
841 if (!SetComp_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
842 DictComp_type = make_type("DictComp", expr_type, DictComp_fields, 3); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
843 if (!DictComp_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
844 GeneratorExp_type = make_type("GeneratorExp", expr_type, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
845 GeneratorExp_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
846 if (!GeneratorExp_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
847 Yield_type = make_type("Yield", expr_type, Yield_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
848 if (!Yield_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
849 YieldFrom_type = make_type("YieldFrom", expr_type, YieldFrom_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
850 if (!YieldFrom_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
851 Compare_type = make_type("Compare", expr_type, Compare_fields, 3); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
852 if (!Compare_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
853 Call_type = make_type("Call", expr_type, Call_fields, 5); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
854 if (!Call_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
855 Num_type = make_type("Num", expr_type, Num_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
856 if (!Num_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
857 Str_type = make_type("Str", expr_type, Str_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
858 if (!Str_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
859 Bytes_type = make_type("Bytes", expr_type, Bytes_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
860 if (!Bytes_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
861 Ellipsis_type = make_type("Ellipsis", expr_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
862 if (!Ellipsis_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
863 Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
864 if (!Attribute_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
865 Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
866 if (!Subscript_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
867 Starred_type = make_type("Starred", expr_type, Starred_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
868 if (!Starred_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
869 Name_type = make_type("Name", expr_type, Name_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
870 if (!Name_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
871 List_type = make_type("List", expr_type, List_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
872 if (!List_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
873 Tuple_type = make_type("Tuple", expr_type, Tuple_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
874 if (!Tuple_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
875 expr_context_type = make_type("expr_context", &AST_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
876 if (!expr_context_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
877 if (!add_attributes(expr_context_type, NULL, 0)) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
878 Load_type = make_type("Load", expr_context_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
879 if (!Load_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
880 Load_singleton = PyType_GenericNew(Load_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
881 if (!Load_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
882 Store_type = make_type("Store", expr_context_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
883 if (!Store_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
884 Store_singleton = PyType_GenericNew(Store_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
885 if (!Store_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
886 Del_type = make_type("Del", expr_context_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
887 if (!Del_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
888 Del_singleton = PyType_GenericNew(Del_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
889 if (!Del_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
890 AugLoad_type = make_type("AugLoad", expr_context_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
891 if (!AugLoad_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
892 AugLoad_singleton = PyType_GenericNew(AugLoad_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
893 if (!AugLoad_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
894 AugStore_type = make_type("AugStore", expr_context_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
895 if (!AugStore_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
896 AugStore_singleton = PyType_GenericNew(AugStore_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
897 if (!AugStore_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
898 Param_type = make_type("Param", expr_context_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
899 if (!Param_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
900 Param_singleton = PyType_GenericNew(Param_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
901 if (!Param_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
902 slice_type = make_type("slice", &AST_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
903 if (!slice_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
904 if (!add_attributes(slice_type, NULL, 0)) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
905 Slice_type = make_type("Slice", slice_type, Slice_fields, 3); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
906 if (!Slice_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
907 ExtSlice_type = make_type("ExtSlice", slice_type, ExtSlice_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
908 if (!ExtSlice_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
909 Index_type = make_type("Index", slice_type, Index_fields, 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
910 if (!Index_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
911 boolop_type = make_type("boolop", &AST_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
912 if (!boolop_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
913 if (!add_attributes(boolop_type, NULL, 0)) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
914 And_type = make_type("And", boolop_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
915 if (!And_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
916 And_singleton = PyType_GenericNew(And_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
917 if (!And_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
918 Or_type = make_type("Or", boolop_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
919 if (!Or_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
920 Or_singleton = PyType_GenericNew(Or_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
921 if (!Or_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
922 operator_type = make_type("operator", &AST_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
923 if (!operator_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
924 if (!add_attributes(operator_type, NULL, 0)) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
925 Add_type = make_type("Add", operator_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
926 if (!Add_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
927 Add_singleton = PyType_GenericNew(Add_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
928 if (!Add_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
929 Sub_type = make_type("Sub", operator_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
930 if (!Sub_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
931 Sub_singleton = PyType_GenericNew(Sub_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
932 if (!Sub_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
933 Mult_type = make_type("Mult", operator_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
934 if (!Mult_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
935 Mult_singleton = PyType_GenericNew(Mult_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
936 if (!Mult_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
937 Div_type = make_type("Div", operator_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
938 if (!Div_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
939 Div_singleton = PyType_GenericNew(Div_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
940 if (!Div_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
941 Mod_type = make_type("Mod", operator_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
942 if (!Mod_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
943 Mod_singleton = PyType_GenericNew(Mod_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
944 if (!Mod_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
945 Pow_type = make_type("Pow", operator_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
946 if (!Pow_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
947 Pow_singleton = PyType_GenericNew(Pow_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
948 if (!Pow_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
949 LShift_type = make_type("LShift", operator_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
950 if (!LShift_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
951 LShift_singleton = PyType_GenericNew(LShift_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
952 if (!LShift_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
953 RShift_type = make_type("RShift", operator_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
954 if (!RShift_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
955 RShift_singleton = PyType_GenericNew(RShift_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
956 if (!RShift_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
957 BitOr_type = make_type("BitOr", operator_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
958 if (!BitOr_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
959 BitOr_singleton = PyType_GenericNew(BitOr_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
960 if (!BitOr_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
961 BitXor_type = make_type("BitXor", operator_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
962 if (!BitXor_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
963 BitXor_singleton = PyType_GenericNew(BitXor_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
964 if (!BitXor_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
965 BitAnd_type = make_type("BitAnd", operator_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
966 if (!BitAnd_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
967 BitAnd_singleton = PyType_GenericNew(BitAnd_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
968 if (!BitAnd_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
969 FloorDiv_type = make_type("FloorDiv", operator_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
970 if (!FloorDiv_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
971 FloorDiv_singleton = PyType_GenericNew(FloorDiv_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
972 if (!FloorDiv_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
973 unaryop_type = make_type("unaryop", &AST_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
974 if (!unaryop_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
975 if (!add_attributes(unaryop_type, NULL, 0)) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
976 Invert_type = make_type("Invert", unaryop_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
977 if (!Invert_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
978 Invert_singleton = PyType_GenericNew(Invert_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
979 if (!Invert_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
980 Not_type = make_type("Not", unaryop_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
981 if (!Not_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
982 Not_singleton = PyType_GenericNew(Not_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
983 if (!Not_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
984 UAdd_type = make_type("UAdd", unaryop_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
985 if (!UAdd_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
986 UAdd_singleton = PyType_GenericNew(UAdd_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
987 if (!UAdd_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
988 USub_type = make_type("USub", unaryop_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
989 if (!USub_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
990 USub_singleton = PyType_GenericNew(USub_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
991 if (!USub_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
992 cmpop_type = make_type("cmpop", &AST_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
993 if (!cmpop_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
994 if (!add_attributes(cmpop_type, NULL, 0)) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
995 Eq_type = make_type("Eq", cmpop_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
996 if (!Eq_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
997 Eq_singleton = PyType_GenericNew(Eq_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
998 if (!Eq_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
999 NotEq_type = make_type("NotEq", cmpop_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1000 if (!NotEq_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1001 NotEq_singleton = PyType_GenericNew(NotEq_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1002 if (!NotEq_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1003 Lt_type = make_type("Lt", cmpop_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1004 if (!Lt_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1005 Lt_singleton = PyType_GenericNew(Lt_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1006 if (!Lt_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1007 LtE_type = make_type("LtE", cmpop_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1008 if (!LtE_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1009 LtE_singleton = PyType_GenericNew(LtE_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1010 if (!LtE_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1011 Gt_type = make_type("Gt", cmpop_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1012 if (!Gt_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1013 Gt_singleton = PyType_GenericNew(Gt_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1014 if (!Gt_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1015 GtE_type = make_type("GtE", cmpop_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1016 if (!GtE_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1017 GtE_singleton = PyType_GenericNew(GtE_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1018 if (!GtE_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1019 Is_type = make_type("Is", cmpop_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1020 if (!Is_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1021 Is_singleton = PyType_GenericNew(Is_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1022 if (!Is_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1023 IsNot_type = make_type("IsNot", cmpop_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1024 if (!IsNot_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1025 IsNot_singleton = PyType_GenericNew(IsNot_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1026 if (!IsNot_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1027 In_type = make_type("In", cmpop_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1028 if (!In_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1029 In_singleton = PyType_GenericNew(In_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1030 if (!In_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1031 NotIn_type = make_type("NotIn", cmpop_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1032 if (!NotIn_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1033 NotIn_singleton = PyType_GenericNew(NotIn_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1034 if (!NotIn_singleton) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1035 comprehension_type = make_type("comprehension", &AST_type, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1036 comprehension_fields, 3); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1037 if (!comprehension_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1038 excepthandler_type = make_type("excepthandler", &AST_type, NULL, 0); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1039 if (!excepthandler_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1040 if (!add_attributes(excepthandler_type, excepthandler_attributes, 2)) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1041 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1042 ExceptHandler_type = make_type("ExceptHandler", excepthandler_type, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1043 ExceptHandler_fields, 3); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1044 if (!ExceptHandler_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1045 arguments_type = make_type("arguments", &AST_type, arguments_fields, 8); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1046 if (!arguments_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1047 arg_type = make_type("arg", &AST_type, arg_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1048 if (!arg_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1049 keyword_type = make_type("keyword", &AST_type, keyword_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1050 if (!keyword_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1051 alias_type = make_type("alias", &AST_type, alias_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1052 if (!alias_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1053 withitem_type = make_type("withitem", &AST_type, withitem_fields, 2); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1054 if (!withitem_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1055 initialized = 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1056 return 1; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1057 } |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1058 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1059 static int obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1060 static int obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1061 static int obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1062 static int obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1063 arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1064 static int obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1065 static int obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1066 static int obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1067 static int obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1068 static int obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1069 static int obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena* |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1070 arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1071 static int obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1072 arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1073 static int obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1074 static int obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1075 static int obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1076 static int obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena); |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
1077 static int obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1078 |
| 35742 | 1079 mod_ty |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
1080 Module(asdl_seq * body, PyArena *arena) |
| 35742 | 1081 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1082 mod_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1083 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1084 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1085 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1086 p->kind = Module_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1087 p->v.Module.body = body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1088 return p; |
| 35742 | 1089 } |
| 1090 | |
| 1091 mod_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
1092 Interactive(asdl_seq * body, PyArena *arena) |
| 35742 | 1093 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1094 mod_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1095 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1096 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1097 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1098 p->kind = Interactive_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1099 p->v.Interactive.body = body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1100 return p; |
| 35742 | 1101 } |
| 1102 | |
| 1103 mod_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
1104 Expression(expr_ty body, PyArena *arena) |
| 35742 | 1105 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1106 mod_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1107 if (!body) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1108 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1109 "field body is required for Expression"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1110 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1111 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1112 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1113 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1114 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1115 p->kind = Expression_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1116 p->v.Expression.body = body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1117 return p; |
| 35742 | 1118 } |
| 1119 | |
| 1120 mod_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
1121 Suite(asdl_seq * body, PyArena *arena) |
| 35742 | 1122 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1123 mod_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1124 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1125 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1126 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1127 p->kind = Suite_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1128 p->v.Suite.body = body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1129 return p; |
| 35742 | 1130 } |
| 1131 | |
| 1132 stmt_ty | |
| 1133 FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq * | |
|
41824
24b60622b944
Merged revisions 55407-55513 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41722
diff
changeset
|
1134 decorator_list, expr_ty returns, int lineno, int col_offset, |
|
24b60622b944
Merged revisions 55407-55513 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41722
diff
changeset
|
1135 PyArena *arena) |
| 35742 | 1136 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1137 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1138 if (!name) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1139 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1140 "field name is required for FunctionDef"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1141 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1142 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1143 if (!args) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1144 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1145 "field args is required for FunctionDef"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1146 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1147 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1148 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1149 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1150 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1151 p->kind = FunctionDef_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1152 p->v.FunctionDef.name = name; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1153 p->v.FunctionDef.args = args; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1154 p->v.FunctionDef.body = body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1155 p->v.FunctionDef.decorator_list = decorator_list; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1156 p->v.FunctionDef.returns = returns; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1157 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1158 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1159 return p; |
| 35742 | 1160 } |
| 1161 | |
| 1162 stmt_ty | |
|
41226
19f7ff443718
Implement PEP 3115 -- new metaclass syntax and semantics.
Guido van Rossum <guido@python.org>
parents:
40980
diff
changeset
|
1163 ClassDef(identifier name, asdl_seq * bases, asdl_seq * keywords, expr_ty |
|
41824
24b60622b944
Merged revisions 55407-55513 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41722
diff
changeset
|
1164 starargs, expr_ty kwargs, asdl_seq * body, asdl_seq * decorator_list, |
|
24b60622b944
Merged revisions 55407-55513 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41722
diff
changeset
|
1165 int lineno, int col_offset, PyArena *arena) |
| 35742 | 1166 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1167 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1168 if (!name) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1169 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1170 "field name is required for ClassDef"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1171 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1172 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1173 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1174 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1175 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1176 p->kind = ClassDef_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1177 p->v.ClassDef.name = name; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1178 p->v.ClassDef.bases = bases; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1179 p->v.ClassDef.keywords = keywords; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1180 p->v.ClassDef.starargs = starargs; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1181 p->v.ClassDef.kwargs = kwargs; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1182 p->v.ClassDef.body = body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1183 p->v.ClassDef.decorator_list = decorator_list; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1184 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1185 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1186 return p; |
| 35742 | 1187 } |
| 1188 | |
| 1189 stmt_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1190 Return(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1191 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1192 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1193 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1194 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1195 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1196 p->kind = Return_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1197 p->v.Return.value = value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1198 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1199 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1200 return p; |
| 35742 | 1201 } |
| 1202 | |
| 1203 stmt_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1204 Delete(asdl_seq * targets, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1205 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1206 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1207 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1208 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1209 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1210 p->kind = Delete_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1211 p->v.Delete.targets = targets; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1212 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1213 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1214 return p; |
| 35742 | 1215 } |
| 1216 | |
| 1217 stmt_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1218 Assign(asdl_seq * targets, expr_ty value, int lineno, int col_offset, PyArena |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1219 *arena) |
| 35742 | 1220 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1221 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1222 if (!value) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1223 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1224 "field value is required for Assign"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1225 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1226 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1227 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1228 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1229 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1230 p->kind = Assign_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1231 p->v.Assign.targets = targets; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1232 p->v.Assign.value = value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1233 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1234 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1235 return p; |
| 35742 | 1236 } |
| 1237 | |
| 1238 stmt_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1239 AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1240 col_offset, PyArena *arena) |
| 35742 | 1241 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1242 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1243 if (!target) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1244 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1245 "field target is required for AugAssign"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1246 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1247 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1248 if (!op) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1249 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1250 "field op is required for AugAssign"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1251 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1252 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1253 if (!value) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1254 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1255 "field value is required for AugAssign"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1256 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1257 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1258 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1259 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1260 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1261 p->kind = AugAssign_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1262 p->v.AugAssign.target = target; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1263 p->v.AugAssign.op = op; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1264 p->v.AugAssign.value = value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1265 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1266 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1267 return p; |
| 35742 | 1268 } |
| 1269 | |
| 1270 stmt_ty | |
| 1271 For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, int | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1272 lineno, int col_offset, PyArena *arena) |
| 35742 | 1273 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1274 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1275 if (!target) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1276 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1277 "field target is required for For"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1278 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1279 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1280 if (!iter) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1281 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1282 "field iter is required for For"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1283 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1284 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1285 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1286 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1287 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1288 p->kind = For_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1289 p->v.For.target = target; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1290 p->v.For.iter = iter; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1291 p->v.For.body = body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1292 p->v.For.orelse = orelse; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1293 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1294 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1295 return p; |
| 35742 | 1296 } |
| 1297 | |
| 1298 stmt_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1299 While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1300 col_offset, PyArena *arena) |
| 35742 | 1301 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1302 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1303 if (!test) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1304 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1305 "field test is required for While"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1306 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1307 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1308 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1309 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1310 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1311 p->kind = While_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1312 p->v.While.test = test; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1313 p->v.While.body = body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1314 p->v.While.orelse = orelse; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1315 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1316 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1317 return p; |
| 35742 | 1318 } |
| 1319 | |
| 1320 stmt_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1321 If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1322 col_offset, PyArena *arena) |
| 35742 | 1323 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1324 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1325 if (!test) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1326 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1327 "field test is required for If"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1328 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1329 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1330 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1331 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1332 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1333 p->kind = If_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1334 p->v.If.test = test; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1335 p->v.If.body = body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1336 p->v.If.orelse = orelse; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1337 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1338 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1339 return p; |
| 35742 | 1340 } |
| 1341 | |
| 1342 stmt_ty | |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
1343 With(asdl_seq * items, asdl_seq * body, int lineno, int col_offset, PyArena |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
1344 *arena) |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1345 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1346 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1347 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1348 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1349 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1350 p->kind = With_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1351 p->v.With.items = items; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1352 p->v.With.body = body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1353 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1354 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1355 return p; |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1356 } |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1357 |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1358 stmt_ty |
|
43102
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42844
diff
changeset
|
1359 Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1360 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1361 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1362 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1363 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1364 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1365 p->kind = Raise_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1366 p->v.Raise.exc = exc; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1367 p->v.Raise.cause = cause; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1368 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1369 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1370 return p; |
| 35742 | 1371 } |
| 1372 | |
| 1373 stmt_ty | |
|
70499
e0e663132363
unify TryExcept and TryFinally (closes #12199)
Benjamin Peterson <benjamin@python.org>
parents:
70439
diff
changeset
|
1374 Try(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, asdl_seq * |
|
e0e663132363
unify TryExcept and TryFinally (closes #12199)
Benjamin Peterson <benjamin@python.org>
parents:
70439
diff
changeset
|
1375 finalbody, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1376 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1377 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1378 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1379 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1380 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1381 p->kind = Try_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1382 p->v.Try.body = body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1383 p->v.Try.handlers = handlers; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1384 p->v.Try.orelse = orelse; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1385 p->v.Try.finalbody = finalbody; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1386 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1387 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1388 return p; |
| 35742 | 1389 } |
| 1390 | |
| 1391 stmt_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1392 Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1393 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1394 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1395 if (!test) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1396 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1397 "field test is required for Assert"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1398 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1399 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1400 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1401 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1402 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1403 p->kind = Assert_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1404 p->v.Assert.test = test; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1405 p->v.Assert.msg = msg; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1406 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1407 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1408 return p; |
| 35742 | 1409 } |
| 1410 | |
| 1411 stmt_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1412 Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1413 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1414 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1415 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1416 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1417 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1418 p->kind = Import_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1419 p->v.Import.names = names; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1420 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1421 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1422 return p; |
| 35742 | 1423 } |
| 1424 | |
| 1425 stmt_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1426 ImportFrom(identifier module, asdl_seq * names, int level, int lineno, int |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1427 col_offset, PyArena *arena) |
| 35742 | 1428 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1429 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1430 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1431 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1432 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1433 p->kind = ImportFrom_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1434 p->v.ImportFrom.module = module; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1435 p->v.ImportFrom.names = names; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1436 p->v.ImportFrom.level = level; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1437 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1438 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1439 return p; |
| 35742 | 1440 } |
| 1441 | |
| 1442 stmt_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1443 Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1444 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1445 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1446 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1447 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1448 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1449 p->kind = Global_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1450 p->v.Global.names = names; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1451 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1452 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1453 return p; |
| 35742 | 1454 } |
| 1455 | |
| 1456 stmt_ty | |
|
40965
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
1457 Nonlocal(asdl_seq * names, int lineno, int col_offset, PyArena *arena) |
|
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
1458 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1459 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1460 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1461 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1462 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1463 p->kind = Nonlocal_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1464 p->v.Nonlocal.names = names; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1465 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1466 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1467 return p; |
|
40965
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
1468 } |
|
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
1469 |
|
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
1470 stmt_ty |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1471 Expr(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1472 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1473 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1474 if (!value) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1475 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1476 "field value is required for Expr"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1477 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1478 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1479 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1480 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1481 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1482 p->kind = Expr_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1483 p->v.Expr.value = value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1484 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1485 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1486 return p; |
| 35742 | 1487 } |
| 1488 | |
| 1489 stmt_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1490 Pass(int lineno, int col_offset, PyArena *arena) |
| 35742 | 1491 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1492 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1493 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1494 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1495 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1496 p->kind = Pass_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1497 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1498 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1499 return p; |
| 35742 | 1500 } |
| 1501 | |
| 1502 stmt_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1503 Break(int lineno, int col_offset, PyArena *arena) |
| 35742 | 1504 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1505 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1506 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1507 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1508 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1509 p->kind = Break_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1510 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1511 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1512 return p; |
| 35742 | 1513 } |
| 1514 | |
| 1515 stmt_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1516 Continue(int lineno, int col_offset, PyArena *arena) |
| 35742 | 1517 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1518 stmt_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1519 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1520 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1521 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1522 p->kind = Continue_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1523 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1524 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1525 return p; |
| 35742 | 1526 } |
| 1527 | |
| 1528 expr_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1529 BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, PyArena |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1530 *arena) |
| 35742 | 1531 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1532 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1533 if (!op) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1534 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1535 "field op is required for BoolOp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1536 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1537 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1538 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1539 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1540 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1541 p->kind = BoolOp_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1542 p->v.BoolOp.op = op; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1543 p->v.BoolOp.values = values; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1544 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1545 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1546 return p; |
| 35742 | 1547 } |
| 1548 | |
| 1549 expr_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1550 BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int col_offset, |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1551 PyArena *arena) |
| 35742 | 1552 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1553 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1554 if (!left) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1555 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1556 "field left is required for BinOp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1557 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1558 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1559 if (!op) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1560 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1561 "field op is required for BinOp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1562 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1563 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1564 if (!right) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1565 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1566 "field right is required for BinOp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1567 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1568 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1569 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1570 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1571 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1572 p->kind = BinOp_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1573 p->v.BinOp.left = left; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1574 p->v.BinOp.op = op; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1575 p->v.BinOp.right = right; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1576 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1577 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1578 return p; |
| 35742 | 1579 } |
| 1580 | |
| 1581 expr_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1582 UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, PyArena |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1583 *arena) |
| 35742 | 1584 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1585 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1586 if (!op) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1587 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1588 "field op is required for UnaryOp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1589 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1590 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1591 if (!operand) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1592 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1593 "field operand is required for UnaryOp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1594 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1595 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1596 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1597 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1598 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1599 p->kind = UnaryOp_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1600 p->v.UnaryOp.op = op; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1601 p->v.UnaryOp.operand = operand; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1602 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1603 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1604 return p; |
| 35742 | 1605 } |
| 1606 | |
| 1607 expr_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1608 Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, PyArena |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1609 *arena) |
| 35742 | 1610 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1611 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1612 if (!args) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1613 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1614 "field args is required for Lambda"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1615 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1616 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1617 if (!body) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1618 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1619 "field body is required for Lambda"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1620 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1621 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1622 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1623 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1624 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1625 p->kind = Lambda_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1626 p->v.Lambda.args = args; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1627 p->v.Lambda.body = body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1628 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1629 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1630 return p; |
| 35742 | 1631 } |
| 1632 | |
| 1633 expr_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1634 IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int col_offset, |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1635 PyArena *arena) |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1636 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1637 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1638 if (!test) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1639 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1640 "field test is required for IfExp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1641 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1642 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1643 if (!body) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1644 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1645 "field body is required for IfExp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1646 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1647 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1648 if (!orelse) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1649 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1650 "field orelse is required for IfExp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1651 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1652 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1653 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1654 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1655 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1656 p->kind = IfExp_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1657 p->v.IfExp.test = test; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1658 p->v.IfExp.body = body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1659 p->v.IfExp.orelse = orelse; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1660 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1661 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1662 return p; |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1663 } |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1664 |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1665 expr_ty |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1666 Dict(asdl_seq * keys, asdl_seq * values, int lineno, int col_offset, PyArena |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1667 *arena) |
| 35742 | 1668 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1669 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1670 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1671 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1672 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1673 p->kind = Dict_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1674 p->v.Dict.keys = keys; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1675 p->v.Dict.values = values; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1676 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1677 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1678 return p; |
| 35742 | 1679 } |
| 1680 | |
| 1681 expr_ty | |
|
39693
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
1682 Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena) |
|
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
1683 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1684 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1685 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1686 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1687 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1688 p->kind = Set_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1689 p->v.Set.elts = elts; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1690 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1691 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1692 return p; |
|
39693
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
1693 } |
|
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
1694 |
|
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
1695 expr_ty |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1696 ListComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1697 PyArena *arena) |
| 35742 | 1698 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1699 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1700 if (!elt) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1701 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1702 "field elt is required for ListComp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1703 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1704 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1705 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1706 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1707 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1708 p->kind = ListComp_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1709 p->v.ListComp.elt = elt; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1710 p->v.ListComp.generators = generators; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1711 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1712 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1713 return p; |
| 35742 | 1714 } |
| 1715 | |
| 1716 expr_ty | |
|
41464
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
1717 SetComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, PyArena |
|
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
1718 *arena) |
|
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
1719 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1720 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1721 if (!elt) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1722 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1723 "field elt is required for SetComp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1724 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1725 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1726 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1727 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1728 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1729 p->kind = SetComp_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1730 p->v.SetComp.elt = elt; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1731 p->v.SetComp.generators = generators; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1732 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1733 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1734 return p; |
|
41464
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
1735 } |
|
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
1736 |
|
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
1737 expr_ty |
|
42193
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
1738 DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int lineno, int |
|
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
1739 col_offset, PyArena *arena) |
|
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
1740 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1741 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1742 if (!key) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1743 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1744 "field key is required for DictComp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1745 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1746 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1747 if (!value) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1748 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1749 "field value is required for DictComp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1750 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1751 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1752 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1753 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1754 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1755 p->kind = DictComp_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1756 p->v.DictComp.key = key; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1757 p->v.DictComp.value = value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1758 p->v.DictComp.generators = generators; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1759 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1760 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1761 return p; |
|
42193
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
1762 } |
|
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
1763 |
|
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
1764 expr_ty |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1765 GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1766 PyArena *arena) |
| 35742 | 1767 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1768 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1769 if (!elt) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1770 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1771 "field elt is required for GeneratorExp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1772 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1773 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1774 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1775 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1776 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1777 p->kind = GeneratorExp_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1778 p->v.GeneratorExp.elt = elt; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1779 p->v.GeneratorExp.generators = generators; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1780 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1781 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1782 return p; |
| 35742 | 1783 } |
| 1784 | |
| 1785 expr_ty | |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
1786 Yield(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1787 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1788 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1789 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1790 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1791 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1792 p->kind = Yield_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1793 p->v.Yield.value = value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1794 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1795 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1796 return p; |
| 35742 | 1797 } |
| 1798 | |
| 1799 expr_ty | |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
1800 YieldFrom(expr_ty value, int lineno, int col_offset, PyArena *arena) |
|
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
1801 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1802 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1803 if (!value) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1804 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1805 "field value is required for YieldFrom"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1806 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1807 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1808 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1809 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1810 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1811 p->kind = YieldFrom_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1812 p->v.YieldFrom.value = value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1813 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1814 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1815 return p; |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
1816 } |
|
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
1817 |
|
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
1818 expr_ty |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36794
diff
changeset
|
1819 Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int lineno, |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36794
diff
changeset
|
1820 int col_offset, PyArena *arena) |
| 35742 | 1821 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1822 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1823 if (!left) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1824 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1825 "field left is required for Compare"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1826 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1827 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1828 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1829 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1830 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1831 p->kind = Compare_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1832 p->v.Compare.left = left; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1833 p->v.Compare.ops = ops; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1834 p->v.Compare.comparators = comparators; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1835 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1836 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1837 return p; |
| 35742 | 1838 } |
| 1839 | |
| 1840 expr_ty | |
| 1841 Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs, | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1842 expr_ty kwargs, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1843 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1844 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1845 if (!func) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1846 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1847 "field func is required for Call"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1848 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1849 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1850 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1851 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1852 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1853 p->kind = Call_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1854 p->v.Call.func = func; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1855 p->v.Call.args = args; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1856 p->v.Call.keywords = keywords; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1857 p->v.Call.starargs = starargs; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1858 p->v.Call.kwargs = kwargs; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1859 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1860 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1861 return p; |
| 35742 | 1862 } |
| 1863 | |
| 1864 expr_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1865 Num(object n, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1866 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1867 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1868 if (!n) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1869 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1870 "field n is required for Num"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1871 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1872 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1873 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1874 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1875 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1876 p->kind = Num_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1877 p->v.Num.n = n; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1878 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1879 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1880 return p; |
| 35742 | 1881 } |
| 1882 | |
| 1883 expr_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1884 Str(string s, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1885 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1886 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1887 if (!s) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1888 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1889 "field s is required for Str"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1890 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1891 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1892 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1893 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1894 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1895 p->kind = Str_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1896 p->v.Str.s = s; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1897 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1898 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1899 return p; |
| 35742 | 1900 } |
| 1901 | |
| 1902 expr_ty | |
|
71792
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
1903 Bytes(bytes s, int lineno, int col_offset, PyArena *arena) |
| 40894 | 1904 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1905 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1906 if (!s) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1907 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1908 "field s is required for Bytes"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1909 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1910 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1911 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1912 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1913 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1914 p->kind = Bytes_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1915 p->v.Bytes.s = s; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1916 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1917 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1918 return p; |
| 40894 | 1919 } |
| 1920 | |
| 1921 expr_ty | |
|
39783
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
1922 Ellipsis(int lineno, int col_offset, PyArena *arena) |
|
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
1923 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1924 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1925 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1926 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1927 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1928 p->kind = Ellipsis_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1929 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1930 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1931 return p; |
|
39783
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
1932 } |
|
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
1933 |
|
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
1934 expr_ty |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1935 Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, int |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1936 col_offset, PyArena *arena) |
| 35742 | 1937 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1938 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1939 if (!value) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1940 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1941 "field value is required for Attribute"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1942 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1943 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1944 if (!attr) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1945 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1946 "field attr is required for Attribute"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1947 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1948 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1949 if (!ctx) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1950 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1951 "field ctx is required for Attribute"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1952 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1953 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1954 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1955 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1956 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1957 p->kind = Attribute_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1958 p->v.Attribute.value = value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1959 p->v.Attribute.attr = attr; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1960 p->v.Attribute.ctx = ctx; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1961 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1962 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1963 return p; |
| 35742 | 1964 } |
| 1965 | |
| 1966 expr_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1967 Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int lineno, int |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1968 col_offset, PyArena *arena) |
| 35742 | 1969 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1970 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1971 if (!value) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1972 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1973 "field value is required for Subscript"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1974 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1975 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1976 if (!slice) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1977 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1978 "field slice is required for Subscript"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1979 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1980 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1981 if (!ctx) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1982 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1983 "field ctx is required for Subscript"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1984 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1985 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1986 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1987 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1988 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1989 p->kind = Subscript_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1990 p->v.Subscript.value = value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1991 p->v.Subscript.slice = slice; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1992 p->v.Subscript.ctx = ctx; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1993 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1994 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1995 return p; |
| 35742 | 1996 } |
| 1997 | |
| 1998 expr_ty | |
|
41699
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
1999 Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset, PyArena |
|
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
2000 *arena) |
|
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
2001 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2002 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2003 if (!value) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2004 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2005 "field value is required for Starred"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2006 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2007 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2008 if (!ctx) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2009 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2010 "field ctx is required for Starred"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2011 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2012 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2013 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2014 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2015 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2016 p->kind = Starred_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2017 p->v.Starred.value = value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2018 p->v.Starred.ctx = ctx; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2019 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2020 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2021 return p; |
|
41699
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
2022 } |
|
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
2023 |
|
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
2024 expr_ty |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
2025 Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, PyArena |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
2026 *arena) |
| 35742 | 2027 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2028 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2029 if (!id) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2030 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2031 "field id is required for Name"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2032 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2033 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2034 if (!ctx) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2035 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2036 "field ctx is required for Name"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2037 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2038 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2039 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2040 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2041 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2042 p->kind = Name_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2043 p->v.Name.id = id; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2044 p->v.Name.ctx = ctx; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2045 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2046 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2047 return p; |
| 35742 | 2048 } |
| 2049 | |
| 2050 expr_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
2051 List(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
2052 *arena) |
| 35742 | 2053 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2054 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2055 if (!ctx) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2056 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2057 "field ctx is required for List"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2058 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2059 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2060 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2061 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2062 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2063 p->kind = List_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2064 p->v.List.elts = elts; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2065 p->v.List.ctx = ctx; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2066 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2067 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2068 return p; |
| 35742 | 2069 } |
| 2070 | |
| 2071 expr_ty | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
2072 Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
2073 *arena) |
| 35742 | 2074 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2075 expr_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2076 if (!ctx) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2077 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2078 "field ctx is required for Tuple"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2079 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2080 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2081 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2082 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2083 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2084 p->kind = Tuple_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2085 p->v.Tuple.elts = elts; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2086 p->v.Tuple.ctx = ctx; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2087 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2088 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2089 return p; |
| 35742 | 2090 } |
| 2091 | |
| 2092 slice_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
2093 Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena) |
| 35742 | 2094 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2095 slice_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2096 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2097 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2098 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2099 p->kind = Slice_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2100 p->v.Slice.lower = lower; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2101 p->v.Slice.upper = upper; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2102 p->v.Slice.step = step; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2103 return p; |
| 35742 | 2104 } |
| 2105 | |
| 2106 slice_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
2107 ExtSlice(asdl_seq * dims, PyArena *arena) |
| 35742 | 2108 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2109 slice_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2110 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2111 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2112 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2113 p->kind = ExtSlice_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2114 p->v.ExtSlice.dims = dims; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2115 return p; |
| 35742 | 2116 } |
| 2117 | |
| 2118 slice_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
2119 Index(expr_ty value, PyArena *arena) |
| 35742 | 2120 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2121 slice_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2122 if (!value) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2123 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2124 "field value is required for Index"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2125 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2126 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2127 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2128 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2129 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2130 p->kind = Index_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2131 p->v.Index.value = value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2132 return p; |
| 35742 | 2133 } |
| 2134 | |
| 2135 comprehension_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
2136 comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena) |
| 35742 | 2137 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2138 comprehension_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2139 if (!target) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2140 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2141 "field target is required for comprehension"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2142 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2143 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2144 if (!iter) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2145 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2146 "field iter is required for comprehension"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2147 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2148 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2149 p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2150 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2151 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2152 p->target = target; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2153 p->iter = iter; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2154 p->ifs = ifs; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2155 return p; |
| 35742 | 2156 } |
| 2157 | |
| 2158 excepthandler_ty | |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
2159 ExceptHandler(expr_ty type, identifier name, asdl_seq * body, int lineno, int |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36794
diff
changeset
|
2160 col_offset, PyArena *arena) |
| 35742 | 2161 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2162 excepthandler_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2163 p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2164 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2165 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2166 p->kind = ExceptHandler_kind; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2167 p->v.ExceptHandler.type = type; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2168 p->v.ExceptHandler.name = name; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2169 p->v.ExceptHandler.body = body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2170 p->lineno = lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2171 p->col_offset = col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2172 return p; |
| 35742 | 2173 } |
| 2174 | |
| 2175 arguments_ty | |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
2176 arguments(asdl_seq * args, identifier vararg, expr_ty varargannotation, |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
2177 asdl_seq * kwonlyargs, identifier kwarg, expr_ty kwargannotation, |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
2178 asdl_seq * defaults, asdl_seq * kw_defaults, PyArena *arena) |
| 35742 | 2179 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2180 arguments_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2181 p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2182 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2183 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2184 p->args = args; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2185 p->vararg = vararg; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2186 p->varargannotation = varargannotation; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2187 p->kwonlyargs = kwonlyargs; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2188 p->kwarg = kwarg; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2189 p->kwargannotation = kwargannotation; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2190 p->defaults = defaults; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2191 p->kw_defaults = kw_defaults; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2192 return p; |
| 35742 | 2193 } |
| 2194 | |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
2195 arg_ty |
|
41717
9ad84070b22d
Merged revisions 55328-55341 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41699
diff
changeset
|
2196 arg(identifier arg, expr_ty annotation, PyArena *arena) |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
2197 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2198 arg_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2199 if (!arg) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2200 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2201 "field arg is required for arg"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2202 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2203 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2204 p = (arg_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2205 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2206 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2207 p->arg = arg; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2208 p->annotation = annotation; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2209 return p; |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
2210 } |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
2211 |
| 35742 | 2212 keyword_ty |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
2213 keyword(identifier arg, expr_ty value, PyArena *arena) |
| 35742 | 2214 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2215 keyword_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2216 if (!arg) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2217 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2218 "field arg is required for keyword"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2219 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2220 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2221 if (!value) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2222 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2223 "field value is required for keyword"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2224 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2225 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2226 p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2227 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2228 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2229 p->arg = arg; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2230 p->value = value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2231 return p; |
| 35742 | 2232 } |
| 2233 | |
| 2234 alias_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
2235 alias(identifier name, identifier asname, PyArena *arena) |
| 35742 | 2236 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2237 alias_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2238 if (!name) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2239 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2240 "field name is required for alias"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2241 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2242 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2243 p = (alias_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2244 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2245 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2246 p->name = name; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2247 p->asname = asname; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2248 return p; |
| 35742 | 2249 } |
| 2250 | |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
2251 withitem_ty |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
2252 withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena) |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
2253 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2254 withitem_ty p; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2255 if (!context_expr) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2256 PyErr_SetString(PyExc_ValueError, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2257 "field context_expr is required for withitem"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2258 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2259 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2260 p = (withitem_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2261 if (!p) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2262 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2263 p->context_expr = context_expr; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2264 p->optional_vars = optional_vars; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2265 return p; |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
2266 } |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
2267 |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2268 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2269 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2270 ast2obj_mod(void* _o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2271 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2272 mod_ty o = (mod_ty)_o; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2273 PyObject *result = NULL, *value = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2274 if (!o) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2275 Py_INCREF(Py_None); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2276 return Py_None; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2277 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2278 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2279 switch (o->kind) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2280 case Module_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2281 result = PyType_GenericNew(Module_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2282 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2283 value = ast2obj_list(o->v.Module.body, ast2obj_stmt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2284 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2285 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2286 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2287 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2288 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2289 case Interactive_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2290 result = PyType_GenericNew(Interactive_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2291 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2292 value = ast2obj_list(o->v.Interactive.body, ast2obj_stmt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2293 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2294 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2295 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2296 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2297 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2298 case Expression_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2299 result = PyType_GenericNew(Expression_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2300 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2301 value = ast2obj_expr(o->v.Expression.body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2302 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2303 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2304 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2305 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2306 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2307 case Suite_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2308 result = PyType_GenericNew(Suite_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2309 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2310 value = ast2obj_list(o->v.Suite.body, ast2obj_stmt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2311 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2312 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2313 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2314 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2315 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2316 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2317 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2318 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2319 Py_XDECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2320 Py_XDECREF(result); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2321 return NULL; |
| 36174 | 2322 } |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2323 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2324 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2325 ast2obj_stmt(void* _o) |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2326 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2327 stmt_ty o = (stmt_ty)_o; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2328 PyObject *result = NULL, *value = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2329 if (!o) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2330 Py_INCREF(Py_None); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2331 return Py_None; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2332 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2333 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2334 switch (o->kind) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2335 case FunctionDef_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2336 result = PyType_GenericNew(FunctionDef_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2337 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2338 value = ast2obj_identifier(o->v.FunctionDef.name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2339 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2340 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2341 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2342 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2343 value = ast2obj_arguments(o->v.FunctionDef.args); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2344 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2345 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2346 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2347 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2348 value = ast2obj_list(o->v.FunctionDef.body, ast2obj_stmt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2349 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2350 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2351 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2352 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2353 value = ast2obj_list(o->v.FunctionDef.decorator_list, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2354 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2355 if (_PyObject_SetAttrId(result, &PyId_decorator_list, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2356 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2357 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2358 value = ast2obj_expr(o->v.FunctionDef.returns); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2359 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2360 if (_PyObject_SetAttrId(result, &PyId_returns, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2361 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2362 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2363 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2364 case ClassDef_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2365 result = PyType_GenericNew(ClassDef_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2366 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2367 value = ast2obj_identifier(o->v.ClassDef.name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2368 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2369 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2370 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2371 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2372 value = ast2obj_list(o->v.ClassDef.bases, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2373 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2374 if (_PyObject_SetAttrId(result, &PyId_bases, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2375 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2376 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2377 value = ast2obj_list(o->v.ClassDef.keywords, ast2obj_keyword); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2378 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2379 if (_PyObject_SetAttrId(result, &PyId_keywords, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2380 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2381 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2382 value = ast2obj_expr(o->v.ClassDef.starargs); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2383 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2384 if (_PyObject_SetAttrId(result, &PyId_starargs, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2385 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2386 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2387 value = ast2obj_expr(o->v.ClassDef.kwargs); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2388 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2389 if (_PyObject_SetAttrId(result, &PyId_kwargs, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2390 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2391 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2392 value = ast2obj_list(o->v.ClassDef.body, ast2obj_stmt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2393 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2394 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2395 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2396 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2397 value = ast2obj_list(o->v.ClassDef.decorator_list, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2398 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2399 if (_PyObject_SetAttrId(result, &PyId_decorator_list, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2400 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2401 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2402 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2403 case Return_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2404 result = PyType_GenericNew(Return_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2405 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2406 value = ast2obj_expr(o->v.Return.value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2407 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2408 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2409 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2410 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2411 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2412 case Delete_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2413 result = PyType_GenericNew(Delete_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2414 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2415 value = ast2obj_list(o->v.Delete.targets, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2416 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2417 if (_PyObject_SetAttrId(result, &PyId_targets, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2418 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2419 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2420 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2421 case Assign_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2422 result = PyType_GenericNew(Assign_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2423 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2424 value = ast2obj_list(o->v.Assign.targets, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2425 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2426 if (_PyObject_SetAttrId(result, &PyId_targets, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2427 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2428 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2429 value = ast2obj_expr(o->v.Assign.value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2430 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2431 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2432 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2433 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2434 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2435 case AugAssign_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2436 result = PyType_GenericNew(AugAssign_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2437 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2438 value = ast2obj_expr(o->v.AugAssign.target); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2439 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2440 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2441 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2442 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2443 value = ast2obj_operator(o->v.AugAssign.op); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2444 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2445 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2446 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2447 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2448 value = ast2obj_expr(o->v.AugAssign.value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2449 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2450 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2451 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2452 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2453 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2454 case For_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2455 result = PyType_GenericNew(For_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2456 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2457 value = ast2obj_expr(o->v.For.target); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2458 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2459 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2460 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2461 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2462 value = ast2obj_expr(o->v.For.iter); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2463 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2464 if (_PyObject_SetAttrId(result, &PyId_iter, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2465 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2466 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2467 value = ast2obj_list(o->v.For.body, ast2obj_stmt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2468 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2469 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2470 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2471 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2472 value = ast2obj_list(o->v.For.orelse, ast2obj_stmt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2473 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2474 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2475 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2476 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2477 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2478 case While_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2479 result = PyType_GenericNew(While_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2480 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2481 value = ast2obj_expr(o->v.While.test); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2482 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2483 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2484 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2485 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2486 value = ast2obj_list(o->v.While.body, ast2obj_stmt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2487 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2488 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2489 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2490 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2491 value = ast2obj_list(o->v.While.orelse, ast2obj_stmt); |
| 36669 | 2492 if (!value) goto failed; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2493 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2494 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2495 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2496 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2497 case If_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2498 result = PyType_GenericNew(If_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2499 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2500 value = ast2obj_expr(o->v.If.test); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2501 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2502 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2503 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2504 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2505 value = ast2obj_list(o->v.If.body, ast2obj_stmt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2506 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2507 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2508 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2509 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2510 value = ast2obj_list(o->v.If.orelse, ast2obj_stmt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2511 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2512 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2513 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2514 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2515 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2516 case With_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2517 result = PyType_GenericNew(With_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2518 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2519 value = ast2obj_list(o->v.With.items, ast2obj_withitem); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2520 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2521 if (_PyObject_SetAttrId(result, &PyId_items, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2522 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2523 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2524 value = ast2obj_list(o->v.With.body, ast2obj_stmt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2525 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2526 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2527 goto failed; |
|
36794
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2528 Py_DECREF(value); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2529 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2530 case Raise_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2531 result = PyType_GenericNew(Raise_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2532 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2533 value = ast2obj_expr(o->v.Raise.exc); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2534 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2535 if (_PyObject_SetAttrId(result, &PyId_exc, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2536 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2537 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2538 value = ast2obj_expr(o->v.Raise.cause); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2539 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2540 if (_PyObject_SetAttrId(result, &PyId_cause, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2541 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2542 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2543 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2544 case Try_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2545 result = PyType_GenericNew(Try_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2546 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2547 value = ast2obj_list(o->v.Try.body, ast2obj_stmt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2548 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2549 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2550 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2551 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2552 value = ast2obj_list(o->v.Try.handlers, ast2obj_excepthandler); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2553 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2554 if (_PyObject_SetAttrId(result, &PyId_handlers, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2555 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2556 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2557 value = ast2obj_list(o->v.Try.orelse, ast2obj_stmt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2558 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2559 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2560 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2561 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2562 value = ast2obj_list(o->v.Try.finalbody, ast2obj_stmt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2563 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2564 if (_PyObject_SetAttrId(result, &PyId_finalbody, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2565 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2566 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2567 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2568 case Assert_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2569 result = PyType_GenericNew(Assert_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2570 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2571 value = ast2obj_expr(o->v.Assert.test); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2572 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2573 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2574 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2575 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2576 value = ast2obj_expr(o->v.Assert.msg); |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
2577 if (!value) goto failed; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2578 if (_PyObject_SetAttrId(result, &PyId_msg, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2579 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2580 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2581 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2582 case Import_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2583 result = PyType_GenericNew(Import_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2584 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2585 value = ast2obj_list(o->v.Import.names, ast2obj_alias); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2586 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2587 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2588 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2589 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2590 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2591 case ImportFrom_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2592 result = PyType_GenericNew(ImportFrom_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2593 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2594 value = ast2obj_identifier(o->v.ImportFrom.module); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2595 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2596 if (_PyObject_SetAttrId(result, &PyId_module, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2597 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2598 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2599 value = ast2obj_list(o->v.ImportFrom.names, ast2obj_alias); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2600 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2601 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2602 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2603 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2604 value = ast2obj_int(o->v.ImportFrom.level); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2605 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2606 if (_PyObject_SetAttrId(result, &PyId_level, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2607 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2608 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2609 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2610 case Global_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2611 result = PyType_GenericNew(Global_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2612 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2613 value = ast2obj_list(o->v.Global.names, ast2obj_identifier); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2614 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2615 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2616 goto failed; |
|
36794
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2617 Py_DECREF(value); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2618 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2619 case Nonlocal_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2620 result = PyType_GenericNew(Nonlocal_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2621 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2622 value = ast2obj_list(o->v.Nonlocal.names, ast2obj_identifier); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2623 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2624 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2625 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2626 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2627 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2628 case Expr_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2629 result = PyType_GenericNew(Expr_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2630 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2631 value = ast2obj_expr(o->v.Expr.value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2632 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2633 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2634 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2635 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2636 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2637 case Pass_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2638 result = PyType_GenericNew(Pass_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2639 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2640 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2641 case Break_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2642 result = PyType_GenericNew(Break_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2643 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2644 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2645 case Continue_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2646 result = PyType_GenericNew(Continue_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2647 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2648 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2649 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2650 value = ast2obj_int(o->lineno); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2651 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2652 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2653 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2654 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2655 value = ast2obj_int(o->col_offset); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2656 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2657 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2658 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2659 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2660 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2661 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2662 Py_XDECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2663 Py_XDECREF(result); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2664 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2665 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2666 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2667 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2668 ast2obj_expr(void* _o) |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2669 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2670 expr_ty o = (expr_ty)_o; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2671 PyObject *result = NULL, *value = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2672 if (!o) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2673 Py_INCREF(Py_None); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2674 return Py_None; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2675 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2676 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2677 switch (o->kind) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2678 case BoolOp_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2679 result = PyType_GenericNew(BoolOp_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2680 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2681 value = ast2obj_boolop(o->v.BoolOp.op); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2682 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2683 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2684 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2685 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2686 value = ast2obj_list(o->v.BoolOp.values, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2687 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2688 if (_PyObject_SetAttrId(result, &PyId_values, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2689 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2690 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2691 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2692 case BinOp_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2693 result = PyType_GenericNew(BinOp_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2694 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2695 value = ast2obj_expr(o->v.BinOp.left); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2696 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2697 if (_PyObject_SetAttrId(result, &PyId_left, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2698 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2699 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2700 value = ast2obj_operator(o->v.BinOp.op); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2701 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2702 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2703 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2704 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2705 value = ast2obj_expr(o->v.BinOp.right); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2706 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2707 if (_PyObject_SetAttrId(result, &PyId_right, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2708 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2709 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2710 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2711 case UnaryOp_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2712 result = PyType_GenericNew(UnaryOp_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2713 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2714 value = ast2obj_unaryop(o->v.UnaryOp.op); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2715 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2716 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2717 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2718 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2719 value = ast2obj_expr(o->v.UnaryOp.operand); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2720 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2721 if (_PyObject_SetAttrId(result, &PyId_operand, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2722 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2723 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2724 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2725 case Lambda_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2726 result = PyType_GenericNew(Lambda_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2727 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2728 value = ast2obj_arguments(o->v.Lambda.args); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2729 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2730 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2731 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2732 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2733 value = ast2obj_expr(o->v.Lambda.body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2734 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2735 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2736 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2737 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2738 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2739 case IfExp_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2740 result = PyType_GenericNew(IfExp_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2741 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2742 value = ast2obj_expr(o->v.IfExp.test); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2743 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2744 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2745 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2746 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2747 value = ast2obj_expr(o->v.IfExp.body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2748 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2749 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2750 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2751 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2752 value = ast2obj_expr(o->v.IfExp.orelse); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2753 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2754 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2755 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2756 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2757 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2758 case Dict_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2759 result = PyType_GenericNew(Dict_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2760 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2761 value = ast2obj_list(o->v.Dict.keys, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2762 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2763 if (_PyObject_SetAttrId(result, &PyId_keys, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2764 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2765 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2766 value = ast2obj_list(o->v.Dict.values, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2767 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2768 if (_PyObject_SetAttrId(result, &PyId_values, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2769 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2770 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2771 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2772 case Set_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2773 result = PyType_GenericNew(Set_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2774 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2775 value = ast2obj_list(o->v.Set.elts, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2776 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2777 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2778 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2779 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2780 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2781 case ListComp_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2782 result = PyType_GenericNew(ListComp_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2783 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2784 value = ast2obj_expr(o->v.ListComp.elt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2785 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2786 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2787 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2788 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2789 value = ast2obj_list(o->v.ListComp.generators, ast2obj_comprehension); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2790 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2791 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2792 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2793 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2794 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2795 case SetComp_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2796 result = PyType_GenericNew(SetComp_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2797 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2798 value = ast2obj_expr(o->v.SetComp.elt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2799 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2800 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2801 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2802 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2803 value = ast2obj_list(o->v.SetComp.generators, ast2obj_comprehension); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2804 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2805 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2806 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2807 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2808 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2809 case DictComp_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2810 result = PyType_GenericNew(DictComp_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2811 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2812 value = ast2obj_expr(o->v.DictComp.key); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2813 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2814 if (_PyObject_SetAttrId(result, &PyId_key, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2815 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2816 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2817 value = ast2obj_expr(o->v.DictComp.value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2818 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2819 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2820 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2821 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2822 value = ast2obj_list(o->v.DictComp.generators, ast2obj_comprehension); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2823 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2824 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2825 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2826 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2827 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2828 case GeneratorExp_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2829 result = PyType_GenericNew(GeneratorExp_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2830 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2831 value = ast2obj_expr(o->v.GeneratorExp.elt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2832 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2833 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2834 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2835 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2836 value = ast2obj_list(o->v.GeneratorExp.generators, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2837 ast2obj_comprehension); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2838 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2839 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2840 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2841 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2842 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2843 case Yield_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2844 result = PyType_GenericNew(Yield_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2845 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2846 value = ast2obj_expr(o->v.Yield.value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2847 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2848 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2849 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2850 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2851 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2852 case YieldFrom_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2853 result = PyType_GenericNew(YieldFrom_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2854 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2855 value = ast2obj_expr(o->v.YieldFrom.value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2856 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2857 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2858 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2859 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2860 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2861 case Compare_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2862 result = PyType_GenericNew(Compare_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2863 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2864 value = ast2obj_expr(o->v.Compare.left); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2865 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2866 if (_PyObject_SetAttrId(result, &PyId_left, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2867 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2868 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2869 { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2870 Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2871 value = PyList_New(n); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2872 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2873 for(i = 0; i < n; i++) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2874 PyList_SET_ITEM(value, i, ast2obj_cmpop((cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i))); |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2875 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2876 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2877 if (_PyObject_SetAttrId(result, &PyId_ops, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2878 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2879 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2880 value = ast2obj_list(o->v.Compare.comparators, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2881 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2882 if (_PyObject_SetAttrId(result, &PyId_comparators, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2883 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2884 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2885 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2886 case Call_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2887 result = PyType_GenericNew(Call_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2888 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2889 value = ast2obj_expr(o->v.Call.func); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2890 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2891 if (_PyObject_SetAttrId(result, &PyId_func, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2892 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2893 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2894 value = ast2obj_list(o->v.Call.args, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2895 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2896 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2897 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2898 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2899 value = ast2obj_list(o->v.Call.keywords, ast2obj_keyword); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2900 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2901 if (_PyObject_SetAttrId(result, &PyId_keywords, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2902 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2903 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2904 value = ast2obj_expr(o->v.Call.starargs); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2905 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2906 if (_PyObject_SetAttrId(result, &PyId_starargs, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2907 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2908 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2909 value = ast2obj_expr(o->v.Call.kwargs); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2910 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2911 if (_PyObject_SetAttrId(result, &PyId_kwargs, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2912 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2913 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2914 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2915 case Num_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2916 result = PyType_GenericNew(Num_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2917 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2918 value = ast2obj_object(o->v.Num.n); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2919 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2920 if (_PyObject_SetAttrId(result, &PyId_n, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2921 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2922 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2923 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2924 case Str_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2925 result = PyType_GenericNew(Str_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2926 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2927 value = ast2obj_string(o->v.Str.s); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2928 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2929 if (_PyObject_SetAttrId(result, &PyId_s, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2930 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2931 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2932 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2933 case Bytes_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2934 result = PyType_GenericNew(Bytes_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2935 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2936 value = ast2obj_bytes(o->v.Bytes.s); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2937 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2938 if (_PyObject_SetAttrId(result, &PyId_s, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2939 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2940 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2941 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2942 case Ellipsis_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2943 result = PyType_GenericNew(Ellipsis_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2944 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2945 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2946 case Attribute_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2947 result = PyType_GenericNew(Attribute_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2948 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2949 value = ast2obj_expr(o->v.Attribute.value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2950 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2951 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2952 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2953 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2954 value = ast2obj_identifier(o->v.Attribute.attr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2955 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2956 if (_PyObject_SetAttrId(result, &PyId_attr, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2957 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2958 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2959 value = ast2obj_expr_context(o->v.Attribute.ctx); |
| 36669 | 2960 if (!value) goto failed; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2961 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2962 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2963 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2964 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2965 case Subscript_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2966 result = PyType_GenericNew(Subscript_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2967 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2968 value = ast2obj_expr(o->v.Subscript.value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2969 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2970 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2971 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2972 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2973 value = ast2obj_slice(o->v.Subscript.slice); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2974 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2975 if (_PyObject_SetAttrId(result, &PyId_slice, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2976 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2977 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2978 value = ast2obj_expr_context(o->v.Subscript.ctx); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2979 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2980 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2981 goto failed; |
|
36794
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2982 Py_DECREF(value); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2983 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2984 case Starred_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2985 result = PyType_GenericNew(Starred_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2986 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2987 value = ast2obj_expr(o->v.Starred.value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2988 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2989 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2990 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2991 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2992 value = ast2obj_expr_context(o->v.Starred.ctx); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2993 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2994 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2995 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2996 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2997 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2998 case Name_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2999 result = PyType_GenericNew(Name_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3000 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3001 value = ast2obj_identifier(o->v.Name.id); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3002 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3003 if (_PyObject_SetAttrId(result, &PyId_id, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3004 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3005 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3006 value = ast2obj_expr_context(o->v.Name.ctx); |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
3007 if (!value) goto failed; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3008 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3009 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3010 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3011 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3012 case List_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3013 result = PyType_GenericNew(List_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3014 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3015 value = ast2obj_list(o->v.List.elts, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3016 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3017 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3018 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3019 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3020 value = ast2obj_expr_context(o->v.List.ctx); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3021 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3022 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3023 goto failed; |
|
36794
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
3024 Py_DECREF(value); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3025 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3026 case Tuple_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3027 result = PyType_GenericNew(Tuple_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3028 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3029 value = ast2obj_list(o->v.Tuple.elts, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3030 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3031 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3032 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3033 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3034 value = ast2obj_expr_context(o->v.Tuple.ctx); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3035 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3036 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3037 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3038 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3039 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3040 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3041 value = ast2obj_int(o->lineno); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3042 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3043 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3044 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3045 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3046 value = ast2obj_int(o->col_offset); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3047 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3048 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3049 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3050 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3051 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3052 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3053 Py_XDECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3054 Py_XDECREF(result); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3055 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3056 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3057 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3058 PyObject* ast2obj_expr_context(expr_context_ty o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3059 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3060 switch(o) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3061 case Load: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3062 Py_INCREF(Load_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3063 return Load_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3064 case Store: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3065 Py_INCREF(Store_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3066 return Store_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3067 case Del: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3068 Py_INCREF(Del_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3069 return Del_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3070 case AugLoad: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3071 Py_INCREF(AugLoad_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3072 return AugLoad_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3073 case AugStore: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3074 Py_INCREF(AugStore_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3075 return AugStore_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3076 case Param: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3077 Py_INCREF(Param_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3078 return Param_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3079 default: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3080 /* should never happen, but just in case ... */ |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3081 PyErr_Format(PyExc_SystemError, "unknown expr_context found"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3082 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3083 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3084 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3085 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3086 ast2obj_slice(void* _o) |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3087 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3088 slice_ty o = (slice_ty)_o; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3089 PyObject *result = NULL, *value = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3090 if (!o) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3091 Py_INCREF(Py_None); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3092 return Py_None; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3093 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3094 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3095 switch (o->kind) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3096 case Slice_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3097 result = PyType_GenericNew(Slice_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3098 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3099 value = ast2obj_expr(o->v.Slice.lower); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3100 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3101 if (_PyObject_SetAttrId(result, &PyId_lower, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3102 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3103 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3104 value = ast2obj_expr(o->v.Slice.upper); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3105 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3106 if (_PyObject_SetAttrId(result, &PyId_upper, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3107 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3108 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3109 value = ast2obj_expr(o->v.Slice.step); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3110 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3111 if (_PyObject_SetAttrId(result, &PyId_step, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3112 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3113 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3114 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3115 case ExtSlice_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3116 result = PyType_GenericNew(ExtSlice_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3117 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3118 value = ast2obj_list(o->v.ExtSlice.dims, ast2obj_slice); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3119 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3120 if (_PyObject_SetAttrId(result, &PyId_dims, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3121 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3122 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3123 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3124 case Index_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3125 result = PyType_GenericNew(Index_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3126 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3127 value = ast2obj_expr(o->v.Index.value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3128 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3129 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3130 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3131 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3132 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3133 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3134 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3135 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3136 Py_XDECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3137 Py_XDECREF(result); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3138 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3139 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3140 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3141 PyObject* ast2obj_boolop(boolop_ty o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3142 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3143 switch(o) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3144 case And: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3145 Py_INCREF(And_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3146 return And_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3147 case Or: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3148 Py_INCREF(Or_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3149 return Or_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3150 default: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3151 /* should never happen, but just in case ... */ |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3152 PyErr_Format(PyExc_SystemError, "unknown boolop found"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3153 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3154 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3155 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3156 PyObject* ast2obj_operator(operator_ty o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3157 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3158 switch(o) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3159 case Add: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3160 Py_INCREF(Add_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3161 return Add_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3162 case Sub: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3163 Py_INCREF(Sub_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3164 return Sub_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3165 case Mult: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3166 Py_INCREF(Mult_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3167 return Mult_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3168 case Div: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3169 Py_INCREF(Div_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3170 return Div_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3171 case Mod: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3172 Py_INCREF(Mod_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3173 return Mod_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3174 case Pow: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3175 Py_INCREF(Pow_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3176 return Pow_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3177 case LShift: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3178 Py_INCREF(LShift_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3179 return LShift_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3180 case RShift: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3181 Py_INCREF(RShift_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3182 return RShift_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3183 case BitOr: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3184 Py_INCREF(BitOr_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3185 return BitOr_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3186 case BitXor: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3187 Py_INCREF(BitXor_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3188 return BitXor_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3189 case BitAnd: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3190 Py_INCREF(BitAnd_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3191 return BitAnd_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3192 case FloorDiv: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3193 Py_INCREF(FloorDiv_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3194 return FloorDiv_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3195 default: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3196 /* should never happen, but just in case ... */ |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3197 PyErr_Format(PyExc_SystemError, "unknown operator found"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3198 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3199 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3200 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3201 PyObject* ast2obj_unaryop(unaryop_ty o) |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3202 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3203 switch(o) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3204 case Invert: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3205 Py_INCREF(Invert_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3206 return Invert_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3207 case Not: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3208 Py_INCREF(Not_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3209 return Not_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3210 case UAdd: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3211 Py_INCREF(UAdd_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3212 return UAdd_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3213 case USub: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3214 Py_INCREF(USub_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3215 return USub_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3216 default: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3217 /* should never happen, but just in case ... */ |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3218 PyErr_Format(PyExc_SystemError, "unknown unaryop found"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3219 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3220 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3221 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3222 PyObject* ast2obj_cmpop(cmpop_ty o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3223 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3224 switch(o) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3225 case Eq: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3226 Py_INCREF(Eq_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3227 return Eq_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3228 case NotEq: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3229 Py_INCREF(NotEq_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3230 return NotEq_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3231 case Lt: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3232 Py_INCREF(Lt_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3233 return Lt_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3234 case LtE: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3235 Py_INCREF(LtE_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3236 return LtE_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3237 case Gt: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3238 Py_INCREF(Gt_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3239 return Gt_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3240 case GtE: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3241 Py_INCREF(GtE_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3242 return GtE_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3243 case Is: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3244 Py_INCREF(Is_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3245 return Is_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3246 case IsNot: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3247 Py_INCREF(IsNot_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3248 return IsNot_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3249 case In: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3250 Py_INCREF(In_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3251 return In_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3252 case NotIn: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3253 Py_INCREF(NotIn_singleton); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3254 return NotIn_singleton; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3255 default: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3256 /* should never happen, but just in case ... */ |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3257 PyErr_Format(PyExc_SystemError, "unknown cmpop found"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3258 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3259 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3260 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3261 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3262 ast2obj_comprehension(void* _o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3263 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3264 comprehension_ty o = (comprehension_ty)_o; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3265 PyObject *result = NULL, *value = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3266 if (!o) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3267 Py_INCREF(Py_None); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3268 return Py_None; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3269 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3270 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3271 result = PyType_GenericNew(comprehension_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3272 if (!result) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3273 value = ast2obj_expr(o->target); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3274 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3275 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3276 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3277 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3278 value = ast2obj_expr(o->iter); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3279 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3280 if (_PyObject_SetAttrId(result, &PyId_iter, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3281 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3282 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3283 value = ast2obj_list(o->ifs, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3284 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3285 if (_PyObject_SetAttrId(result, &PyId_ifs, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3286 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3287 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3288 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3289 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3290 Py_XDECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3291 Py_XDECREF(result); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3292 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3293 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3294 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3295 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3296 ast2obj_excepthandler(void* _o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3297 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3298 excepthandler_ty o = (excepthandler_ty)_o; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3299 PyObject *result = NULL, *value = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3300 if (!o) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3301 Py_INCREF(Py_None); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3302 return Py_None; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3303 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3304 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3305 switch (o->kind) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3306 case ExceptHandler_kind: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3307 result = PyType_GenericNew(ExceptHandler_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3308 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3309 value = ast2obj_expr(o->v.ExceptHandler.type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3310 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3311 if (_PyObject_SetAttrId(result, &PyId_type, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3312 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3313 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3314 value = ast2obj_identifier(o->v.ExceptHandler.name); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36794
diff
changeset
|
3315 if (!value) goto failed; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3316 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3317 goto failed; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36794
diff
changeset
|
3318 Py_DECREF(value); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3319 value = ast2obj_list(o->v.ExceptHandler.body, ast2obj_stmt); |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36794
diff
changeset
|
3320 if (!value) goto failed; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3321 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3322 goto failed; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36794
diff
changeset
|
3323 Py_DECREF(value); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3324 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3325 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3326 value = ast2obj_int(o->lineno); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3327 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3328 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3329 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3330 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3331 value = ast2obj_int(o->col_offset); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3332 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3333 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3334 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3335 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3336 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3337 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3338 Py_XDECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3339 Py_XDECREF(result); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3340 return NULL; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3341 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3342 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3343 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3344 ast2obj_arguments(void* _o) |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3345 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3346 arguments_ty o = (arguments_ty)_o; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3347 PyObject *result = NULL, *value = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3348 if (!o) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3349 Py_INCREF(Py_None); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3350 return Py_None; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3351 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3352 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3353 result = PyType_GenericNew(arguments_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3354 if (!result) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3355 value = ast2obj_list(o->args, ast2obj_arg); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3356 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3357 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3358 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3359 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3360 value = ast2obj_identifier(o->vararg); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3361 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3362 if (_PyObject_SetAttrId(result, &PyId_vararg, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3363 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3364 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3365 value = ast2obj_expr(o->varargannotation); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3366 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3367 if (_PyObject_SetAttrId(result, &PyId_varargannotation, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3368 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3369 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3370 value = ast2obj_list(o->kwonlyargs, ast2obj_arg); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3371 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3372 if (_PyObject_SetAttrId(result, &PyId_kwonlyargs, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3373 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3374 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3375 value = ast2obj_identifier(o->kwarg); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3376 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3377 if (_PyObject_SetAttrId(result, &PyId_kwarg, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3378 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3379 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3380 value = ast2obj_expr(o->kwargannotation); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3381 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3382 if (_PyObject_SetAttrId(result, &PyId_kwargannotation, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3383 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3384 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3385 value = ast2obj_list(o->defaults, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3386 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3387 if (_PyObject_SetAttrId(result, &PyId_defaults, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3388 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3389 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3390 value = ast2obj_list(o->kw_defaults, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3391 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3392 if (_PyObject_SetAttrId(result, &PyId_kw_defaults, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3393 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3394 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3395 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3396 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3397 Py_XDECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3398 Py_XDECREF(result); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3399 return NULL; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3400 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3401 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3402 PyObject* |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3403 ast2obj_arg(void* _o) |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3404 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3405 arg_ty o = (arg_ty)_o; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3406 PyObject *result = NULL, *value = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3407 if (!o) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3408 Py_INCREF(Py_None); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3409 return Py_None; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3410 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3411 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3412 result = PyType_GenericNew(arg_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3413 if (!result) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3414 value = ast2obj_identifier(o->arg); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3415 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3416 if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3417 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3418 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3419 value = ast2obj_expr(o->annotation); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3420 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3421 if (_PyObject_SetAttrId(result, &PyId_annotation, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3422 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3423 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3424 return result; |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3425 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3426 Py_XDECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3427 Py_XDECREF(result); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3428 return NULL; |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3429 } |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3430 |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3431 PyObject* |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3432 ast2obj_keyword(void* _o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3433 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3434 keyword_ty o = (keyword_ty)_o; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3435 PyObject *result = NULL, *value = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3436 if (!o) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3437 Py_INCREF(Py_None); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3438 return Py_None; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3439 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3440 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3441 result = PyType_GenericNew(keyword_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3442 if (!result) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3443 value = ast2obj_identifier(o->arg); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3444 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3445 if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3446 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3447 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3448 value = ast2obj_expr(o->value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3449 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3450 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3451 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3452 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3453 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3454 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3455 Py_XDECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3456 Py_XDECREF(result); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3457 return NULL; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3458 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3459 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3460 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3461 ast2obj_alias(void* _o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3462 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3463 alias_ty o = (alias_ty)_o; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3464 PyObject *result = NULL, *value = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3465 if (!o) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3466 Py_INCREF(Py_None); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3467 return Py_None; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3468 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3469 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3470 result = PyType_GenericNew(alias_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3471 if (!result) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3472 value = ast2obj_identifier(o->name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3473 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3474 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3475 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3476 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3477 value = ast2obj_identifier(o->asname); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3478 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3479 if (_PyObject_SetAttrId(result, &PyId_asname, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3480 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3481 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3482 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3483 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3484 Py_XDECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3485 Py_XDECREF(result); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3486 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3487 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3488 |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
3489 PyObject* |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
3490 ast2obj_withitem(void* _o) |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
3491 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3492 withitem_ty o = (withitem_ty)_o; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3493 PyObject *result = NULL, *value = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3494 if (!o) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3495 Py_INCREF(Py_None); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3496 return Py_None; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3497 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3498 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3499 result = PyType_GenericNew(withitem_type, NULL, NULL); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3500 if (!result) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3501 value = ast2obj_expr(o->context_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3502 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3503 if (_PyObject_SetAttrId(result, &PyId_context_expr, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3504 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3505 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3506 value = ast2obj_expr(o->optional_vars); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3507 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3508 if (_PyObject_SetAttrId(result, &PyId_optional_vars, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3509 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3510 Py_DECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3511 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3512 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3513 Py_XDECREF(value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3514 Py_XDECREF(result); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3515 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3516 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3517 |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3518 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3519 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3520 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3521 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3522 int isinstance; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3523 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3524 PyObject *tmp = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3525 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3526 if (obj == Py_None) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3527 *out = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3528 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3529 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3530 isinstance = PyObject_IsInstance(obj, (PyObject*)Module_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3531 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3532 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3533 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3534 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3535 asdl_seq* body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3536 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3537 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3538 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3539 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3540 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3541 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3542 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3543 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3544 PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3545 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3546 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3547 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3548 body = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3549 if (body == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3550 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3551 stmt_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3552 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3553 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3554 asdl_seq_SET(body, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3555 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3556 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3557 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3558 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Module"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3559 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
3560 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3561 *out = Module(body, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3562 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3563 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3564 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3565 isinstance = PyObject_IsInstance(obj, (PyObject*)Interactive_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3566 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3567 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3568 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3569 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3570 asdl_seq* body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3571 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3572 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3573 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3574 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3575 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3576 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3577 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3578 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3579 PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3580 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3581 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3582 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3583 body = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3584 if (body == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3585 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3586 stmt_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3587 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3588 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3589 asdl_seq_SET(body, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3590 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3591 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3592 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3593 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Interactive"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3594 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
3595 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3596 *out = Interactive(body, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3597 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3598 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3599 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3600 isinstance = PyObject_IsInstance(obj, (PyObject*)Expression_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3601 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3602 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3603 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3604 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3605 expr_ty body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3606 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3607 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3608 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3609 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3610 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3611 res = obj2ast_expr(tmp, &body, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3612 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3613 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3614 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3615 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3616 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
3617 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3618 *out = Expression(body, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3619 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3620 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3621 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3622 isinstance = PyObject_IsInstance(obj, (PyObject*)Suite_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3623 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3624 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3625 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3626 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3627 asdl_seq* body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3628 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3629 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3630 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3631 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3632 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3633 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3634 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3635 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3636 PyErr_Format(PyExc_TypeError, "Suite field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3637 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3638 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3639 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3640 body = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3641 if (body == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3642 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3643 stmt_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3644 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3645 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3646 asdl_seq_SET(body, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3647 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3648 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3649 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3650 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Suite"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3651 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3652 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3653 *out = Suite(body, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3654 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3655 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3656 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3657 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3658 PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3659 failed: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3660 Py_XDECREF(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3661 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3662 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3663 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3664 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3665 obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3666 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3667 int isinstance; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3668 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3669 PyObject *tmp = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3670 int lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3671 int col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3672 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3673 if (obj == Py_None) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3674 *out = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3675 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3676 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3677 if (_PyObject_HasAttrId(obj, &PyId_lineno)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3678 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3679 tmp = _PyObject_GetAttrId(obj, &PyId_lineno); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3680 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3681 res = obj2ast_int(tmp, &lineno, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3682 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3683 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3684 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3685 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3686 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3687 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3688 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3689 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3690 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3691 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3692 res = obj2ast_int(tmp, &col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3693 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3694 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3695 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3696 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3697 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3698 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3699 isinstance = PyObject_IsInstance(obj, (PyObject*)FunctionDef_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3700 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3701 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3702 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3703 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3704 identifier name; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3705 arguments_ty args; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3706 asdl_seq* body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3707 asdl_seq* decorator_list; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3708 expr_ty returns; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3709 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3710 if (_PyObject_HasAttrId(obj, &PyId_name)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3711 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3712 tmp = _PyObject_GetAttrId(obj, &PyId_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3713 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3714 res = obj2ast_identifier(tmp, &name, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3715 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3716 Py_CLEAR(tmp); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3717 } else { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3718 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3719 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3720 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3721 if (_PyObject_HasAttrId(obj, &PyId_args)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3722 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3723 tmp = _PyObject_GetAttrId(obj, &PyId_args); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3724 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3725 res = obj2ast_arguments(tmp, &args, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3726 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3727 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3728 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3729 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3730 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3731 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3732 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3733 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3734 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3735 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3736 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3737 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3738 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3739 PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3740 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3741 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3742 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3743 body = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3744 if (body == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3745 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3746 stmt_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3747 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3748 if (res != 0) goto failed; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3749 asdl_seq_SET(body, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3750 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3751 Py_CLEAR(tmp); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3752 } else { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3753 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from FunctionDef"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3754 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3755 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3756 if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3757 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3758 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3759 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3760 tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3761 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3762 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3763 PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3764 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3765 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3766 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3767 decorator_list = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3768 if (decorator_list == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3769 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3770 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3771 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3772 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3773 asdl_seq_SET(decorator_list, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3774 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3775 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3776 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3777 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from FunctionDef"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3778 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3779 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3780 if (_PyObject_HasAttrId(obj, &PyId_returns)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3781 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3782 tmp = _PyObject_GetAttrId(obj, &PyId_returns); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3783 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3784 res = obj2ast_expr(tmp, &returns, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3785 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3786 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3787 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3788 returns = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
3789 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3790 *out = FunctionDef(name, args, body, decorator_list, returns, lineno, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3791 col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3792 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3793 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3794 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3795 isinstance = PyObject_IsInstance(obj, (PyObject*)ClassDef_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3796 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3797 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3798 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3799 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3800 identifier name; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3801 asdl_seq* bases; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3802 asdl_seq* keywords; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3803 expr_ty starargs; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3804 expr_ty kwargs; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3805 asdl_seq* body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3806 asdl_seq* decorator_list; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3807 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3808 if (_PyObject_HasAttrId(obj, &PyId_name)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3809 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3810 tmp = _PyObject_GetAttrId(obj, &PyId_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3811 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3812 res = obj2ast_identifier(tmp, &name, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3813 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3814 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3815 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3816 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3817 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3818 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3819 if (_PyObject_HasAttrId(obj, &PyId_bases)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3820 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3821 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3822 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3823 tmp = _PyObject_GetAttrId(obj, &PyId_bases); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3824 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3825 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3826 PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3827 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3828 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3829 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3830 bases = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3831 if (bases == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3832 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3833 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3834 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3835 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3836 asdl_seq_SET(bases, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3837 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3838 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3839 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3840 PyErr_SetString(PyExc_TypeError, "required field \"bases\" missing from ClassDef"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3841 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3842 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3843 if (_PyObject_HasAttrId(obj, &PyId_keywords)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3844 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3845 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3846 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3847 tmp = _PyObject_GetAttrId(obj, &PyId_keywords); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3848 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3849 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3850 PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3851 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3852 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3853 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3854 keywords = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3855 if (keywords == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3856 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3857 keyword_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3858 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3859 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3860 asdl_seq_SET(keywords, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3861 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3862 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3863 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3864 PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from ClassDef"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3865 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3866 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3867 if (_PyObject_HasAttrId(obj, &PyId_starargs)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3868 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3869 tmp = _PyObject_GetAttrId(obj, &PyId_starargs); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3870 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3871 res = obj2ast_expr(tmp, &starargs, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3872 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3873 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3874 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3875 starargs = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3876 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3877 if (_PyObject_HasAttrId(obj, &PyId_kwargs)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3878 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3879 tmp = _PyObject_GetAttrId(obj, &PyId_kwargs); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3880 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3881 res = obj2ast_expr(tmp, &kwargs, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3882 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3883 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3884 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3885 kwargs = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3886 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3887 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3888 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3889 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3890 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3891 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3892 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3893 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3894 PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3895 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3896 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3897 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3898 body = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3899 if (body == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3900 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3901 stmt_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3902 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3903 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3904 asdl_seq_SET(body, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3905 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3906 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3907 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3908 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ClassDef"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3909 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3910 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3911 if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3912 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3913 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3914 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3915 tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3916 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3917 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3918 PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3919 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3920 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3921 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3922 decorator_list = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3923 if (decorator_list == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3924 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3925 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3926 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3927 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3928 asdl_seq_SET(decorator_list, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3929 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3930 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3931 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3932 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from ClassDef"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3933 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
3934 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3935 *out = ClassDef(name, bases, keywords, starargs, kwargs, body, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3936 decorator_list, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3937 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3938 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3939 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3940 isinstance = PyObject_IsInstance(obj, (PyObject*)Return_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3941 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3942 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3943 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3944 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3945 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3946 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3947 if (_PyObject_HasAttrId(obj, &PyId_value)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3948 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3949 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3950 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3951 res = obj2ast_expr(tmp, &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3952 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3953 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3954 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3955 value = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3956 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3957 *out = Return(value, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3958 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3959 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3960 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3961 isinstance = PyObject_IsInstance(obj, (PyObject*)Delete_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3962 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3963 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3964 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3965 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3966 asdl_seq* targets; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3967 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3968 if (_PyObject_HasAttrId(obj, &PyId_targets)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3969 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3970 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3971 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3972 tmp = _PyObject_GetAttrId(obj, &PyId_targets); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3973 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3974 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3975 PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3976 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3977 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3978 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3979 targets = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3980 if (targets == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3981 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3982 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3983 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3984 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3985 asdl_seq_SET(targets, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3986 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3987 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3988 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3989 PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Delete"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3990 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3991 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3992 *out = Delete(targets, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3993 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3994 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3995 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3996 isinstance = PyObject_IsInstance(obj, (PyObject*)Assign_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3997 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3998 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3999 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4000 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4001 asdl_seq* targets; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4002 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4003 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4004 if (_PyObject_HasAttrId(obj, &PyId_targets)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4005 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4006 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4007 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4008 tmp = _PyObject_GetAttrId(obj, &PyId_targets); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4009 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4010 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4011 PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4012 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4013 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4014 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4015 targets = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4016 if (targets == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4017 for (i = 0; i < len; i++) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4018 expr_ty value; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4019 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4020 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4021 asdl_seq_SET(targets, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4022 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4023 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4024 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4025 PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Assign"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4026 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4027 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4028 if (_PyObject_HasAttrId(obj, &PyId_value)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4029 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4030 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4031 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4032 res = obj2ast_expr(tmp, &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4033 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4034 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4035 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4036 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4037 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4038 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4039 *out = Assign(targets, value, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4040 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4041 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4042 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4043 isinstance = PyObject_IsInstance(obj, (PyObject*)AugAssign_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4044 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4045 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4046 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4047 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4048 expr_ty target; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4049 operator_ty op; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4050 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4051 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4052 if (_PyObject_HasAttrId(obj, &PyId_target)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4053 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4054 tmp = _PyObject_GetAttrId(obj, &PyId_target); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4055 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4056 res = obj2ast_expr(tmp, &target, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4057 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4058 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4059 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4060 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4061 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4062 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4063 if (_PyObject_HasAttrId(obj, &PyId_op)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4064 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4065 tmp = _PyObject_GetAttrId(obj, &PyId_op); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4066 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4067 res = obj2ast_operator(tmp, &op, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4068 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4069 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4070 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4071 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4072 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4073 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4074 if (_PyObject_HasAttrId(obj, &PyId_value)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4075 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4076 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4077 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4078 res = obj2ast_expr(tmp, &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4079 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4080 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4081 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4082 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4083 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4084 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4085 *out = AugAssign(target, op, value, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4086 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4087 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4088 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4089 isinstance = PyObject_IsInstance(obj, (PyObject*)For_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4090 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4091 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4092 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4093 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4094 expr_ty target; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4095 expr_ty iter; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4096 asdl_seq* body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4097 asdl_seq* orelse; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4098 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4099 if (_PyObject_HasAttrId(obj, &PyId_target)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4100 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4101 tmp = _PyObject_GetAttrId(obj, &PyId_target); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4102 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4103 res = obj2ast_expr(tmp, &target, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4104 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4105 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4106 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4107 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4108 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4109 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4110 if (_PyObject_HasAttrId(obj, &PyId_iter)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4111 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4112 tmp = _PyObject_GetAttrId(obj, &PyId_iter); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4113 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4114 res = obj2ast_expr(tmp, &iter, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4115 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4116 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4117 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4118 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4119 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4120 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4121 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4122 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4123 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4124 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4125 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4126 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4127 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4128 PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4129 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4130 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4131 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4132 body = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4133 if (body == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4134 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4135 stmt_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4136 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4137 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4138 asdl_seq_SET(body, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4139 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4140 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4141 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4142 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from For"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4143 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4144 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4145 if (_PyObject_HasAttrId(obj, &PyId_orelse)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4146 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4147 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4148 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4149 tmp = _PyObject_GetAttrId(obj, &PyId_orelse); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4150 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4151 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4152 PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4153 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4154 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4155 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4156 orelse = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4157 if (orelse == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4158 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4159 stmt_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4160 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4161 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4162 asdl_seq_SET(orelse, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4163 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4164 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4165 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4166 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from For"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4167 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4168 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4169 *out = For(target, iter, body, orelse, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4170 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4171 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4172 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4173 isinstance = PyObject_IsInstance(obj, (PyObject*)While_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4174 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4175 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4176 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4177 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4178 expr_ty test; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4179 asdl_seq* body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4180 asdl_seq* orelse; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4181 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4182 if (_PyObject_HasAttrId(obj, &PyId_test)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4183 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4184 tmp = _PyObject_GetAttrId(obj, &PyId_test); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4185 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4186 res = obj2ast_expr(tmp, &test, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4187 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4188 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4189 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4190 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4191 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4192 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4193 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4194 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4195 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4196 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4197 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4198 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4199 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4200 PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4201 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4202 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4203 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4204 body = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4205 if (body == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4206 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4207 stmt_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4208 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4209 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4210 asdl_seq_SET(body, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4211 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4212 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4213 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4214 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from While"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4215 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4216 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4217 if (_PyObject_HasAttrId(obj, &PyId_orelse)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4218 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4219 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4220 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4221 tmp = _PyObject_GetAttrId(obj, &PyId_orelse); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4222 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4223 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4224 PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4225 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4226 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4227 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4228 orelse = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4229 if (orelse == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4230 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4231 stmt_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4232 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4233 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4234 asdl_seq_SET(orelse, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4235 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4236 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4237 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4238 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from While"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4239 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4240 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4241 *out = While(test, body, orelse, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4242 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4243 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4244 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4245 isinstance = PyObject_IsInstance(obj, (PyObject*)If_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4246 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4247 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4248 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4249 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4250 expr_ty test; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4251 asdl_seq* body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4252 asdl_seq* orelse; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4253 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4254 if (_PyObject_HasAttrId(obj, &PyId_test)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4255 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4256 tmp = _PyObject_GetAttrId(obj, &PyId_test); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4257 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4258 res = obj2ast_expr(tmp, &test, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4259 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4260 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4261 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4262 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4263 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4264 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4265 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4266 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4267 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4268 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4269 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4270 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4271 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4272 PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4273 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4274 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4275 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4276 body = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4277 if (body == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4278 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4279 stmt_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4280 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4281 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4282 asdl_seq_SET(body, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4283 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4284 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4285 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4286 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from If"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4287 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4288 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4289 if (_PyObject_HasAttrId(obj, &PyId_orelse)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4290 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4291 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4292 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4293 tmp = _PyObject_GetAttrId(obj, &PyId_orelse); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4294 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4295 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4296 PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4297 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4298 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4299 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4300 orelse = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4301 if (orelse == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4302 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4303 stmt_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4304 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4305 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4306 asdl_seq_SET(orelse, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4307 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4308 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4309 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4310 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from If"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4311 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4312 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4313 *out = If(test, body, orelse, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4314 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4315 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4316 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4317 isinstance = PyObject_IsInstance(obj, (PyObject*)With_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4318 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4319 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4320 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4321 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4322 asdl_seq* items; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4323 asdl_seq* body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4324 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4325 if (_PyObject_HasAttrId(obj, &PyId_items)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4326 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4327 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4328 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4329 tmp = _PyObject_GetAttrId(obj, &PyId_items); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4330 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4331 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4332 PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4333 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4334 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4335 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4336 items = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4337 if (items == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4338 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4339 withitem_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4340 res = obj2ast_withitem(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4341 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4342 asdl_seq_SET(items, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4343 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4344 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4345 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4346 PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from With"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4347 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4348 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4349 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4350 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4351 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4352 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4353 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4354 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4355 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4356 PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4357 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4358 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4359 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4360 body = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4361 if (body == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4362 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4363 stmt_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4364 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4365 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4366 asdl_seq_SET(body, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4367 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4368 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4369 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4370 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from With"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4371 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4372 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4373 *out = With(items, body, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4374 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4375 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4376 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4377 isinstance = PyObject_IsInstance(obj, (PyObject*)Raise_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4378 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4379 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4380 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4381 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4382 expr_ty exc; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4383 expr_ty cause; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4384 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4385 if (_PyObject_HasAttrId(obj, &PyId_exc)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4386 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4387 tmp = _PyObject_GetAttrId(obj, &PyId_exc); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4388 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4389 res = obj2ast_expr(tmp, &exc, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4390 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4391 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4392 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4393 exc = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4394 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4395 if (_PyObject_HasAttrId(obj, &PyId_cause)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4396 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4397 tmp = _PyObject_GetAttrId(obj, &PyId_cause); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4398 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4399 res = obj2ast_expr(tmp, &cause, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4400 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4401 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4402 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4403 cause = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4404 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4405 *out = Raise(exc, cause, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4406 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4407 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4408 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4409 isinstance = PyObject_IsInstance(obj, (PyObject*)Try_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4410 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4411 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4412 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4413 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4414 asdl_seq* body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4415 asdl_seq* handlers; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4416 asdl_seq* orelse; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4417 asdl_seq* finalbody; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4418 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4419 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4420 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4421 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4422 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4423 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4424 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4425 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4426 PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4427 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4428 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4429 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4430 body = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4431 if (body == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4432 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4433 stmt_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4434 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4435 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4436 asdl_seq_SET(body, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4437 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4438 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4439 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4440 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Try"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4441 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4442 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4443 if (_PyObject_HasAttrId(obj, &PyId_handlers)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4444 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4445 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4446 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4447 tmp = _PyObject_GetAttrId(obj, &PyId_handlers); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4448 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4449 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4450 PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4451 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4452 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4453 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4454 handlers = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4455 if (handlers == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4456 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4457 excepthandler_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4458 res = obj2ast_excepthandler(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4459 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4460 asdl_seq_SET(handlers, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4461 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4462 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4463 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4464 PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from Try"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4465 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4466 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4467 if (_PyObject_HasAttrId(obj, &PyId_orelse)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4468 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4469 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4470 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4471 tmp = _PyObject_GetAttrId(obj, &PyId_orelse); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4472 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4473 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4474 PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4475 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4476 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4477 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4478 orelse = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4479 if (orelse == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4480 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4481 stmt_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4482 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4483 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4484 asdl_seq_SET(orelse, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4485 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4486 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4487 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4488 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from Try"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4489 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4490 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4491 if (_PyObject_HasAttrId(obj, &PyId_finalbody)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4492 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4493 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4494 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4495 tmp = _PyObject_GetAttrId(obj, &PyId_finalbody); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4496 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4497 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4498 PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4499 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4500 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4501 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4502 finalbody = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4503 if (finalbody == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4504 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4505 stmt_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4506 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4507 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4508 asdl_seq_SET(finalbody, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4509 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4510 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4511 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4512 PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from Try"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4513 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4514 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4515 *out = Try(body, handlers, orelse, finalbody, lineno, col_offset, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4516 arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4517 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4518 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4519 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4520 isinstance = PyObject_IsInstance(obj, (PyObject*)Assert_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4521 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4522 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4523 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4524 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4525 expr_ty test; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4526 expr_ty msg; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4527 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4528 if (_PyObject_HasAttrId(obj, &PyId_test)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4529 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4530 tmp = _PyObject_GetAttrId(obj, &PyId_test); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4531 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4532 res = obj2ast_expr(tmp, &test, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4533 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4534 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4535 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4536 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4537 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4538 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4539 if (_PyObject_HasAttrId(obj, &PyId_msg)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4540 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4541 tmp = _PyObject_GetAttrId(obj, &PyId_msg); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4542 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4543 res = obj2ast_expr(tmp, &msg, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4544 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4545 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4546 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4547 msg = NULL; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4548 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4549 *out = Assert(test, msg, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4550 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4551 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4552 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4553 isinstance = PyObject_IsInstance(obj, (PyObject*)Import_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4554 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4555 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4556 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4557 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4558 asdl_seq* names; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4559 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4560 if (_PyObject_HasAttrId(obj, &PyId_names)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4561 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4562 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4563 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4564 tmp = _PyObject_GetAttrId(obj, &PyId_names); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4565 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4566 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4567 PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4568 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4569 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4570 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4571 names = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4572 if (names == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4573 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4574 alias_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4575 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4576 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4577 asdl_seq_SET(names, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4578 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4579 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4580 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4581 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Import"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4582 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4583 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4584 *out = Import(names, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4585 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4586 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4587 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4588 isinstance = PyObject_IsInstance(obj, (PyObject*)ImportFrom_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4589 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4590 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4591 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4592 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4593 identifier module; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4594 asdl_seq* names; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4595 int level; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4596 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4597 if (_PyObject_HasAttrId(obj, &PyId_module)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4598 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4599 tmp = _PyObject_GetAttrId(obj, &PyId_module); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4600 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4601 res = obj2ast_identifier(tmp, &module, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4602 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4603 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4604 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4605 module = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4606 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4607 if (_PyObject_HasAttrId(obj, &PyId_names)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4608 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4609 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4610 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4611 tmp = _PyObject_GetAttrId(obj, &PyId_names); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4612 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4613 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4614 PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4615 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4616 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4617 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4618 names = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4619 if (names == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4620 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4621 alias_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4622 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4623 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4624 asdl_seq_SET(names, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4625 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4626 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4627 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4628 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from ImportFrom"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4629 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4630 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4631 if (_PyObject_HasAttrId(obj, &PyId_level)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4632 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4633 tmp = _PyObject_GetAttrId(obj, &PyId_level); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4634 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4635 res = obj2ast_int(tmp, &level, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4636 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4637 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4638 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4639 level = 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4640 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4641 *out = ImportFrom(module, names, level, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4642 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4643 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4644 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4645 isinstance = PyObject_IsInstance(obj, (PyObject*)Global_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4646 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4647 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4648 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4649 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4650 asdl_seq* names; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4651 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4652 if (_PyObject_HasAttrId(obj, &PyId_names)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4653 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4654 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4655 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4656 tmp = _PyObject_GetAttrId(obj, &PyId_names); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4657 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4658 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4659 PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4660 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4661 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4662 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4663 names = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4664 if (names == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4665 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4666 identifier value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4667 res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4668 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4669 asdl_seq_SET(names, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4670 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4671 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4672 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4673 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Global"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4674 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4675 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4676 *out = Global(names, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4677 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4678 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4679 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4680 isinstance = PyObject_IsInstance(obj, (PyObject*)Nonlocal_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4681 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4682 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4683 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4684 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4685 asdl_seq* names; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4686 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4687 if (_PyObject_HasAttrId(obj, &PyId_names)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4688 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4689 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4690 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4691 tmp = _PyObject_GetAttrId(obj, &PyId_names); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4692 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4693 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4694 PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4695 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4696 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4697 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4698 names = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4699 if (names == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4700 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4701 identifier value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4702 res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4703 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4704 asdl_seq_SET(names, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4705 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4706 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4707 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4708 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Nonlocal"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4709 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4710 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4711 *out = Nonlocal(names, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4712 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4713 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4714 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4715 isinstance = PyObject_IsInstance(obj, (PyObject*)Expr_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4716 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4717 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4718 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4719 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4720 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4721 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4722 if (_PyObject_HasAttrId(obj, &PyId_value)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4723 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4724 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4725 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4726 res = obj2ast_expr(tmp, &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4727 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4728 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4729 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4730 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4731 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4732 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4733 *out = Expr(value, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4734 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4735 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4736 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4737 isinstance = PyObject_IsInstance(obj, (PyObject*)Pass_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4738 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4739 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4740 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4741 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4742 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4743 *out = Pass(lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4744 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4745 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4746 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4747 isinstance = PyObject_IsInstance(obj, (PyObject*)Break_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4748 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4749 return 1; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4750 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4751 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4752 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4753 *out = Break(lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4754 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4755 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4756 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4757 isinstance = PyObject_IsInstance(obj, (PyObject*)Continue_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4758 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4759 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4760 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4761 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4762 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4763 *out = Continue(lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4764 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4765 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4766 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4767 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4768 PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4769 failed: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4770 Py_XDECREF(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4771 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4772 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4773 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4774 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4775 obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4776 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4777 int isinstance; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4778 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4779 PyObject *tmp = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4780 int lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4781 int col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4782 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4783 if (obj == Py_None) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4784 *out = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4785 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4786 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4787 if (_PyObject_HasAttrId(obj, &PyId_lineno)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4788 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4789 tmp = _PyObject_GetAttrId(obj, &PyId_lineno); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4790 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4791 res = obj2ast_int(tmp, &lineno, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4792 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4793 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4794 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4795 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4796 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4797 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4798 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4799 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4800 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4801 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4802 res = obj2ast_int(tmp, &col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4803 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4804 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4805 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4806 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4807 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4808 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4809 isinstance = PyObject_IsInstance(obj, (PyObject*)BoolOp_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4810 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4811 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4812 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4813 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4814 boolop_ty op; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4815 asdl_seq* values; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4816 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4817 if (_PyObject_HasAttrId(obj, &PyId_op)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4818 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4819 tmp = _PyObject_GetAttrId(obj, &PyId_op); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4820 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4821 res = obj2ast_boolop(tmp, &op, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4822 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4823 Py_CLEAR(tmp); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4824 } else { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4825 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4826 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4827 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4828 if (_PyObject_HasAttrId(obj, &PyId_values)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4829 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4830 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4831 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4832 tmp = _PyObject_GetAttrId(obj, &PyId_values); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4833 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4834 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4835 PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4836 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4837 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4838 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4839 values = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4840 if (values == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4841 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4842 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4843 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4844 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4845 asdl_seq_SET(values, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4846 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4847 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4848 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4849 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from BoolOp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4850 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4851 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4852 *out = BoolOp(op, values, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4853 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4854 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4855 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4856 isinstance = PyObject_IsInstance(obj, (PyObject*)BinOp_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4857 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4858 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4859 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4860 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4861 expr_ty left; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4862 operator_ty op; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4863 expr_ty right; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4864 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4865 if (_PyObject_HasAttrId(obj, &PyId_left)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4866 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4867 tmp = _PyObject_GetAttrId(obj, &PyId_left); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4868 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4869 res = obj2ast_expr(tmp, &left, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4870 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4871 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4872 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4873 PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4874 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4875 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4876 if (_PyObject_HasAttrId(obj, &PyId_op)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4877 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4878 tmp = _PyObject_GetAttrId(obj, &PyId_op); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4879 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4880 res = obj2ast_operator(tmp, &op, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4881 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4882 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4883 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4884 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4885 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4886 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4887 if (_PyObject_HasAttrId(obj, &PyId_right)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4888 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4889 tmp = _PyObject_GetAttrId(obj, &PyId_right); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4890 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4891 res = obj2ast_expr(tmp, &right, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4892 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4893 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4894 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4895 PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4896 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4897 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4898 *out = BinOp(left, op, right, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4899 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4900 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4901 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4902 isinstance = PyObject_IsInstance(obj, (PyObject*)UnaryOp_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4903 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4904 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4905 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4906 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4907 unaryop_ty op; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4908 expr_ty operand; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4909 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4910 if (_PyObject_HasAttrId(obj, &PyId_op)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4911 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4912 tmp = _PyObject_GetAttrId(obj, &PyId_op); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4913 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4914 res = obj2ast_unaryop(tmp, &op, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4915 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4916 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4917 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4918 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4919 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4920 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4921 if (_PyObject_HasAttrId(obj, &PyId_operand)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4922 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4923 tmp = _PyObject_GetAttrId(obj, &PyId_operand); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4924 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4925 res = obj2ast_expr(tmp, &operand, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4926 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4927 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4928 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4929 PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4930 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4931 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4932 *out = UnaryOp(op, operand, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4933 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4934 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4935 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4936 isinstance = PyObject_IsInstance(obj, (PyObject*)Lambda_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4937 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4938 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4939 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4940 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4941 arguments_ty args; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4942 expr_ty body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4943 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4944 if (_PyObject_HasAttrId(obj, &PyId_args)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4945 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4946 tmp = _PyObject_GetAttrId(obj, &PyId_args); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4947 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4948 res = obj2ast_arguments(tmp, &args, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4949 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4950 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4951 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4952 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4953 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4954 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4955 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4956 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4957 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4958 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4959 res = obj2ast_expr(tmp, &body, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4960 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4961 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4962 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4963 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4964 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4965 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4966 *out = Lambda(args, body, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4967 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4968 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4969 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4970 isinstance = PyObject_IsInstance(obj, (PyObject*)IfExp_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4971 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4972 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4973 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4974 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4975 expr_ty test; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4976 expr_ty body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4977 expr_ty orelse; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4978 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4979 if (_PyObject_HasAttrId(obj, &PyId_test)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4980 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4981 tmp = _PyObject_GetAttrId(obj, &PyId_test); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4982 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4983 res = obj2ast_expr(tmp, &test, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4984 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4985 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4986 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4987 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4988 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4989 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4990 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4991 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4992 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4993 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4994 res = obj2ast_expr(tmp, &body, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4995 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4996 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4997 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4998 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4999 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5000 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5001 if (_PyObject_HasAttrId(obj, &PyId_orelse)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5002 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5003 tmp = _PyObject_GetAttrId(obj, &PyId_orelse); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5004 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5005 res = obj2ast_expr(tmp, &orelse, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5006 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5007 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5008 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5009 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5010 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5011 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5012 *out = IfExp(test, body, orelse, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5013 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5014 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5015 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5016 isinstance = PyObject_IsInstance(obj, (PyObject*)Dict_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5017 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5018 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5019 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5020 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5021 asdl_seq* keys; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5022 asdl_seq* values; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5023 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5024 if (_PyObject_HasAttrId(obj, &PyId_keys)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5025 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5026 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5027 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5028 tmp = _PyObject_GetAttrId(obj, &PyId_keys); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5029 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5030 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5031 PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5032 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5033 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5034 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5035 keys = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5036 if (keys == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5037 for (i = 0; i < len; i++) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5038 expr_ty value; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5039 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5040 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5041 asdl_seq_SET(keys, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5042 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5043 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5044 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5045 PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from Dict"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5046 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5047 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5048 if (_PyObject_HasAttrId(obj, &PyId_values)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5049 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5050 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5051 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5052 tmp = _PyObject_GetAttrId(obj, &PyId_values); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5053 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5054 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5055 PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5056 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5057 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5058 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5059 values = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5060 if (values == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5061 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5062 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5063 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5064 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5065 asdl_seq_SET(values, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5066 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5067 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5068 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5069 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Dict"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5070 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5071 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5072 *out = Dict(keys, values, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5073 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5074 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5075 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5076 isinstance = PyObject_IsInstance(obj, (PyObject*)Set_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5077 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5078 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5079 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5080 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5081 asdl_seq* elts; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5082 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5083 if (_PyObject_HasAttrId(obj, &PyId_elts)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5084 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5085 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5086 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5087 tmp = _PyObject_GetAttrId(obj, &PyId_elts); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5088 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5089 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5090 PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5091 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5092 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5093 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5094 elts = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5095 if (elts == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5096 for (i = 0; i < len; i++) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5097 expr_ty value; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5098 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5099 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5100 asdl_seq_SET(elts, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5101 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5102 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5103 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5104 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Set"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5105 return 1; |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
5106 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5107 *out = Set(elts, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5108 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5109 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5110 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5111 isinstance = PyObject_IsInstance(obj, (PyObject*)ListComp_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5112 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5113 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5114 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5115 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5116 expr_ty elt; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5117 asdl_seq* generators; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5118 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5119 if (_PyObject_HasAttrId(obj, &PyId_elt)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5120 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5121 tmp = _PyObject_GetAttrId(obj, &PyId_elt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5122 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5123 res = obj2ast_expr(tmp, &elt, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5124 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5125 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5126 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5127 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5128 return 1; |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
5129 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5130 if (_PyObject_HasAttrId(obj, &PyId_generators)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5131 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5132 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5133 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5134 tmp = _PyObject_GetAttrId(obj, &PyId_generators); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5135 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5136 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5137 PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5138 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5139 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5140 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5141 generators = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5142 if (generators == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5143 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5144 comprehension_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5145 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5146 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5147 asdl_seq_SET(generators, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5148 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5149 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5150 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5151 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from ListComp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5152 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5153 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5154 *out = ListComp(elt, generators, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5155 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5156 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5157 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5158 isinstance = PyObject_IsInstance(obj, (PyObject*)SetComp_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5159 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5160 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5161 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5162 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5163 expr_ty elt; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5164 asdl_seq* generators; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5165 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5166 if (_PyObject_HasAttrId(obj, &PyId_elt)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5167 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5168 tmp = _PyObject_GetAttrId(obj, &PyId_elt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5169 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5170 res = obj2ast_expr(tmp, &elt, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5171 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5172 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5173 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5174 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5175 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5176 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5177 if (_PyObject_HasAttrId(obj, &PyId_generators)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5178 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5179 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5180 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5181 tmp = _PyObject_GetAttrId(obj, &PyId_generators); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5182 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5183 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5184 PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5185 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5186 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5187 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5188 generators = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5189 if (generators == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5190 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5191 comprehension_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5192 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5193 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5194 asdl_seq_SET(generators, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5195 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5196 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5197 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5198 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from SetComp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5199 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5200 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5201 *out = SetComp(elt, generators, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5202 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5203 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5204 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5205 isinstance = PyObject_IsInstance(obj, (PyObject*)DictComp_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5206 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5207 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5208 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5209 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5210 expr_ty key; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5211 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5212 asdl_seq* generators; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5213 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5214 if (_PyObject_HasAttrId(obj, &PyId_key)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5215 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5216 tmp = _PyObject_GetAttrId(obj, &PyId_key); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5217 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5218 res = obj2ast_expr(tmp, &key, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5219 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5220 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5221 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5222 PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5223 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5224 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5225 if (_PyObject_HasAttrId(obj, &PyId_value)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5226 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5227 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5228 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5229 res = obj2ast_expr(tmp, &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5230 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5231 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5232 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5233 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from DictComp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5234 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5235 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5236 if (_PyObject_HasAttrId(obj, &PyId_generators)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5237 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5238 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5239 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5240 tmp = _PyObject_GetAttrId(obj, &PyId_generators); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5241 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5242 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5243 PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5244 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5245 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5246 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5247 generators = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5248 if (generators == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5249 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5250 comprehension_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5251 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5252 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5253 asdl_seq_SET(generators, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5254 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5255 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5256 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5257 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from DictComp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5258 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5259 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5260 *out = DictComp(key, value, generators, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5261 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5262 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5263 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5264 isinstance = PyObject_IsInstance(obj, (PyObject*)GeneratorExp_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5265 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5266 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5267 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5268 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5269 expr_ty elt; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5270 asdl_seq* generators; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5271 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5272 if (_PyObject_HasAttrId(obj, &PyId_elt)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5273 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5274 tmp = _PyObject_GetAttrId(obj, &PyId_elt); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5275 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5276 res = obj2ast_expr(tmp, &elt, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5277 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5278 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5279 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5280 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5281 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5282 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5283 if (_PyObject_HasAttrId(obj, &PyId_generators)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5284 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5285 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5286 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5287 tmp = _PyObject_GetAttrId(obj, &PyId_generators); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5288 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5289 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5290 PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5291 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5292 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5293 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5294 generators = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5295 if (generators == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5296 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5297 comprehension_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5298 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5299 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5300 asdl_seq_SET(generators, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5301 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5302 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5303 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5304 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from GeneratorExp"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5305 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5306 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5307 *out = GeneratorExp(elt, generators, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5308 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5309 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5310 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5311 isinstance = PyObject_IsInstance(obj, (PyObject*)Yield_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5312 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5313 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5314 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5315 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5316 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5317 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5318 if (_PyObject_HasAttrId(obj, &PyId_value)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5319 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5320 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5321 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5322 res = obj2ast_expr(tmp, &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5323 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5324 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5325 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5326 value = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5327 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5328 *out = Yield(value, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5329 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5330 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5331 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5332 isinstance = PyObject_IsInstance(obj, (PyObject*)YieldFrom_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5333 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5334 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5335 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5336 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5337 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5338 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5339 if (_PyObject_HasAttrId(obj, &PyId_value)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5340 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5341 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5342 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5343 res = obj2ast_expr(tmp, &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5344 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5345 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5346 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5347 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5348 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5349 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5350 *out = YieldFrom(value, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5351 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5352 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5353 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5354 isinstance = PyObject_IsInstance(obj, (PyObject*)Compare_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5355 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5356 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5357 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5358 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5359 expr_ty left; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5360 asdl_int_seq* ops; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5361 asdl_seq* comparators; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5362 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5363 if (_PyObject_HasAttrId(obj, &PyId_left)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5364 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5365 tmp = _PyObject_GetAttrId(obj, &PyId_left); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5366 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5367 res = obj2ast_expr(tmp, &left, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5368 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5369 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5370 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5371 PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5372 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5373 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5374 if (_PyObject_HasAttrId(obj, &PyId_ops)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5375 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5376 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5377 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5378 tmp = _PyObject_GetAttrId(obj, &PyId_ops); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5379 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5380 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5381 PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5382 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5383 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5384 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5385 ops = asdl_int_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5386 if (ops == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5387 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5388 cmpop_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5389 res = obj2ast_cmpop(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5390 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5391 asdl_seq_SET(ops, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5392 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5393 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5394 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5395 PyErr_SetString(PyExc_TypeError, "required field \"ops\" missing from Compare"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5396 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5397 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5398 if (_PyObject_HasAttrId(obj, &PyId_comparators)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5399 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5400 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5401 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5402 tmp = _PyObject_GetAttrId(obj, &PyId_comparators); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5403 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5404 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5405 PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5406 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5407 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5408 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5409 comparators = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5410 if (comparators == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5411 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5412 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5413 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5414 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5415 asdl_seq_SET(comparators, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5416 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5417 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5418 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5419 PyErr_SetString(PyExc_TypeError, "required field \"comparators\" missing from Compare"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5420 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5421 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5422 *out = Compare(left, ops, comparators, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5423 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5424 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5425 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5426 isinstance = PyObject_IsInstance(obj, (PyObject*)Call_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5427 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5428 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5429 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5430 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5431 expr_ty func; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5432 asdl_seq* args; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5433 asdl_seq* keywords; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5434 expr_ty starargs; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5435 expr_ty kwargs; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5436 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5437 if (_PyObject_HasAttrId(obj, &PyId_func)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5438 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5439 tmp = _PyObject_GetAttrId(obj, &PyId_func); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5440 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5441 res = obj2ast_expr(tmp, &func, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5442 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5443 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5444 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5445 PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5446 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5447 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5448 if (_PyObject_HasAttrId(obj, &PyId_args)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5449 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5450 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5451 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5452 tmp = _PyObject_GetAttrId(obj, &PyId_args); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5453 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5454 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5455 PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5456 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5457 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5458 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5459 args = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5460 if (args == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5461 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5462 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5463 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5464 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5465 asdl_seq_SET(args, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5466 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5467 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5468 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5469 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Call"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5470 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5471 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5472 if (_PyObject_HasAttrId(obj, &PyId_keywords)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5473 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5474 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5475 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5476 tmp = _PyObject_GetAttrId(obj, &PyId_keywords); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5477 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5478 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5479 PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5480 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5481 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5482 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5483 keywords = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5484 if (keywords == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5485 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5486 keyword_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5487 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5488 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5489 asdl_seq_SET(keywords, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5490 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5491 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5492 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5493 PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from Call"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5494 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5495 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5496 if (_PyObject_HasAttrId(obj, &PyId_starargs)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5497 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5498 tmp = _PyObject_GetAttrId(obj, &PyId_starargs); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5499 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5500 res = obj2ast_expr(tmp, &starargs, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5501 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5502 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5503 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5504 starargs = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5505 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5506 if (_PyObject_HasAttrId(obj, &PyId_kwargs)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5507 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5508 tmp = _PyObject_GetAttrId(obj, &PyId_kwargs); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5509 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5510 res = obj2ast_expr(tmp, &kwargs, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5511 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5512 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5513 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5514 kwargs = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5515 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5516 *out = Call(func, args, keywords, starargs, kwargs, lineno, col_offset, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5517 arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5518 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5519 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5520 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5521 isinstance = PyObject_IsInstance(obj, (PyObject*)Num_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5522 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5523 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5524 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5525 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5526 object n; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5527 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5528 if (_PyObject_HasAttrId(obj, &PyId_n)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5529 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5530 tmp = _PyObject_GetAttrId(obj, &PyId_n); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5531 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5532 res = obj2ast_object(tmp, &n, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5533 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5534 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5535 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5536 PyErr_SetString(PyExc_TypeError, "required field \"n\" missing from Num"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5537 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5538 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5539 *out = Num(n, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5540 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5541 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5542 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5543 isinstance = PyObject_IsInstance(obj, (PyObject*)Str_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5544 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5545 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5546 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5547 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5548 string s; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5549 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5550 if (_PyObject_HasAttrId(obj, &PyId_s)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5551 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5552 tmp = _PyObject_GetAttrId(obj, &PyId_s); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5553 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5554 res = obj2ast_string(tmp, &s, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5555 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5556 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5557 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5558 PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Str"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5559 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5560 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5561 *out = Str(s, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5562 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5563 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5564 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5565 isinstance = PyObject_IsInstance(obj, (PyObject*)Bytes_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5566 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5567 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5568 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5569 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5570 bytes s; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5571 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5572 if (_PyObject_HasAttrId(obj, &PyId_s)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5573 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5574 tmp = _PyObject_GetAttrId(obj, &PyId_s); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5575 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5576 res = obj2ast_bytes(tmp, &s, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5577 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5578 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5579 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5580 PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Bytes"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5581 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5582 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5583 *out = Bytes(s, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5584 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5585 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5586 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5587 isinstance = PyObject_IsInstance(obj, (PyObject*)Ellipsis_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5588 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5589 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5590 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5591 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5592 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5593 *out = Ellipsis(lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5594 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5595 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5596 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5597 isinstance = PyObject_IsInstance(obj, (PyObject*)Attribute_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5598 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5599 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5600 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5601 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5602 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5603 identifier attr; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5604 expr_context_ty ctx; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5605 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5606 if (_PyObject_HasAttrId(obj, &PyId_value)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5607 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5608 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5609 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5610 res = obj2ast_expr(tmp, &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5611 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5612 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5613 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5614 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5615 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5616 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5617 if (_PyObject_HasAttrId(obj, &PyId_attr)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5618 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5619 tmp = _PyObject_GetAttrId(obj, &PyId_attr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5620 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5621 res = obj2ast_identifier(tmp, &attr, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5622 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5623 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5624 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5625 PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5626 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5627 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5628 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5629 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5630 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5631 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5632 res = obj2ast_expr_context(tmp, &ctx, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5633 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5634 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5635 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5636 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5637 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5638 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5639 *out = Attribute(value, attr, ctx, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5640 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5641 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5642 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5643 isinstance = PyObject_IsInstance(obj, (PyObject*)Subscript_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5644 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5645 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5646 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5647 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5648 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5649 slice_ty slice; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5650 expr_context_ty ctx; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5651 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5652 if (_PyObject_HasAttrId(obj, &PyId_value)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5653 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5654 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5655 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5656 res = obj2ast_expr(tmp, &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5657 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5658 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5659 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5660 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5661 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5662 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5663 if (_PyObject_HasAttrId(obj, &PyId_slice)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5664 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5665 tmp = _PyObject_GetAttrId(obj, &PyId_slice); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5666 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5667 res = obj2ast_slice(tmp, &slice, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5668 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5669 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5670 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5671 PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5672 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5673 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5674 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5675 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5676 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5677 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5678 res = obj2ast_expr_context(tmp, &ctx, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5679 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5680 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5681 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5682 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5683 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5684 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5685 *out = Subscript(value, slice, ctx, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5686 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5687 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5688 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5689 isinstance = PyObject_IsInstance(obj, (PyObject*)Starred_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5690 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5691 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5692 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5693 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5694 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5695 expr_context_ty ctx; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5696 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5697 if (_PyObject_HasAttrId(obj, &PyId_value)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5698 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5699 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5700 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5701 res = obj2ast_expr(tmp, &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5702 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5703 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5704 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5705 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5706 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5707 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5708 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5709 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5710 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5711 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5712 res = obj2ast_expr_context(tmp, &ctx, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5713 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5714 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5715 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5716 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5717 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5718 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5719 *out = Starred(value, ctx, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5720 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5721 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5722 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5723 isinstance = PyObject_IsInstance(obj, (PyObject*)Name_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5724 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5725 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5726 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5727 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5728 identifier id; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5729 expr_context_ty ctx; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5730 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5731 if (_PyObject_HasAttrId(obj, &PyId_id)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5732 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5733 tmp = _PyObject_GetAttrId(obj, &PyId_id); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5734 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5735 res = obj2ast_identifier(tmp, &id, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5736 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5737 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5738 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5739 PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5740 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5741 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5742 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5743 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5744 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5745 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5746 res = obj2ast_expr_context(tmp, &ctx, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5747 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5748 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5749 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5750 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5751 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5752 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5753 *out = Name(id, ctx, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5754 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5755 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5756 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5757 isinstance = PyObject_IsInstance(obj, (PyObject*)List_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5758 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5759 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5760 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5761 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5762 asdl_seq* elts; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5763 expr_context_ty ctx; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5764 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5765 if (_PyObject_HasAttrId(obj, &PyId_elts)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5766 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5767 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5768 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5769 tmp = _PyObject_GetAttrId(obj, &PyId_elts); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5770 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5771 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5772 PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5773 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5774 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5775 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5776 elts = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5777 if (elts == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5778 for (i = 0; i < len; i++) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5779 expr_ty value; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5780 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5781 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5782 asdl_seq_SET(elts, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5783 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5784 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5785 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5786 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from List"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5787 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5788 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5789 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5790 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5791 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5792 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5793 res = obj2ast_expr_context(tmp, &ctx, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5794 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5795 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5796 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5797 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5798 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5799 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5800 *out = List(elts, ctx, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5801 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5802 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5803 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5804 isinstance = PyObject_IsInstance(obj, (PyObject*)Tuple_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5805 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5806 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5807 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5808 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5809 asdl_seq* elts; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5810 expr_context_ty ctx; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5811 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5812 if (_PyObject_HasAttrId(obj, &PyId_elts)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5813 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5814 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5815 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5816 tmp = _PyObject_GetAttrId(obj, &PyId_elts); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5817 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5818 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5819 PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5820 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5821 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5822 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5823 elts = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5824 if (elts == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5825 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5826 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5827 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5828 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5829 asdl_seq_SET(elts, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5830 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5831 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5832 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5833 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Tuple"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5834 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5835 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5836 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5837 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5838 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5839 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5840 res = obj2ast_expr_context(tmp, &ctx, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5841 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5842 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5843 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5844 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5845 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5846 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5847 *out = Tuple(elts, ctx, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5848 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5849 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5850 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5851 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5852 PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5853 failed: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5854 Py_XDECREF(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5855 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5856 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5857 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5858 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5859 obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5860 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5861 int isinstance; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5862 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5863 isinstance = PyObject_IsInstance(obj, (PyObject *)Load_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5864 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5865 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5866 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5867 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5868 *out = Load; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5869 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5870 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5871 isinstance = PyObject_IsInstance(obj, (PyObject *)Store_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5872 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5873 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5874 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5875 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5876 *out = Store; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5877 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5878 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5879 isinstance = PyObject_IsInstance(obj, (PyObject *)Del_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5880 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5881 return 1; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5882 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5883 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5884 *out = Del; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5885 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5886 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5887 isinstance = PyObject_IsInstance(obj, (PyObject *)AugLoad_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5888 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5889 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5890 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5891 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5892 *out = AugLoad; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5893 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5894 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5895 isinstance = PyObject_IsInstance(obj, (PyObject *)AugStore_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5896 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5897 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5898 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5899 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5900 *out = AugStore; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5901 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5902 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5903 isinstance = PyObject_IsInstance(obj, (PyObject *)Param_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5904 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5905 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5906 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5907 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5908 *out = Param; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5909 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5910 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5911 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5912 PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5913 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5914 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5915 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5916 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5917 obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5918 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5919 int isinstance; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5920 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5921 PyObject *tmp = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5922 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5923 if (obj == Py_None) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5924 *out = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5925 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5926 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5927 isinstance = PyObject_IsInstance(obj, (PyObject*)Slice_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5928 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5929 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5930 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5931 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5932 expr_ty lower; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5933 expr_ty upper; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5934 expr_ty step; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5935 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5936 if (_PyObject_HasAttrId(obj, &PyId_lower)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5937 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5938 tmp = _PyObject_GetAttrId(obj, &PyId_lower); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5939 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5940 res = obj2ast_expr(tmp, &lower, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5941 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5942 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5943 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5944 lower = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5945 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5946 if (_PyObject_HasAttrId(obj, &PyId_upper)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5947 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5948 tmp = _PyObject_GetAttrId(obj, &PyId_upper); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5949 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5950 res = obj2ast_expr(tmp, &upper, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5951 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5952 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5953 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5954 upper = NULL; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5955 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5956 if (_PyObject_HasAttrId(obj, &PyId_step)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5957 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5958 tmp = _PyObject_GetAttrId(obj, &PyId_step); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5959 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5960 res = obj2ast_expr(tmp, &step, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5961 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5962 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5963 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5964 step = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5965 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5966 *out = Slice(lower, upper, step, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5967 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5968 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5969 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5970 isinstance = PyObject_IsInstance(obj, (PyObject*)ExtSlice_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5971 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5972 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5973 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5974 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5975 asdl_seq* dims; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5976 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5977 if (_PyObject_HasAttrId(obj, &PyId_dims)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5978 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5979 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5980 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5981 tmp = _PyObject_GetAttrId(obj, &PyId_dims); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5982 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5983 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5984 PyErr_Format(PyExc_TypeError, "ExtSlice field \"dims\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5985 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5986 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5987 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5988 dims = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5989 if (dims == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5990 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5991 slice_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5992 res = obj2ast_slice(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5993 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5994 asdl_seq_SET(dims, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5995 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5996 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5997 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5998 PyErr_SetString(PyExc_TypeError, "required field \"dims\" missing from ExtSlice"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5999 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6000 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6001 *out = ExtSlice(dims, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6002 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6003 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6004 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6005 isinstance = PyObject_IsInstance(obj, (PyObject*)Index_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6006 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6007 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6008 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6009 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6010 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6011 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6012 if (_PyObject_HasAttrId(obj, &PyId_value)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6013 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6014 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6015 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6016 res = obj2ast_expr(tmp, &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6017 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6018 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6019 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6020 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Index"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6021 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6022 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6023 *out = Index(value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6024 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6025 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6026 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6027 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6028 PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %R", obj); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6029 failed: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6030 Py_XDECREF(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6031 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6032 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6033 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6034 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6035 obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6036 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6037 int isinstance; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6038 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6039 isinstance = PyObject_IsInstance(obj, (PyObject *)And_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6040 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6041 return 1; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6042 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6043 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6044 *out = And; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6045 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6046 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6047 isinstance = PyObject_IsInstance(obj, (PyObject *)Or_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6048 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6049 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6050 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6051 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6052 *out = Or; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6053 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6054 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6055 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6056 PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6057 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6058 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6059 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6060 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6061 obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6062 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6063 int isinstance; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6064 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6065 isinstance = PyObject_IsInstance(obj, (PyObject *)Add_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6066 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6067 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6068 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6069 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6070 *out = Add; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6071 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6072 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6073 isinstance = PyObject_IsInstance(obj, (PyObject *)Sub_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6074 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6075 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6076 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6077 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6078 *out = Sub; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6079 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6080 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6081 isinstance = PyObject_IsInstance(obj, (PyObject *)Mult_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6082 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6083 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6084 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6085 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6086 *out = Mult; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6087 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6088 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6089 isinstance = PyObject_IsInstance(obj, (PyObject *)Div_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6090 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6091 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6092 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6093 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6094 *out = Div; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6095 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6096 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6097 isinstance = PyObject_IsInstance(obj, (PyObject *)Mod_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6098 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6099 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6100 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6101 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6102 *out = Mod; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6103 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6104 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6105 isinstance = PyObject_IsInstance(obj, (PyObject *)Pow_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6106 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6107 return 1; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6108 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6109 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6110 *out = Pow; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6111 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6112 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6113 isinstance = PyObject_IsInstance(obj, (PyObject *)LShift_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6114 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6115 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6116 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6117 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6118 *out = LShift; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6119 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6120 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6121 isinstance = PyObject_IsInstance(obj, (PyObject *)RShift_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6122 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6123 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6124 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6125 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6126 *out = RShift; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6127 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6128 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6129 isinstance = PyObject_IsInstance(obj, (PyObject *)BitOr_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6130 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6131 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6132 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6133 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6134 *out = BitOr; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6135 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6136 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6137 isinstance = PyObject_IsInstance(obj, (PyObject *)BitXor_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6138 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6139 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6140 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6141 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6142 *out = BitXor; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6143 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6144 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6145 isinstance = PyObject_IsInstance(obj, (PyObject *)BitAnd_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6146 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6147 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6148 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6149 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6150 *out = BitAnd; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6151 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6152 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6153 isinstance = PyObject_IsInstance(obj, (PyObject *)FloorDiv_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6154 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6155 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6156 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6157 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6158 *out = FloorDiv; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6159 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6160 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6161 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6162 PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6163 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6164 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6165 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6166 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6167 obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6168 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6169 int isinstance; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6170 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6171 isinstance = PyObject_IsInstance(obj, (PyObject *)Invert_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6172 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6173 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6174 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6175 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6176 *out = Invert; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6177 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6178 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6179 isinstance = PyObject_IsInstance(obj, (PyObject *)Not_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6180 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6181 return 1; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6182 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6183 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6184 *out = Not; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6185 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6186 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6187 isinstance = PyObject_IsInstance(obj, (PyObject *)UAdd_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6188 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6189 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6190 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6191 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6192 *out = UAdd; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6193 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6194 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6195 isinstance = PyObject_IsInstance(obj, (PyObject *)USub_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6196 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6197 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6198 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6199 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6200 *out = USub; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6201 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6202 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6203 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6204 PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6205 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6206 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6207 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6208 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6209 obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6210 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6211 int isinstance; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6212 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6213 isinstance = PyObject_IsInstance(obj, (PyObject *)Eq_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6214 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6215 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6216 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6217 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6218 *out = Eq; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6219 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6220 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6221 isinstance = PyObject_IsInstance(obj, (PyObject *)NotEq_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6222 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6223 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6224 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6225 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6226 *out = NotEq; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6227 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6228 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6229 isinstance = PyObject_IsInstance(obj, (PyObject *)Lt_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6230 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6231 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6232 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6233 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6234 *out = Lt; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6235 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6236 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6237 isinstance = PyObject_IsInstance(obj, (PyObject *)LtE_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6238 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6239 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6240 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6241 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6242 *out = LtE; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6243 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6244 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6245 isinstance = PyObject_IsInstance(obj, (PyObject *)Gt_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6246 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6247 return 1; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6248 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6249 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6250 *out = Gt; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6251 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6252 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6253 isinstance = PyObject_IsInstance(obj, (PyObject *)GtE_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6254 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6255 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6256 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6257 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6258 *out = GtE; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6259 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6260 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6261 isinstance = PyObject_IsInstance(obj, (PyObject *)Is_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6262 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6263 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6264 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6265 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6266 *out = Is; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6267 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6268 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6269 isinstance = PyObject_IsInstance(obj, (PyObject *)IsNot_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6270 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6271 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6272 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6273 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6274 *out = IsNot; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6275 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6276 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6277 isinstance = PyObject_IsInstance(obj, (PyObject *)In_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6278 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6279 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6280 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6281 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6282 *out = In; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6283 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6284 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6285 isinstance = PyObject_IsInstance(obj, (PyObject *)NotIn_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6286 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6287 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6288 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6289 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6290 *out = NotIn; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6291 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6292 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6293 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6294 PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6295 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6296 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6297 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6298 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6299 obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6300 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6301 PyObject* tmp = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6302 expr_ty target; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6303 expr_ty iter; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6304 asdl_seq* ifs; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6305 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6306 if (_PyObject_HasAttrId(obj, &PyId_target)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6307 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6308 tmp = _PyObject_GetAttrId(obj, &PyId_target); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6309 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6310 res = obj2ast_expr(tmp, &target, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6311 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6312 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6313 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6314 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6315 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6316 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6317 if (_PyObject_HasAttrId(obj, &PyId_iter)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6318 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6319 tmp = _PyObject_GetAttrId(obj, &PyId_iter); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6320 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6321 res = obj2ast_expr(tmp, &iter, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6322 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6323 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6324 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6325 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6326 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6327 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6328 if (_PyObject_HasAttrId(obj, &PyId_ifs)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6329 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6330 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6331 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6332 tmp = _PyObject_GetAttrId(obj, &PyId_ifs); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6333 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6334 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6335 PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6336 goto failed; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6337 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6338 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6339 ifs = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6340 if (ifs == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6341 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6342 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6343 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6344 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6345 asdl_seq_SET(ifs, i, value); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6346 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6347 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6348 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6349 PyErr_SetString(PyExc_TypeError, "required field \"ifs\" missing from comprehension"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6350 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6351 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6352 *out = comprehension(target, iter, ifs, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6353 return 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6354 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6355 Py_XDECREF(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6356 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6357 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6358 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6359 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6360 obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6361 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6362 int isinstance; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6363 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6364 PyObject *tmp = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6365 int lineno; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6366 int col_offset; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6367 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6368 if (obj == Py_None) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6369 *out = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6370 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6371 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6372 if (_PyObject_HasAttrId(obj, &PyId_lineno)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6373 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6374 tmp = _PyObject_GetAttrId(obj, &PyId_lineno); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6375 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6376 res = obj2ast_int(tmp, &lineno, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6377 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6378 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6379 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6380 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6381 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6382 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6383 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6384 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6385 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6386 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6387 res = obj2ast_int(tmp, &col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6388 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6389 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6390 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6391 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6392 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6393 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6394 isinstance = PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6395 if (isinstance == -1) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6396 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6397 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6398 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6399 expr_ty type; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6400 identifier name; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6401 asdl_seq* body; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6402 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6403 if (_PyObject_HasAttrId(obj, &PyId_type)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6404 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6405 tmp = _PyObject_GetAttrId(obj, &PyId_type); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6406 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6407 res = obj2ast_expr(tmp, &type, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6408 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6409 Py_CLEAR(tmp); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6410 } else { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6411 type = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6412 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6413 if (_PyObject_HasAttrId(obj, &PyId_name)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6414 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6415 tmp = _PyObject_GetAttrId(obj, &PyId_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6416 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6417 res = obj2ast_identifier(tmp, &name, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6418 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6419 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6420 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6421 name = NULL; |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
6422 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6423 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6424 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6425 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6426 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6427 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6428 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6429 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6430 PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6431 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6432 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6433 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6434 body = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6435 if (body == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6436 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6437 stmt_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6438 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6439 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6440 asdl_seq_SET(body, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6441 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6442 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6443 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6444 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ExceptHandler"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6445 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6446 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6447 *out = ExceptHandler(type, name, body, lineno, col_offset, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6448 if (*out == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6449 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6450 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6451 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6452 PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6453 failed: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6454 Py_XDECREF(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6455 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6456 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6457 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6458 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6459 obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6460 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6461 PyObject* tmp = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6462 asdl_seq* args; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6463 identifier vararg; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6464 expr_ty varargannotation; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6465 asdl_seq* kwonlyargs; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6466 identifier kwarg; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6467 expr_ty kwargannotation; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6468 asdl_seq* defaults; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6469 asdl_seq* kw_defaults; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6470 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6471 if (_PyObject_HasAttrId(obj, &PyId_args)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6472 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6473 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6474 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6475 tmp = _PyObject_GetAttrId(obj, &PyId_args); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6476 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6477 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6478 PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6479 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6480 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6481 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6482 args = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6483 if (args == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6484 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6485 arg_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6486 res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6487 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6488 asdl_seq_SET(args, i, value); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6489 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6490 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6491 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6492 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from arguments"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6493 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6494 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6495 if (_PyObject_HasAttrId(obj, &PyId_vararg)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6496 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6497 tmp = _PyObject_GetAttrId(obj, &PyId_vararg); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6498 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6499 res = obj2ast_identifier(tmp, &vararg, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6500 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6501 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6502 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6503 vararg = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6504 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6505 if (_PyObject_HasAttrId(obj, &PyId_varargannotation)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6506 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6507 tmp = _PyObject_GetAttrId(obj, &PyId_varargannotation); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6508 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6509 res = obj2ast_expr(tmp, &varargannotation, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6510 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6511 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6512 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6513 varargannotation = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6514 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6515 if (_PyObject_HasAttrId(obj, &PyId_kwonlyargs)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6516 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6517 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6518 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6519 tmp = _PyObject_GetAttrId(obj, &PyId_kwonlyargs); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6520 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6521 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6522 PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6523 goto failed; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6524 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6525 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6526 kwonlyargs = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6527 if (kwonlyargs == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6528 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6529 arg_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6530 res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6531 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6532 asdl_seq_SET(kwonlyargs, i, value); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6533 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6534 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6535 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6536 PyErr_SetString(PyExc_TypeError, "required field \"kwonlyargs\" missing from arguments"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6537 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6538 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6539 if (_PyObject_HasAttrId(obj, &PyId_kwarg)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6540 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6541 tmp = _PyObject_GetAttrId(obj, &PyId_kwarg); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6542 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6543 res = obj2ast_identifier(tmp, &kwarg, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6544 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6545 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6546 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6547 kwarg = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6548 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6549 if (_PyObject_HasAttrId(obj, &PyId_kwargannotation)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6550 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6551 tmp = _PyObject_GetAttrId(obj, &PyId_kwargannotation); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6552 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6553 res = obj2ast_expr(tmp, &kwargannotation, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6554 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6555 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6556 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6557 kwargannotation = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6558 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6559 if (_PyObject_HasAttrId(obj, &PyId_defaults)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6560 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6561 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6562 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6563 tmp = _PyObject_GetAttrId(obj, &PyId_defaults); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6564 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6565 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6566 PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6567 goto failed; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6568 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6569 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6570 defaults = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6571 if (defaults == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6572 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6573 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6574 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6575 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6576 asdl_seq_SET(defaults, i, value); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6577 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6578 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6579 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6580 PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6581 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6582 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6583 if (_PyObject_HasAttrId(obj, &PyId_kw_defaults)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6584 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6585 Py_ssize_t len; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6586 Py_ssize_t i; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6587 tmp = _PyObject_GetAttrId(obj, &PyId_kw_defaults); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6588 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6589 if (!PyList_Check(tmp)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6590 PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6591 goto failed; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6592 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6593 len = PyList_GET_SIZE(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6594 kw_defaults = asdl_seq_new(len, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6595 if (kw_defaults == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6596 for (i = 0; i < len; i++) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6597 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6598 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6599 if (res != 0) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6600 asdl_seq_SET(kw_defaults, i, value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6601 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6602 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6603 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6604 PyErr_SetString(PyExc_TypeError, "required field \"kw_defaults\" missing from arguments"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6605 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6606 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6607 *out = arguments(args, vararg, varargannotation, kwonlyargs, kwarg, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6608 kwargannotation, defaults, kw_defaults, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6609 return 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6610 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6611 Py_XDECREF(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6612 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6613 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6614 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6615 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6616 obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6617 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6618 PyObject* tmp = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6619 identifier arg; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6620 expr_ty annotation; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6621 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6622 if (_PyObject_HasAttrId(obj, &PyId_arg)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6623 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6624 tmp = _PyObject_GetAttrId(obj, &PyId_arg); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6625 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6626 res = obj2ast_identifier(tmp, &arg, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6627 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6628 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6629 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6630 PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6631 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6632 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6633 if (_PyObject_HasAttrId(obj, &PyId_annotation)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6634 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6635 tmp = _PyObject_GetAttrId(obj, &PyId_annotation); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6636 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6637 res = obj2ast_expr(tmp, &annotation, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6638 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6639 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6640 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6641 annotation = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6642 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6643 *out = arg(arg, annotation, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6644 return 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6645 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6646 Py_XDECREF(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6647 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6648 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6649 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6650 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6651 obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6652 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6653 PyObject* tmp = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6654 identifier arg; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6655 expr_ty value; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6656 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6657 if (_PyObject_HasAttrId(obj, &PyId_arg)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6658 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6659 tmp = _PyObject_GetAttrId(obj, &PyId_arg); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6660 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6661 res = obj2ast_identifier(tmp, &arg, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6662 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6663 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6664 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6665 PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from keyword"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6666 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6667 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6668 if (_PyObject_HasAttrId(obj, &PyId_value)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6669 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6670 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6671 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6672 res = obj2ast_expr(tmp, &value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6673 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6674 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6675 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6676 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6677 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6678 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6679 *out = keyword(arg, value, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6680 return 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6681 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6682 Py_XDECREF(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6683 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6684 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6685 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6686 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6687 obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6688 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6689 PyObject* tmp = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6690 identifier name; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6691 identifier asname; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6692 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6693 if (_PyObject_HasAttrId(obj, &PyId_name)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6694 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6695 tmp = _PyObject_GetAttrId(obj, &PyId_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6696 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6697 res = obj2ast_identifier(tmp, &name, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6698 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6699 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6700 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6701 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6702 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6703 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6704 if (_PyObject_HasAttrId(obj, &PyId_asname)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6705 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6706 tmp = _PyObject_GetAttrId(obj, &PyId_asname); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6707 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6708 res = obj2ast_identifier(tmp, &asname, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6709 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6710 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6711 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6712 asname = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6713 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6714 *out = alias(name, asname, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6715 return 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6716 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6717 Py_XDECREF(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6718 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6719 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6720 |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
6721 int |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
6722 obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena) |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
6723 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6724 PyObject* tmp = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6725 expr_ty context_expr; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6726 expr_ty optional_vars; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6727 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6728 if (_PyObject_HasAttrId(obj, &PyId_context_expr)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6729 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6730 tmp = _PyObject_GetAttrId(obj, &PyId_context_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6731 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6732 res = obj2ast_expr(tmp, &context_expr, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6733 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6734 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6735 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6736 PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6737 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6738 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6739 if (_PyObject_HasAttrId(obj, &PyId_optional_vars)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6740 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6741 tmp = _PyObject_GetAttrId(obj, &PyId_optional_vars); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6742 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6743 res = obj2ast_expr(tmp, &optional_vars, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6744 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6745 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6746 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6747 optional_vars = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6748 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6749 *out = withitem(context_expr, optional_vars, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6750 return 0; |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
6751 failed: |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6752 Py_XDECREF(tmp); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6753 return 1; |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
6754 } |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
6755 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6756 |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
47301
diff
changeset
|
6757 static struct PyModuleDef _astmodule = { |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
47301
diff
changeset
|
6758 PyModuleDef_HEAD_INIT, "_ast" |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
47301
diff
changeset
|
6759 }; |
| 36669 | 6760 PyMODINIT_FUNC |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
47301
diff
changeset
|
6761 PyInit__ast(void) |
| 36669 | 6762 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6763 PyObject *m, *d; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6764 if (!init_types()) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6765 m = PyModule_Create(&_astmodule); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6766 if (!m) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6767 d = PyModule_GetDict(m); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6768 if (PyDict_SetItemString(d, "AST", (PyObject*)&AST_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6769 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6770 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6771 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6772 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6773 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6774 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) < |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6775 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6776 if (PyDict_SetItemString(d, "Expression", (PyObject*)Expression_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6777 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6778 if (PyDict_SetItemString(d, "Suite", (PyObject*)Suite_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6779 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6780 if (PyDict_SetItemString(d, "stmt", (PyObject*)stmt_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6781 if (PyDict_SetItemString(d, "FunctionDef", (PyObject*)FunctionDef_type) < |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6782 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6783 if (PyDict_SetItemString(d, "ClassDef", (PyObject*)ClassDef_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6784 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6785 if (PyDict_SetItemString(d, "Return", (PyObject*)Return_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6786 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6787 if (PyDict_SetItemString(d, "Delete", (PyObject*)Delete_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6788 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6789 if (PyDict_SetItemString(d, "Assign", (PyObject*)Assign_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6790 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6791 if (PyDict_SetItemString(d, "AugAssign", (PyObject*)AugAssign_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6792 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6793 if (PyDict_SetItemString(d, "For", (PyObject*)For_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6794 if (PyDict_SetItemString(d, "While", (PyObject*)While_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6795 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6796 if (PyDict_SetItemString(d, "If", (PyObject*)If_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6797 if (PyDict_SetItemString(d, "With", (PyObject*)With_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6798 if (PyDict_SetItemString(d, "Raise", (PyObject*)Raise_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6799 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6800 if (PyDict_SetItemString(d, "Try", (PyObject*)Try_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6801 if (PyDict_SetItemString(d, "Assert", (PyObject*)Assert_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6802 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6803 if (PyDict_SetItemString(d, "Import", (PyObject*)Import_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6804 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6805 if (PyDict_SetItemString(d, "ImportFrom", (PyObject*)ImportFrom_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6806 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6807 if (PyDict_SetItemString(d, "Global", (PyObject*)Global_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6808 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6809 if (PyDict_SetItemString(d, "Nonlocal", (PyObject*)Nonlocal_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6810 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6811 if (PyDict_SetItemString(d, "Expr", (PyObject*)Expr_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6812 if (PyDict_SetItemString(d, "Pass", (PyObject*)Pass_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6813 if (PyDict_SetItemString(d, "Break", (PyObject*)Break_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6814 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6815 if (PyDict_SetItemString(d, "Continue", (PyObject*)Continue_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6816 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6817 if (PyDict_SetItemString(d, "expr", (PyObject*)expr_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6818 if (PyDict_SetItemString(d, "BoolOp", (PyObject*)BoolOp_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6819 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6820 if (PyDict_SetItemString(d, "BinOp", (PyObject*)BinOp_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6821 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6822 if (PyDict_SetItemString(d, "UnaryOp", (PyObject*)UnaryOp_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6823 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6824 if (PyDict_SetItemString(d, "Lambda", (PyObject*)Lambda_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6825 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6826 if (PyDict_SetItemString(d, "IfExp", (PyObject*)IfExp_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6827 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6828 if (PyDict_SetItemString(d, "Dict", (PyObject*)Dict_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6829 if (PyDict_SetItemString(d, "Set", (PyObject*)Set_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6830 if (PyDict_SetItemString(d, "ListComp", (PyObject*)ListComp_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6831 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6832 if (PyDict_SetItemString(d, "SetComp", (PyObject*)SetComp_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6833 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6834 if (PyDict_SetItemString(d, "DictComp", (PyObject*)DictComp_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6835 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6836 if (PyDict_SetItemString(d, "GeneratorExp", (PyObject*)GeneratorExp_type) < |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6837 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6838 if (PyDict_SetItemString(d, "Yield", (PyObject*)Yield_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6839 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6840 if (PyDict_SetItemString(d, "YieldFrom", (PyObject*)YieldFrom_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6841 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6842 if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6843 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6844 if (PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6845 if (PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6846 if (PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6847 if (PyDict_SetItemString(d, "Bytes", (PyObject*)Bytes_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6848 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6849 if (PyDict_SetItemString(d, "Ellipsis", (PyObject*)Ellipsis_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6850 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6851 if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6852 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6853 if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6854 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6855 if (PyDict_SetItemString(d, "Starred", (PyObject*)Starred_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6856 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6857 if (PyDict_SetItemString(d, "Name", (PyObject*)Name_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6858 if (PyDict_SetItemString(d, "List", (PyObject*)List_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6859 if (PyDict_SetItemString(d, "Tuple", (PyObject*)Tuple_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6860 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6861 if (PyDict_SetItemString(d, "expr_context", (PyObject*)expr_context_type) < |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6862 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6863 if (PyDict_SetItemString(d, "Load", (PyObject*)Load_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6864 if (PyDict_SetItemString(d, "Store", (PyObject*)Store_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6865 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6866 if (PyDict_SetItemString(d, "Del", (PyObject*)Del_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6867 if (PyDict_SetItemString(d, "AugLoad", (PyObject*)AugLoad_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6868 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6869 if (PyDict_SetItemString(d, "AugStore", (PyObject*)AugStore_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6870 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6871 if (PyDict_SetItemString(d, "Param", (PyObject*)Param_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6872 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6873 if (PyDict_SetItemString(d, "slice", (PyObject*)slice_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6874 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6875 if (PyDict_SetItemString(d, "Slice", (PyObject*)Slice_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6876 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6877 if (PyDict_SetItemString(d, "ExtSlice", (PyObject*)ExtSlice_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6878 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6879 if (PyDict_SetItemString(d, "Index", (PyObject*)Index_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6880 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6881 if (PyDict_SetItemString(d, "boolop", (PyObject*)boolop_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6882 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6883 if (PyDict_SetItemString(d, "And", (PyObject*)And_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6884 if (PyDict_SetItemString(d, "Or", (PyObject*)Or_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6885 if (PyDict_SetItemString(d, "operator", (PyObject*)operator_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6886 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6887 if (PyDict_SetItemString(d, "Add", (PyObject*)Add_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6888 if (PyDict_SetItemString(d, "Sub", (PyObject*)Sub_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6889 if (PyDict_SetItemString(d, "Mult", (PyObject*)Mult_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6890 if (PyDict_SetItemString(d, "Div", (PyObject*)Div_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6891 if (PyDict_SetItemString(d, "Mod", (PyObject*)Mod_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6892 if (PyDict_SetItemString(d, "Pow", (PyObject*)Pow_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6893 if (PyDict_SetItemString(d, "LShift", (PyObject*)LShift_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6894 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6895 if (PyDict_SetItemString(d, "RShift", (PyObject*)RShift_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6896 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6897 if (PyDict_SetItemString(d, "BitOr", (PyObject*)BitOr_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6898 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6899 if (PyDict_SetItemString(d, "BitXor", (PyObject*)BitXor_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6900 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6901 if (PyDict_SetItemString(d, "BitAnd", (PyObject*)BitAnd_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6902 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6903 if (PyDict_SetItemString(d, "FloorDiv", (PyObject*)FloorDiv_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6904 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6905 if (PyDict_SetItemString(d, "unaryop", (PyObject*)unaryop_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6906 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6907 if (PyDict_SetItemString(d, "Invert", (PyObject*)Invert_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6908 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6909 if (PyDict_SetItemString(d, "Not", (PyObject*)Not_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6910 if (PyDict_SetItemString(d, "UAdd", (PyObject*)UAdd_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6911 if (PyDict_SetItemString(d, "USub", (PyObject*)USub_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6912 if (PyDict_SetItemString(d, "cmpop", (PyObject*)cmpop_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6913 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6914 if (PyDict_SetItemString(d, "Eq", (PyObject*)Eq_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6915 if (PyDict_SetItemString(d, "NotEq", (PyObject*)NotEq_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6916 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6917 if (PyDict_SetItemString(d, "Lt", (PyObject*)Lt_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6918 if (PyDict_SetItemString(d, "LtE", (PyObject*)LtE_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6919 if (PyDict_SetItemString(d, "Gt", (PyObject*)Gt_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6920 if (PyDict_SetItemString(d, "GtE", (PyObject*)GtE_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6921 if (PyDict_SetItemString(d, "Is", (PyObject*)Is_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6922 if (PyDict_SetItemString(d, "IsNot", (PyObject*)IsNot_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6923 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6924 if (PyDict_SetItemString(d, "In", (PyObject*)In_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6925 if (PyDict_SetItemString(d, "NotIn", (PyObject*)NotIn_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6926 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6927 if (PyDict_SetItemString(d, "comprehension", (PyObject*)comprehension_type) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6928 < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6929 if (PyDict_SetItemString(d, "excepthandler", (PyObject*)excepthandler_type) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6930 < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6931 if (PyDict_SetItemString(d, "ExceptHandler", (PyObject*)ExceptHandler_type) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6932 < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6933 if (PyDict_SetItemString(d, "arguments", (PyObject*)arguments_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6934 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6935 if (PyDict_SetItemString(d, "arg", (PyObject*)arg_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6936 if (PyDict_SetItemString(d, "keyword", (PyObject*)keyword_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6937 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6938 if (PyDict_SetItemString(d, "alias", (PyObject*)alias_type) < 0) return |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6939 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6940 if (PyDict_SetItemString(d, "withitem", (PyObject*)withitem_type) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6941 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6942 return m; |
| 36669 | 6943 } |
| 6944 | |
| 35742 | 6945 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
6946 PyObject* PyAST_mod2obj(mod_ty t) |
| 35742 | 6947 { |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
6948 init_types(); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
6949 return ast2obj_mod(t); |
| 35742 | 6950 } |
|
42013
cd125fe83051
Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents:
41825
diff
changeset
|
6951 |
|
46227
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6952 /* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */ |
|
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6953 mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode) |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6954 { |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6955 mod_ty res; |
|
46227
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6956 PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type, |
|
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6957 (PyObject*)Interactive_type}; |
|
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6958 char *req_name[] = {"Module", "Expression", "Interactive"}; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6959 int isinstance; |
|
46227
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6960 assert(0 <= mode && mode <= 2); |
|
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6961 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6962 init_types(); |
|
46227
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6963 |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6964 isinstance = PyObject_IsInstance(ast, req_type[mode]); |
|
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6965 if (isinstance == -1) |
|
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6966 return NULL; |
|
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6967 if (!isinstance) { |
|
46227
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6968 PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s", |
|
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6969 req_name[mode], Py_TYPE(ast)->tp_name); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6970 return NULL; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6971 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6972 if (obj2ast_mod(ast, &res, arena) != 0) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6973 return NULL; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6974 else |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6975 return res; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6976 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6977 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6978 int PyAST_Check(PyObject* obj) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6979 { |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6980 init_types(); |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
6981 return PyObject_IsInstance(obj, (PyObject*)&AST_type); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6982 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6983 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6984 |
