Mercurial > cpython-lru_cache-weakref
annotate Python/Python-ast.c @ 84851:1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Replace 8 spaces with 4.
| author | Victor Stinner <victor.stinner@gmail.com> |
|---|---|
| date | Sat, 27 Jul 2013 00:01:35 +0200 |
| parents | cf8f42eadbd0 f2d557484906 |
| children | 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 }; |
|
80738
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
274 static PyTypeObject *NameConstant_type; |
|
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
275 static char *NameConstant_fields[]={ |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
276 "value", |
|
80738
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
277 }; |
|
39783
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
278 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
|
279 static PyTypeObject *Attribute_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
280 _Py_IDENTIFIER(attr); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
281 _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
|
282 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
|
283 "value", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
284 "attr", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
285 "ctx", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
286 }; |
|
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
|
287 static PyTypeObject *Subscript_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
288 _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
|
289 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
|
290 "value", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
291 "slice", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
292 "ctx", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
293 }; |
|
41699
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
294 static PyTypeObject *Starred_type; |
|
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
295 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
|
296 "value", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
297 "ctx", |
|
41699
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
298 }; |
|
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
|
299 static PyTypeObject *Name_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
300 _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
|
301 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
|
302 "id", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
303 "ctx", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
304 }; |
|
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
|
305 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
|
306 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
|
307 "elts", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
308 "ctx", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
309 }; |
|
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
|
310 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
|
311 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
|
312 "elts", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
313 "ctx", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
314 }; |
|
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 *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
|
316 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
|
317 *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
|
318 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
|
319 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
|
320 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
|
321 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
|
322 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
|
323 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
|
324 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
|
325 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
|
326 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
|
327 static PyTypeObject *Slice_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
328 _Py_IDENTIFIER(lower); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
329 _Py_IDENTIFIER(upper); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
330 _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
|
331 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
|
332 "lower", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
333 "upper", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
334 "step", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
335 }; |
|
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
|
336 static PyTypeObject *ExtSlice_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
337 _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
|
338 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
|
339 "dims", |
|
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 *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
|
342 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
|
343 "value", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
344 }; |
|
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
|
345 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
|
346 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
|
347 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
|
348 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
|
349 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
|
350 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
|
351 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
|
352 *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
|
353 *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
|
354 *FloorDiv_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
355 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
|
356 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
|
357 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
|
358 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
|
359 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
|
360 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
|
361 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
|
362 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
|
363 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
|
364 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
|
365 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
|
366 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
|
367 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
|
368 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
|
369 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
|
370 *USub_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
371 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
|
372 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
|
373 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
|
374 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
|
375 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
|
376 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
|
377 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
|
378 *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
|
379 *NotIn_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
380 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
|
381 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
|
382 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
|
383 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
|
384 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
|
385 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
|
386 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
|
387 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
|
388 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
|
389 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
|
390 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
|
391 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
|
392 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
|
393 _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
|
394 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
|
395 "target", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
396 "iter", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
397 "ifs", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
398 }; |
|
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
|
399 static PyTypeObject *excepthandler_type; |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
400 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
|
401 "lineno", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
402 "col_offset", |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
403 }; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
404 static PyObject* ast2obj_excepthandler(void*); |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
405 static PyTypeObject *ExceptHandler_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
406 _Py_IDENTIFIER(type); |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
407 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
|
408 "type", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
409 "name", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
410 "body", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
411 }; |
|
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
|
412 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
|
413 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
|
414 _Py_IDENTIFIER(vararg); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
415 _Py_IDENTIFIER(kwonlyargs); |
|
82732
7c5c678e4164
unify some ast.argument's attrs; change Attribute column offset (closes #16795)
Benjamin Peterson <benjamin@python.org>
parents:
81039
diff
changeset
|
416 _Py_IDENTIFIER(kw_defaults); |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
417 _Py_IDENTIFIER(kwarg); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
418 _Py_IDENTIFIER(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
|
419 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
|
420 "args", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
421 "vararg", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
422 "kwonlyargs", |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
423 "kw_defaults", |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
424 "kwarg", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
425 "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*); |
|
82732
7c5c678e4164
unify some ast.argument's attrs; change Attribute column offset (closes #16795)
Benjamin Peterson <benjamin@python.org>
parents:
81039
diff
changeset
|
429 static char *arg_attributes[] = { |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
430 "lineno", |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
431 "col_offset", |
|
82732
7c5c678e4164
unify some ast.argument's attrs; change Attribute column offset (closes #16795)
Benjamin Peterson <benjamin@python.org>
parents:
81039
diff
changeset
|
432 }; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
433 _Py_IDENTIFIER(arg); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
434 _Py_IDENTIFIER(annotation); |
|
41717
9ad84070b22d
Merged revisions 55328-55341 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41699
diff
changeset
|
435 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
|
436 "arg", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
437 "annotation", |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
438 }; |
|
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
|
439 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
|
440 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
|
441 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
|
442 "arg", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
443 "value", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
444 }; |
|
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
|
445 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
|
446 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
|
447 _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
|
448 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
|
449 "name", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
450 "asname", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
451 }; |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
452 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
|
453 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
|
454 _Py_IDENTIFIER(context_expr); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
455 _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
|
456 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
|
457 "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
|
458 "optional_vars", |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
459 }; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
460 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
461 |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
462 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
|
463 PyObject_HEAD |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
464 PyObject *dict; |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
465 } AST_object; |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
466 |
| 75686 | 467 static void |
| 468 ast_dealloc(AST_object *self) | |
| 469 { | |
| 470 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
|
471 Py_TYPE(self)->tp_free(self); |
| 75686 | 472 } |
| 473 | |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
474 static int |
|
78006
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
475 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
|
476 { |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
477 Py_VISIT(self->dict); |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
478 return 0; |
|
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 |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
481 static void |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
482 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
|
483 { |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
484 Py_CLEAR(self->dict); |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
485 } |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
486 |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
487 static int |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
488 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
|
489 { |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
490 _Py_IDENTIFIER(_fields); |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
491 Py_ssize_t i, numfields = 0; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
492 int res = -1; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
493 PyObject *key, *value, *fields; |
|
72848
81380082d216
Use identifier API for PyObject_GetAttrString.
Martin v. Löwis <martin@v.loewis.de>
parents:
72195
diff
changeset
|
494 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
|
495 if (!fields) |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
496 PyErr_Clear(); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
497 if (fields) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
498 numfields = PySequence_Size(fields); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
499 if (numfields == -1) |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
500 goto cleanup; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
501 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
502 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
|
503 if (PyTuple_GET_SIZE(args) > 0) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
504 if (numfields != PyTuple_GET_SIZE(args)) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
505 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
|
506 "%zd positional argument%s", |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
507 Py_TYPE(self)->tp_name, |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
508 numfields == 0 ? "" : "either 0 or ", |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
509 numfields, numfields == 1 ? "" : "s"); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
510 res = -1; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
511 goto cleanup; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
512 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
513 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
|
514 /* cannot be reached when fields is NULL */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
515 PyObject *name = PySequence_GetItem(fields, i); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
516 if (!name) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
517 res = -1; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
518 goto cleanup; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
519 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
520 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
|
521 Py_DECREF(name); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
522 if (res < 0) |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
523 goto cleanup; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
524 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
525 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
526 if (kw) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
527 i = 0; /* needed by PyDict_Next */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
528 while (PyDict_Next(kw, &i, &key, &value)) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
529 res = PyObject_SetAttr(self, key, value); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
530 if (res < 0) |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
531 goto cleanup; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
532 } |
|
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 cleanup: |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
535 Py_XDECREF(fields); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
536 return res; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
537 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
538 |
|
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
|
539 /* 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
|
540 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
|
541 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
|
542 { |
|
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 PyObject *res; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
544 _Py_IDENTIFIER(__dict__); |
|
72848
81380082d216
Use identifier API for PyObject_GetAttrString.
Martin v. Löwis <martin@v.loewis.de>
parents:
72195
diff
changeset
|
545 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
|
546 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
|
547 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
|
548 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
|
549 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
|
550 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
|
551 } |
|
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 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
|
553 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
|
554 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
|
555 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
|
556 } |
|
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 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
|
558 } |
|
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 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
|
561 {"__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
|
562 {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
|
563 }; |
|
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
|
564 |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
565 static PyGetSetDef ast_type_getsets[] = { |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
566 {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict}, |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
567 {NULL} |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
568 }; |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
569 |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
570 static PyTypeObject AST_type = { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
571 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
|
572 "_ast.AST", |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
573 sizeof(AST_object), |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
574 0, |
| 75686 | 575 (destructor)ast_dealloc, /* tp_dealloc */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
576 0, /* tp_print */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
577 0, /* tp_getattr */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
578 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
|
579 0, /* tp_reserved */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
580 0, /* tp_repr */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
581 0, /* tp_as_number */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
582 0, /* tp_as_sequence */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
583 0, /* tp_as_mapping */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
584 0, /* tp_hash */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
585 0, /* tp_call */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
586 0, /* tp_str */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
587 PyObject_GenericGetAttr, /* tp_getattro */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
588 PyObject_GenericSetAttr, /* tp_setattro */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
589 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
|
590 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
|
591 0, /* tp_doc */ |
|
78006
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
592 (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
|
593 (inquiry)ast_clear, /* tp_clear */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
594 0, /* tp_richcompare */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
595 0, /* tp_weaklistoffset */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
596 0, /* tp_iter */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
597 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
|
598 ast_type_methods, /* tp_methods */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
599 0, /* tp_members */ |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
600 ast_type_getsets, /* tp_getset */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
601 0, /* tp_base */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
602 0, /* tp_dict */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
603 0, /* tp_descr_get */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
604 0, /* tp_descr_set */ |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
605 offsetof(AST_object, dict),/* tp_dictoffset */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
606 (initproc)ast_type_init, /* tp_init */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
607 PyType_GenericAlloc, /* tp_alloc */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
608 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
|
609 PyObject_GC_Del, /* tp_free */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
610 }; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
611 |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
612 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
613 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
|
614 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
615 PyObject *fnames, *result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
616 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
|
617 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
|
618 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
|
619 for (i = 0; i < num_fields; i++) { |
|
42816
872c7c3f0af3
Use unicode for AST attributes
Neal Norwitz <nnorwitz@gmail.com>
parents:
42206
diff
changeset
|
620 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
|
621 if (!field) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
622 Py_DECREF(fnames); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
623 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
624 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
625 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
|
626 } |
|
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
|
627 result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}", |
| 36669 | 628 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
|
629 Py_DECREF(fnames); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
630 return (PyTypeObject*)result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
631 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
632 |
| 36669 | 633 static int add_attributes(PyTypeObject* type, char**attrs, int num_fields) |
| 634 { | |
|
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
|
635 int i, result; |
|
72926
db4aa878cea2
Port SetAttrString/HasAttrString to SetAttrId/GetAttrId.
Martin v. Löwis <martin@v.loewis.de>
parents:
72925
diff
changeset
|
636 _Py_IDENTIFIER(_attributes); |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
637 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
|
638 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
|
639 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
|
640 for (i = 0; i < num_fields; i++) { |
|
42816
872c7c3f0af3
Use unicode for AST attributes
Neal Norwitz <nnorwitz@gmail.com>
parents:
42206
diff
changeset
|
641 s = PyUnicode_FromString(attrs[i]); |
| 36669 | 642 if (!s) { |
| 643 Py_DECREF(l); | |
| 644 return 0; | |
| 645 } | |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
646 PyTuple_SET_ITEM(l, i, s); |
| 36669 | 647 } |
|
72926
db4aa878cea2
Port SetAttrString/HasAttrString to SetAttrId/GetAttrId.
Martin v. Löwis <martin@v.loewis.de>
parents:
72925
diff
changeset
|
648 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
|
649 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
|
650 return result; |
| 36669 | 651 } |
| 652 | |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
653 /* Conversion AST -> Python */ |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
654 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
655 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
|
656 { |
|
76964
c18a1a82bb07
use Py_ssize_t for ast sequence lengths
Benjamin Peterson <benjamin@python.org>
parents:
76948
diff
changeset
|
657 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
|
658 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
|
659 PyObject *value; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
660 if (!result) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
661 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
662 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
|
663 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
|
664 if (!value) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
665 Py_DECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
666 return NULL; |
|
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 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
|
669 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
670 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
671 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
672 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
673 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
|
674 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
675 if (!o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
676 o = Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
677 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
|
678 return (PyObject*)o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
679 } |
|
80738
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
680 #define ast2obj_singleton ast2obj_object |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
681 #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
|
682 #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
|
683 #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
|
684 |
|
40937
6aa1be5dd009
Merged revisions 53912-53951 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40896
diff
changeset
|
685 static PyObject* ast2obj_int(long b) |
| 36669 | 686 { |
|
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
|
687 return PyLong_FromLong(b); |
| 36669 | 688 } |
| 689 | |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
690 /* Conversion Python -> AST */ |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
691 |
|
80738
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
692 static int obj2ast_singleton(PyObject *obj, PyObject** out, PyArena* arena) |
|
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
693 { |
|
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
694 if (obj != Py_None && obj != Py_True && obj != Py_False) { |
|
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
695 PyErr_SetString(PyExc_ValueError, |
|
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
696 "AST singleton must be True, False, or None"); |
|
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
697 return 1; |
|
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
698 } |
|
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
699 *out = obj; |
|
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
700 return 0; |
|
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
701 } |
|
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
702 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
703 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
|
704 { |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
705 if (obj == Py_None) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
706 obj = NULL; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
707 if (obj) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
708 PyArena_AddPyObject(arena, obj); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
709 Py_XINCREF(obj); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
710 *out = obj; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
711 return 0; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
712 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
713 |
|
71458
c9ebae3285e3
None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents:
71455
diff
changeset
|
714 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
|
715 { |
|
71458
c9ebae3285e3
None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents:
71455
diff
changeset
|
716 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
|
717 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
|
718 return 1; |
|
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
719 } |
|
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
720 return obj2ast_object(obj, out, arena); |
|
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
721 } |
|
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
722 |
|
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
723 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
|
724 { |
|
72154
c8b6d4417274
accept bytes for the AST 'string' type
Benjamin Peterson <benjamin@python.org>
parents:
71458
diff
changeset
|
725 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
|
726 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
|
727 return 1; |
|
c9ebae3285e3
None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents:
71455
diff
changeset
|
728 } |
|
c9ebae3285e3
None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents:
71455
diff
changeset
|
729 return obj2ast_object(obj, out, arena); |
|
71454
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
730 } |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
731 |
|
71792
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
732 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
|
733 { |
|
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
734 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
|
735 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
|
736 return 1; |
|
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
737 } |
|
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
738 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
|
739 } |
|
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
740 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
741 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
|
742 { |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
743 int i; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
744 if (!PyLong_Check(obj)) { |
|
73700
470f7d7c57ce
Issue #13436: commit regenerated Python-ast.c
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
72154
diff
changeset
|
745 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
|
746 return 1; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
747 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
748 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
749 i = (int)PyLong_AsLong(obj); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
750 if (i == -1 && PyErr_Occurred()) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
751 return 1; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
752 *out = i; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
753 return 0; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
754 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
755 |
|
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
|
756 static int add_ast_fields(void) |
|
49583
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
757 { |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
758 PyObject *empty_tuple, *d; |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
759 if (PyType_Ready(&AST_type) < 0) |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
760 return -1; |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
761 d = AST_type.tp_dict; |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
762 empty_tuple = PyTuple_New(0); |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
763 if (!empty_tuple || |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
764 PyDict_SetItemString(d, "_fields", empty_tuple) < 0 || |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
765 PyDict_SetItemString(d, "_attributes", empty_tuple) < 0) { |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
766 Py_XDECREF(empty_tuple); |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
767 return -1; |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
768 } |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
769 Py_DECREF(empty_tuple); |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
770 return 0; |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
771 } |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
772 |
|
82747
c8ccc0519247
refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents:
82732
diff
changeset
|
773 static int exists_not_none(PyObject *obj, _Py_Identifier *id) |
|
c8ccc0519247
refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents:
82732
diff
changeset
|
774 { |
|
82750
cc7a94efb1b7
bump Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
82747
diff
changeset
|
775 int isnone; |
|
82747
c8ccc0519247
refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents:
82732
diff
changeset
|
776 PyObject *attr = _PyObject_GetAttrId(obj, id); |
|
c8ccc0519247
refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents:
82732
diff
changeset
|
777 if (!attr) { |
|
c8ccc0519247
refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents:
82732
diff
changeset
|
778 PyErr_Clear(); |
|
c8ccc0519247
refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents:
82732
diff
changeset
|
779 return 0; |
|
c8ccc0519247
refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents:
82732
diff
changeset
|
780 } |
|
82750
cc7a94efb1b7
bump Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
82747
diff
changeset
|
781 isnone = attr == Py_None; |
|
82747
c8ccc0519247
refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents:
82732
diff
changeset
|
782 Py_DECREF(attr); |
|
c8ccc0519247
refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents:
82732
diff
changeset
|
783 return !isnone; |
|
c8ccc0519247
refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents:
82732
diff
changeset
|
784 } |
|
c8ccc0519247
refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents:
82732
diff
changeset
|
785 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
786 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
787 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
|
788 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
789 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
|
790 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
|
791 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
|
792 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
|
793 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
|
794 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
|
795 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
|
796 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
|
797 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
|
798 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
799 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
|
800 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
|
801 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
|
802 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
|
803 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
|
804 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
|
805 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
|
806 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
|
807 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
|
808 5); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
809 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
|
810 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
|
811 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
|
812 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
|
813 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
|
814 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
|
815 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
|
816 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
|
817 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
|
818 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
|
819 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
|
820 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
|
821 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
|
822 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
|
823 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
|
824 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
|
825 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
|
826 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
|
827 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
|
828 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
|
829 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
|
830 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
|
831 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
|
832 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
|
833 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
|
834 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
|
835 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
|
836 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
|
837 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
|
838 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
|
839 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
|
840 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
|
841 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
|
842 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
|
843 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
|
844 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
|
845 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
|
846 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
|
847 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
|
848 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
|
849 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
|
850 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
|
851 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
|
852 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
|
853 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
|
854 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
|
855 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
|
856 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
|
857 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
|
858 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
|
859 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
|
860 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
|
861 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
|
862 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
|
863 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
|
864 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
|
865 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
|
866 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
|
867 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
|
868 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
|
869 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
|
870 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
|
871 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
|
872 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
|
873 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
|
874 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
|
875 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
|
876 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
|
877 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
|
878 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
|
879 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
|
880 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
|
881 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
|
882 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
|
883 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
|
884 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
|
885 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
|
886 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
|
887 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
|
888 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
|
889 if (!Bytes_type) return 0; |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
890 NameConstant_type = make_type("NameConstant", expr_type, |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
891 NameConstant_fields, 1); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
892 if (!NameConstant_type) return 0; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
893 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
|
894 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
|
895 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
|
896 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
|
897 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
|
898 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
|
899 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
|
900 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
|
901 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
|
902 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
|
903 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
|
904 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
|
905 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
|
906 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
|
907 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
|
908 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
|
909 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
|
910 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
|
911 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
|
912 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
|
913 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
|
914 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
|
915 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
|
916 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
|
917 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
|
918 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
|
919 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
|
920 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
|
921 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
|
922 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
|
923 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
|
924 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
|
925 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
|
926 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
|
927 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
|
928 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
|
929 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
|
930 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
|
931 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
|
932 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
|
933 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
|
934 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
|
935 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
|
936 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
|
937 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
|
938 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
|
939 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
|
940 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
|
941 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
|
942 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
|
943 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
|
944 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
|
945 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
|
946 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
|
947 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
|
948 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
|
949 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
|
950 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
|
951 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
|
952 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
|
953 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
|
954 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
|
955 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
|
956 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
|
957 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
|
958 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
|
959 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
|
960 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
|
961 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
|
962 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
|
963 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
|
964 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
|
965 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
|
966 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
|
967 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
|
968 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
|
969 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
|
970 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
|
971 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
|
972 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
|
973 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
|
974 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
|
975 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
|
976 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
|
977 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
|
978 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
|
979 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
|
980 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
|
981 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
|
982 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
|
983 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
|
984 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
|
985 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
|
986 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
|
987 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
|
988 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
|
989 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
|
990 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
|
991 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
|
992 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
|
993 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
|
994 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
|
995 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
|
996 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
|
997 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
|
998 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
|
999 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
|
1000 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
|
1001 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
|
1002 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
|
1003 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
|
1004 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
|
1005 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
|
1006 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
|
1007 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
|
1008 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
|
1009 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
|
1010 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
|
1011 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
|
1012 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
|
1013 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
|
1014 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
|
1015 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
|
1016 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
|
1017 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
|
1018 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
|
1019 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
|
1020 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
|
1021 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
|
1022 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
|
1023 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
|
1024 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
|
1025 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
|
1026 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
|
1027 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
|
1028 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
|
1029 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
|
1030 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
|
1031 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
|
1032 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
|
1033 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
|
1034 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
|
1035 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
|
1036 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
|
1037 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
|
1038 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
|
1039 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
|
1040 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
|
1041 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
|
1042 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
|
1043 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
|
1044 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
|
1045 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
|
1046 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
|
1047 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
|
1048 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
|
1049 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
|
1050 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
|
1051 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
|
1052 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
|
1053 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
|
1054 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
|
1055 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
|
1056 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
|
1057 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
|
1058 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
|
1059 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
|
1060 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
|
1061 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
|
1062 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
|
1063 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
|
1064 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
|
1065 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
|
1066 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
|
1067 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
|
1068 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
|
1069 if (!comprehension_type) return 0; |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1070 if (!add_attributes(comprehension_type, NULL, 0)) return 0; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1071 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
|
1072 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
|
1073 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
|
1074 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
|
1075 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
|
1076 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
|
1077 if (!ExceptHandler_type) return 0; |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1078 arguments_type = make_type("arguments", &AST_type, arguments_fields, 6); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1079 if (!arguments_type) return 0; |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1080 if (!add_attributes(arguments_type, NULL, 0)) return 0; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1081 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
|
1082 if (!arg_type) return 0; |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1083 if (!add_attributes(arg_type, arg_attributes, 2)) return 0; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1084 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
|
1085 if (!keyword_type) return 0; |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1086 if (!add_attributes(keyword_type, NULL, 0)) return 0; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1087 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
|
1088 if (!alias_type) return 0; |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1089 if (!add_attributes(alias_type, NULL, 0)) return 0; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1090 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
|
1091 if (!withitem_type) return 0; |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1092 if (!add_attributes(withitem_type, NULL, 0)) return 0; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1093 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
|
1094 return 1; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1095 } |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1096 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1097 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
|
1098 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
|
1099 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
|
1100 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
|
1101 arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1102 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
|
1103 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
|
1104 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
|
1105 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
|
1106 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
|
1107 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
|
1108 arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1109 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
|
1110 arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1111 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
|
1112 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
|
1113 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
|
1114 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
|
1115 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
|
1116 |
| 35742 | 1117 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
|
1118 Module(asdl_seq * body, PyArena *arena) |
| 35742 | 1119 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1120 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
|
1121 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
|
1122 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
|
1123 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
|
1124 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
|
1125 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
|
1126 return p; |
| 35742 | 1127 } |
| 1128 | |
| 1129 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
|
1130 Interactive(asdl_seq * body, PyArena *arena) |
| 35742 | 1131 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1132 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
|
1133 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
|
1134 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
|
1135 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
|
1136 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
|
1137 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
|
1138 return p; |
| 35742 | 1139 } |
| 1140 | |
| 1141 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
|
1142 Expression(expr_ty body, PyArena *arena) |
| 35742 | 1143 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1144 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
|
1145 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
|
1146 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
|
1147 "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
|
1148 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
|
1149 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1150 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
|
1151 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
|
1152 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
|
1153 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
|
1154 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
|
1155 return p; |
| 35742 | 1156 } |
| 1157 | |
| 1158 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
|
1159 Suite(asdl_seq * body, PyArena *arena) |
| 35742 | 1160 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1161 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
|
1162 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
|
1163 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
|
1164 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
|
1165 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
|
1166 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
|
1167 return p; |
| 35742 | 1168 } |
| 1169 | |
| 1170 stmt_ty | |
| 1171 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
|
1172 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
|
1173 PyArena *arena) |
| 35742 | 1174 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1175 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
|
1176 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
|
1177 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
|
1178 "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
|
1179 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
|
1180 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1181 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
|
1182 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
|
1183 "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
|
1184 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
|
1185 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1186 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
|
1187 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
|
1188 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
|
1189 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
|
1190 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
|
1191 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
|
1192 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
|
1193 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
|
1194 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
|
1195 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
|
1196 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
|
1197 return p; |
| 35742 | 1198 } |
| 1199 | |
| 1200 stmt_ty | |
|
41226
19f7ff443718
Implement PEP 3115 -- new metaclass syntax and semantics.
Guido van Rossum <guido@python.org>
parents:
40980
diff
changeset
|
1201 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
|
1202 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
|
1203 int lineno, int col_offset, PyArena *arena) |
| 35742 | 1204 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1205 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
|
1206 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
|
1207 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
|
1208 "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
|
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 } |
|
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 = (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
|
1212 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
|
1213 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
|
1214 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
|
1215 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
|
1216 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
|
1217 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
|
1218 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
|
1219 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
|
1220 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
|
1221 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
|
1222 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
|
1223 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
|
1224 return p; |
| 35742 | 1225 } |
| 1226 | |
| 1227 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
|
1228 Return(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1229 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1230 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
|
1231 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
|
1232 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
|
1233 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
|
1234 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
|
1235 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
|
1236 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
|
1237 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
|
1238 return p; |
| 35742 | 1239 } |
| 1240 | |
| 1241 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
|
1242 Delete(asdl_seq * targets, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1243 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1244 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
|
1245 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
|
1246 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
|
1247 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
|
1248 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
|
1249 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
|
1250 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
|
1251 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
|
1252 return p; |
| 35742 | 1253 } |
| 1254 | |
| 1255 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
|
1256 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
|
1257 *arena) |
| 35742 | 1258 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1259 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
|
1260 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
|
1261 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
|
1262 "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
|
1263 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
|
1264 } |
|
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 = (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
|
1266 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
|
1267 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
|
1268 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
|
1269 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
|
1270 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
|
1271 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
|
1272 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
|
1273 return p; |
| 35742 | 1274 } |
| 1275 | |
| 1276 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
|
1277 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
|
1278 col_offset, PyArena *arena) |
| 35742 | 1279 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1280 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
|
1281 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
|
1282 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
|
1283 "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
|
1284 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
|
1285 } |
|
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 (!op) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1287 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
|
1288 "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
|
1289 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
|
1290 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1291 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
|
1292 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
|
1293 "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
|
1294 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
|
1295 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1296 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
|
1297 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
|
1298 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
|
1299 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
|
1300 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
|
1301 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
|
1302 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
|
1303 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
|
1304 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
|
1305 return p; |
| 35742 | 1306 } |
| 1307 | |
| 1308 stmt_ty | |
| 1309 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
|
1310 lineno, int col_offset, PyArena *arena) |
| 35742 | 1311 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1312 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
|
1313 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
|
1314 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
|
1315 "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
|
1316 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
|
1317 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1318 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
|
1319 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
|
1320 "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
|
1321 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
|
1322 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1323 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
|
1324 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
|
1325 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
|
1326 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
|
1327 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
|
1328 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
|
1329 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
|
1330 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
|
1331 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
|
1332 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
|
1333 return p; |
| 35742 | 1334 } |
| 1335 | |
| 1336 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
|
1337 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
|
1338 col_offset, PyArena *arena) |
| 35742 | 1339 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1340 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
|
1341 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
|
1342 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
|
1343 "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
|
1344 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
|
1345 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1346 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
|
1347 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
|
1348 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
|
1349 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
|
1350 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
|
1351 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
|
1352 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
|
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; |
| 35742 | 1356 } |
| 1357 | |
| 1358 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
|
1359 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
|
1360 col_offset, PyArena *arena) |
| 35742 | 1361 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1362 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
|
1363 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
|
1364 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
|
1365 "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
|
1366 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
|
1367 } |
|
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 = (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
|
1369 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
|
1370 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
|
1371 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
|
1372 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
|
1373 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
|
1374 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
|
1375 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
|
1376 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
|
1377 return p; |
| 35742 | 1378 } |
| 1379 | |
| 1380 stmt_ty | |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
1381 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
|
1382 *arena) |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1383 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1384 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
|
1385 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
|
1386 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
|
1387 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
|
1388 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
|
1389 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
|
1390 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
|
1391 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
|
1392 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
|
1393 return p; |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1394 } |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1395 |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1396 stmt_ty |
|
43102
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42844
diff
changeset
|
1397 Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1398 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1399 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
|
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 = 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
|
1404 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
|
1405 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
|
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 | |
|
70499
e0e663132363
unify TryExcept and TryFinally (closes #12199)
Benjamin Peterson <benjamin@python.org>
parents:
70439
diff
changeset
|
1412 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
|
1413 finalbody, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1414 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1415 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
|
1416 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
|
1417 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
|
1418 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
|
1419 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
|
1420 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
|
1421 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
|
1422 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
|
1423 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
|
1424 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
|
1425 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
|
1426 return p; |
| 35742 | 1427 } |
| 1428 | |
| 1429 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
|
1430 Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1431 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1432 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
|
1433 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
|
1434 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
|
1435 "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
|
1436 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
|
1437 } |
|
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 = (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
|
1439 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
|
1440 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
|
1441 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
|
1442 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
|
1443 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
|
1444 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
|
1445 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
|
1446 return p; |
| 35742 | 1447 } |
| 1448 | |
| 1449 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
|
1450 Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1451 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1452 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
|
1453 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
|
1454 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
|
1455 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
|
1456 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
|
1457 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
|
1458 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
|
1459 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
|
1460 return p; |
| 35742 | 1461 } |
| 1462 | |
| 1463 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
|
1464 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
|
1465 col_offset, PyArena *arena) |
| 35742 | 1466 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1467 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
|
1468 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
|
1469 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
|
1470 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
|
1471 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
|
1472 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
|
1473 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
|
1474 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
|
1475 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
|
1476 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
|
1477 return p; |
| 35742 | 1478 } |
| 1479 | |
| 1480 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
|
1481 Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1482 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1483 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
|
1484 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
|
1485 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
|
1486 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
|
1487 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
|
1488 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
|
1489 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
|
1490 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
|
1491 return p; |
| 35742 | 1492 } |
| 1493 | |
| 1494 stmt_ty | |
|
40965
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
1495 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
|
1496 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1497 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
|
1498 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
|
1499 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
|
1500 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
|
1501 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
|
1502 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
|
1503 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
|
1504 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
|
1505 return p; |
|
40965
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
1506 } |
|
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
1507 |
|
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
1508 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
|
1509 Expr(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1510 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1511 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
|
1512 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
|
1513 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
|
1514 "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
|
1515 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
|
1516 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1517 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
|
1518 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
|
1519 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
|
1520 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
|
1521 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
|
1522 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
|
1523 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
|
1524 return p; |
| 35742 | 1525 } |
| 1526 | |
| 1527 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
|
1528 Pass(int lineno, int col_offset, PyArena *arena) |
| 35742 | 1529 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1530 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
|
1531 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
|
1532 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
|
1533 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
|
1534 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
|
1535 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
|
1536 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
|
1537 return p; |
| 35742 | 1538 } |
| 1539 | |
| 1540 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
|
1541 Break(int lineno, int col_offset, PyArena *arena) |
| 35742 | 1542 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1543 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
|
1544 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
|
1545 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
|
1546 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
|
1547 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
|
1548 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
|
1549 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
|
1550 return p; |
| 35742 | 1551 } |
| 1552 | |
| 1553 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
|
1554 Continue(int lineno, int col_offset, PyArena *arena) |
| 35742 | 1555 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1556 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
|
1557 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
|
1558 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
|
1559 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
|
1560 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
|
1561 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
|
1562 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
|
1563 return p; |
| 35742 | 1564 } |
| 1565 | |
| 1566 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
|
1567 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
|
1568 *arena) |
| 35742 | 1569 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1570 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
|
1571 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
|
1572 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
|
1573 "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
|
1574 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
|
1575 } |
|
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 = (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
|
1577 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
|
1578 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
|
1579 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
|
1580 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
|
1581 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
|
1582 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
|
1583 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
|
1584 return p; |
| 35742 | 1585 } |
| 1586 | |
| 1587 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
|
1588 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
|
1589 PyArena *arena) |
| 35742 | 1590 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1591 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
|
1592 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
|
1593 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
|
1594 "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
|
1595 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
|
1596 } |
|
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 (!op) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1598 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
|
1599 "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
|
1600 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
|
1601 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1602 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
|
1603 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
|
1604 "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
|
1605 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
|
1606 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1607 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
|
1608 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
|
1609 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
|
1610 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
|
1611 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
|
1612 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
|
1613 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
|
1614 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
|
1615 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
|
1616 return p; |
| 35742 | 1617 } |
| 1618 | |
| 1619 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
|
1620 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
|
1621 *arena) |
| 35742 | 1622 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1623 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
|
1624 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
|
1625 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
|
1626 "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
|
1627 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
|
1628 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1629 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
|
1630 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
|
1631 "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
|
1632 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
|
1633 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1634 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
|
1635 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
|
1636 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
|
1637 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
|
1638 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
|
1639 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
|
1640 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
|
1641 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
|
1642 return p; |
| 35742 | 1643 } |
| 1644 | |
| 1645 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
|
1646 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
|
1647 *arena) |
| 35742 | 1648 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1649 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
|
1650 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
|
1651 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
|
1652 "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
|
1653 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
|
1654 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1655 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
|
1656 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
|
1657 "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
|
1658 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
|
1659 } |
|
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 = (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
|
1661 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
|
1662 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
|
1663 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
|
1664 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
|
1665 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
|
1666 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
|
1667 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
|
1668 return p; |
| 35742 | 1669 } |
| 1670 | |
| 1671 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
|
1672 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
|
1673 PyArena *arena) |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1674 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1675 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
|
1676 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
|
1677 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
|
1678 "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
|
1679 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
|
1680 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1681 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
|
1682 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
|
1683 "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
|
1684 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
|
1685 } |
|
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 (!orelse) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1687 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
|
1688 "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
|
1689 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
|
1690 } |
|
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 = (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
|
1692 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
|
1693 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
|
1694 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
|
1695 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
|
1696 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
|
1697 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
|
1698 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
|
1699 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
|
1700 return p; |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1701 } |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1702 |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1703 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
|
1704 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
|
1705 *arena) |
| 35742 | 1706 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1707 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
|
1708 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
|
1709 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
|
1710 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
|
1711 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
|
1712 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
|
1713 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
|
1714 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
|
1715 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
|
1716 return p; |
| 35742 | 1717 } |
| 1718 | |
| 1719 expr_ty | |
|
39693
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
1720 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
|
1721 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1722 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
|
1723 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
|
1724 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
|
1725 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
|
1726 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
|
1727 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
|
1728 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
|
1729 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
|
1730 return p; |
|
39693
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
1731 } |
|
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
1732 |
|
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
1733 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
|
1734 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
|
1735 PyArena *arena) |
| 35742 | 1736 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1737 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
|
1738 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
|
1739 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
|
1740 "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
|
1741 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
|
1742 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1743 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
|
1744 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
|
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 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
|
1747 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
|
1748 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
|
1749 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
|
1750 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
|
1751 return p; |
| 35742 | 1752 } |
| 1753 | |
| 1754 expr_ty | |
|
41464
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
1755 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
|
1756 *arena) |
|
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
1757 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1758 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
|
1759 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
|
1760 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
|
1761 "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
|
1762 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
|
1763 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1764 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
|
1765 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
|
1766 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
|
1767 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
|
1768 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
|
1769 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
|
1770 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
|
1771 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
|
1772 return p; |
|
41464
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
1773 } |
|
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
1774 |
|
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
1775 expr_ty |
|
42193
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
1776 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
|
1777 col_offset, PyArena *arena) |
|
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
1778 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1779 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
|
1780 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
|
1781 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
|
1782 "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
|
1783 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
|
1784 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1785 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
|
1786 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
|
1787 "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
|
1788 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
|
1789 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1790 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
|
1791 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
|
1792 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
|
1793 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
|
1794 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
|
1795 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
|
1796 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
|
1797 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
|
1798 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
|
1799 return p; |
|
42193
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
1800 } |
|
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
1801 |
|
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
1802 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
|
1803 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
|
1804 PyArena *arena) |
| 35742 | 1805 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1806 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
|
1807 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
|
1808 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
|
1809 "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
|
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 } |
|
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 = (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
|
1813 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
|
1814 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
|
1815 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
|
1816 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
|
1817 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
|
1818 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
|
1819 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
|
1820 return p; |
| 35742 | 1821 } |
| 1822 | |
| 1823 expr_ty | |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
1824 Yield(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1825 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1826 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
|
1827 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
|
1828 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
|
1829 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
|
1830 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
|
1831 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
|
1832 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
|
1833 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
|
1834 return p; |
| 35742 | 1835 } |
| 1836 | |
| 1837 expr_ty | |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
1838 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
|
1839 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1840 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
|
1841 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
|
1842 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
|
1843 "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
|
1844 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
|
1845 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1846 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
|
1847 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
|
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 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
|
1850 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
|
1851 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
|
1852 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
|
1853 return p; |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
1854 } |
|
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
1855 |
|
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
1856 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
|
1857 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
|
1858 int col_offset, PyArena *arena) |
| 35742 | 1859 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1860 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
|
1861 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
|
1862 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
|
1863 "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
|
1864 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
|
1865 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1866 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
|
1867 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
|
1868 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
|
1869 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
|
1870 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
|
1871 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
|
1872 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
|
1873 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
|
1874 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
|
1875 return p; |
| 35742 | 1876 } |
| 1877 | |
| 1878 expr_ty | |
| 1879 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
|
1880 expr_ty kwargs, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1881 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1882 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
|
1883 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
|
1884 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
|
1885 "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
|
1886 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
|
1887 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1888 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
|
1889 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
|
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 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
|
1892 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
|
1893 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
|
1894 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
|
1895 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
|
1896 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
|
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 | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1903 Num(object n, int lineno, int col_offset, PyArena *arena) |
| 35742 | 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 (!n) { |
|
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 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
|
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 = 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
|
1915 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
|
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; |
| 35742 | 1919 } |
| 1920 | |
| 1921 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
|
1922 Str(string s, int lineno, int col_offset, PyArena *arena) |
| 35742 | 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 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
|
1926 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
|
1927 "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
|
1928 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
|
1929 } |
|
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 = (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
|
1931 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
|
1932 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
|
1933 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
|
1934 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
|
1935 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
|
1936 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
|
1937 return p; |
| 35742 | 1938 } |
| 1939 | |
| 1940 expr_ty | |
|
71792
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
1941 Bytes(bytes s, int lineno, int col_offset, PyArena *arena) |
| 40894 | 1942 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1943 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
|
1944 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
|
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 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
|
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 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
|
1950 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
|
1951 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
|
1952 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
|
1953 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
|
1954 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
|
1955 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
|
1956 return p; |
| 40894 | 1957 } |
| 1958 | |
| 1959 expr_ty | |
|
80738
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
1960 NameConstant(singleton value, int lineno, int col_offset, PyArena *arena) |
|
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
1961 { |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1962 expr_ty p; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1963 if (!value) { |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1964 PyErr_SetString(PyExc_ValueError, |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1965 "field value is required for NameConstant"); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1966 return NULL; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1967 } |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1968 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1969 if (!p) |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1970 return NULL; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1971 p->kind = NameConstant_kind; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1972 p->v.NameConstant.value = value; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1973 p->lineno = lineno; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1974 p->col_offset = col_offset; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
1975 return p; |
|
80738
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
1976 } |
|
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
1977 |
|
03f92a9f0875
create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents:
80589
diff
changeset
|
1978 expr_ty |
|
39783
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
1979 Ellipsis(int lineno, int col_offset, PyArena *arena) |
|
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
1980 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1981 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
|
1982 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
|
1983 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
|
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 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
|
1986 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
|
1987 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
|
1988 return p; |
|
39783
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
1989 } |
|
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
1990 |
|
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
1991 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
|
1992 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
|
1993 col_offset, PyArena *arena) |
| 35742 | 1994 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1995 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
|
1996 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
|
1997 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
|
1998 "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
|
1999 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
|
2000 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2001 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
|
2002 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
|
2003 "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
|
2004 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
|
2005 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2006 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
|
2007 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
|
2008 "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
|
2009 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
|
2010 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2011 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
|
2012 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
|
2013 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
|
2014 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
|
2015 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
|
2016 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
|
2017 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
|
2018 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
|
2019 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
|
2020 return p; |
| 35742 | 2021 } |
| 2022 | |
| 2023 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
|
2024 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
|
2025 col_offset, PyArena *arena) |
| 35742 | 2026 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2027 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
|
2028 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
|
2029 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
|
2030 "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
|
2031 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
|
2032 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2033 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
|
2034 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
|
2035 "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
|
2036 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
|
2037 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2038 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
|
2039 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
|
2040 "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
|
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 } |
|
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 = (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
|
2044 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
|
2045 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
|
2046 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
|
2047 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
|
2048 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
|
2049 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
|
2050 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
|
2051 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
|
2052 return p; |
| 35742 | 2053 } |
| 2054 | |
| 2055 expr_ty | |
|
41699
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
2056 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
|
2057 *arena) |
|
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
2058 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2059 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
|
2060 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
|
2061 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
|
2062 "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
|
2063 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
|
2064 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2065 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
|
2066 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
|
2067 "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
|
2068 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
|
2069 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2070 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
|
2071 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
|
2072 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
|
2073 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
|
2074 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
|
2075 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
|
2076 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
|
2077 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
|
2078 return p; |
|
41699
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
2079 } |
|
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
2080 |
|
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
2081 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
|
2082 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
|
2083 *arena) |
| 35742 | 2084 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2085 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
|
2086 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
|
2087 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
|
2088 "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
|
2089 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
|
2090 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2091 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
|
2092 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
|
2093 "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
|
2094 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
|
2095 } |
|
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 = (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
|
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 = 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
|
2100 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
|
2101 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
|
2102 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
|
2103 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
|
2104 return p; |
| 35742 | 2105 } |
| 2106 | |
| 2107 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
|
2108 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
|
2109 *arena) |
| 35742 | 2110 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2111 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
|
2112 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
|
2113 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
|
2114 "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
|
2115 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
|
2116 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2117 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
|
2118 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
|
2119 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
|
2120 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
|
2121 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
|
2122 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
|
2123 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
|
2124 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
|
2125 return p; |
| 35742 | 2126 } |
| 2127 | |
| 2128 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
|
2129 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
|
2130 *arena) |
| 35742 | 2131 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2132 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
|
2133 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
|
2134 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
|
2135 "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
|
2136 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
|
2137 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2138 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
|
2139 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
|
2140 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
|
2141 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
|
2142 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
|
2143 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
|
2144 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
|
2145 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
|
2146 return p; |
| 35742 | 2147 } |
| 2148 | |
| 2149 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
|
2150 Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena) |
| 35742 | 2151 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2152 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
|
2153 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
|
2154 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
|
2155 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
|
2156 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
|
2157 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
|
2158 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
|
2159 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
|
2160 return p; |
| 35742 | 2161 } |
| 2162 | |
| 2163 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
|
2164 ExtSlice(asdl_seq * dims, PyArena *arena) |
| 35742 | 2165 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2166 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
|
2167 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
|
2168 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
|
2169 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
|
2170 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
|
2171 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
|
2172 return p; |
| 35742 | 2173 } |
| 2174 | |
| 2175 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
|
2176 Index(expr_ty value, PyArena *arena) |
| 35742 | 2177 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2178 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
|
2179 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
|
2180 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
|
2181 "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
|
2182 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
|
2183 } |
|
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 = (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
|
2185 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
|
2186 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
|
2187 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
|
2188 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
|
2189 return p; |
| 35742 | 2190 } |
| 2191 | |
| 2192 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
|
2193 comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena) |
| 35742 | 2194 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2195 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
|
2196 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
|
2197 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
|
2198 "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
|
2199 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
|
2200 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2201 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
|
2202 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
|
2203 "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
|
2204 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
|
2205 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2206 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
|
2207 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
|
2208 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
|
2209 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
|
2210 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
|
2211 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
|
2212 return p; |
| 35742 | 2213 } |
| 2214 | |
| 2215 excepthandler_ty | |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
2216 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
|
2217 col_offset, PyArena *arena) |
| 35742 | 2218 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2219 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
|
2220 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
|
2221 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
|
2222 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
|
2223 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
|
2224 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
|
2225 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
|
2226 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
|
2227 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
|
2228 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
|
2229 return p; |
| 35742 | 2230 } |
| 2231 | |
| 2232 arguments_ty | |
|
82732
7c5c678e4164
unify some ast.argument's attrs; change Attribute column offset (closes #16795)
Benjamin Peterson <benjamin@python.org>
parents:
81039
diff
changeset
|
2233 arguments(asdl_seq * args, arg_ty vararg, asdl_seq * kwonlyargs, asdl_seq * |
|
7c5c678e4164
unify some ast.argument's attrs; change Attribute column offset (closes #16795)
Benjamin Peterson <benjamin@python.org>
parents:
81039
diff
changeset
|
2234 kw_defaults, arg_ty kwarg, asdl_seq * defaults, PyArena *arena) |
| 35742 | 2235 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2236 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
|
2237 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
|
2238 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
|
2239 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
|
2240 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
|
2241 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
|
2242 p->kwonlyargs = kwonlyargs; |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
2243 p->kw_defaults = kw_defaults; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2244 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
|
2245 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
|
2246 return p; |
| 35742 | 2247 } |
| 2248 | |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
2249 arg_ty |
|
41717
9ad84070b22d
Merged revisions 55328-55341 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41699
diff
changeset
|
2250 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
|
2251 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2252 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
|
2253 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
|
2254 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
|
2255 "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
|
2256 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
|
2257 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2258 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
|
2259 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
|
2260 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
|
2261 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
|
2262 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
|
2263 return p; |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
2264 } |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
2265 |
| 35742 | 2266 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
|
2267 keyword(identifier arg, expr_ty value, PyArena *arena) |
| 35742 | 2268 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2269 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
|
2270 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
|
2271 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
|
2272 "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
|
2273 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
|
2274 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2275 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
|
2276 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
|
2277 "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
|
2278 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
|
2279 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2280 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
|
2281 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
|
2282 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
|
2283 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
|
2284 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
|
2285 return p; |
| 35742 | 2286 } |
| 2287 | |
| 2288 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
|
2289 alias(identifier name, identifier asname, PyArena *arena) |
| 35742 | 2290 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2291 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
|
2292 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
|
2293 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
|
2294 "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
|
2295 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
|
2296 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2297 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
|
2298 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
|
2299 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
|
2300 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
|
2301 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
|
2302 return p; |
| 35742 | 2303 } |
| 2304 | |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
2305 withitem_ty |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
2306 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
|
2307 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2308 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
|
2309 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
|
2310 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
|
2311 "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
|
2312 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
|
2313 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2314 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
|
2315 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
|
2316 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
|
2317 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
|
2318 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
|
2319 return p; |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
2320 } |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
2321 |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2322 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2323 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2324 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
|
2325 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2326 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
|
2327 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
|
2328 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
|
2329 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
|
2330 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
|
2331 } |
|
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 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
|
2334 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
|
2335 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
|
2336 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
|
2337 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
|
2338 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
|
2339 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
|
2340 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2341 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
|
2342 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2343 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
|
2344 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
|
2345 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
|
2346 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
|
2347 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
|
2348 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
|
2349 goto 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 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
|
2351 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2352 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
|
2353 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
|
2354 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
|
2355 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
|
2356 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
|
2357 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
|
2358 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2359 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
|
2360 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2361 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
|
2362 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
|
2363 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
|
2364 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
|
2365 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
|
2366 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
|
2367 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2368 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
|
2369 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2370 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2371 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2372 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
|
2373 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
|
2374 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
|
2375 return NULL; |
| 36174 | 2376 } |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2377 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2378 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2379 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
|
2380 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2381 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
|
2382 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
|
2383 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
|
2384 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
|
2385 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
|
2386 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2387 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2388 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
|
2389 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
|
2390 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
|
2391 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
|
2392 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
|
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_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
|
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_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
|
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_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
|
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 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
|
2403 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
|
2404 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
|
2405 goto 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 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
|
2407 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
|
2408 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
|
2409 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
|
2410 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2411 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
|
2412 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
|
2413 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
|
2414 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
|
2415 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2416 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
|
2417 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2418 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
|
2419 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
|
2420 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
|
2421 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
|
2422 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
|
2423 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
|
2424 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2425 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
|
2426 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
|
2427 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
|
2428 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
|
2429 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2430 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
|
2431 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
|
2432 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
|
2433 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
|
2434 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2435 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
|
2436 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
|
2437 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
|
2438 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
|
2439 goto 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 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
|
2441 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
|
2442 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
|
2443 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
|
2444 goto 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 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
|
2446 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
|
2447 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
|
2448 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
|
2449 goto 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 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
|
2451 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
|
2452 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
|
2453 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
|
2454 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2455 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
|
2456 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2457 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
|
2458 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
|
2459 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
|
2460 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
|
2461 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
|
2462 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
|
2463 goto 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 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
|
2465 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2466 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
|
2467 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
|
2468 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
|
2469 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
|
2470 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
|
2471 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
|
2472 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2473 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
|
2474 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2475 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
|
2476 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
|
2477 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
|
2478 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
|
2479 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
|
2480 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
|
2481 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2482 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
|
2483 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
|
2484 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
|
2485 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
|
2486 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2487 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
|
2488 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2489 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
|
2490 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
|
2491 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
|
2492 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
|
2493 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
|
2494 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
|
2495 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2496 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
|
2497 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
|
2498 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
|
2499 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
|
2500 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2501 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
|
2502 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
|
2503 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
|
2504 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
|
2505 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2506 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
|
2507 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2508 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
|
2509 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
|
2510 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
|
2511 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
|
2512 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
|
2513 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
|
2514 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2515 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
|
2516 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
|
2517 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
|
2518 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
|
2519 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2520 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
|
2521 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
|
2522 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
|
2523 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
|
2524 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2525 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
|
2526 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
|
2527 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
|
2528 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
|
2529 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2530 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
|
2531 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2532 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
|
2533 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
|
2534 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
|
2535 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
|
2536 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
|
2537 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
|
2538 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2539 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
|
2540 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
|
2541 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
|
2542 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
|
2543 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2544 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
|
2545 value = ast2obj_list(o->v.While.orelse, ast2obj_stmt); |
| 36669 | 2546 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
|
2547 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
|
2548 goto 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 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
|
2550 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2551 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
|
2552 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
|
2553 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
|
2554 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
|
2555 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
|
2556 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
|
2557 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2558 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
|
2559 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
|
2560 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
|
2561 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
|
2562 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2563 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
|
2564 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
|
2565 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
|
2566 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
|
2567 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2568 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
|
2569 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2570 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
|
2571 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
|
2572 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
|
2573 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
|
2574 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
|
2575 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
|
2576 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2577 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
|
2578 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
|
2579 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
|
2580 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
|
2581 goto failed; |
|
36794
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2582 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
|
2583 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2584 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
|
2585 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
|
2586 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
|
2587 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
|
2588 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
|
2589 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
|
2590 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2591 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
|
2592 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
|
2593 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
|
2594 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
|
2595 goto 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 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
|
2597 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2598 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
|
2599 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
|
2600 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
|
2601 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
|
2602 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
|
2603 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
|
2604 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2605 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
|
2606 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
|
2607 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
|
2608 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
|
2609 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2610 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
|
2611 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
|
2612 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
|
2613 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
|
2614 goto 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 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
|
2616 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
|
2617 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
|
2618 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
|
2619 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2620 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
|
2621 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2622 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
|
2623 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
|
2624 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
|
2625 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
|
2626 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
|
2627 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
|
2628 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2629 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
|
2630 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
|
2631 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
|
2632 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
|
2633 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2634 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
|
2635 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2636 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
|
2637 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
|
2638 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
|
2639 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
|
2640 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
|
2641 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
|
2642 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2643 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
|
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 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
|
2646 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
|
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 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
|
2649 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
|
2650 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
|
2651 goto 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 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
|
2653 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
|
2654 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
|
2655 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
|
2656 goto 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 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
|
2658 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
|
2659 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
|
2660 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
|
2661 goto failed; |
|
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_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
|
2663 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2664 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
|
2665 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
|
2666 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
|
2667 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
|
2668 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
|
2669 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
|
2670 goto failed; |
|
36794
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2671 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
|
2672 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2673 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
|
2674 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
|
2675 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
|
2676 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
|
2677 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
|
2678 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
|
2679 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2680 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
|
2681 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2682 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
|
2683 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
|
2684 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
|
2685 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
|
2686 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
|
2687 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
|
2688 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2689 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
|
2690 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2691 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
|
2692 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
|
2693 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
|
2694 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2695 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
|
2696 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
|
2697 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
|
2698 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2699 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
|
2700 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
|
2701 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
|
2702 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2703 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2704 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
|
2705 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
|
2706 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
|
2707 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2708 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
|
2709 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
|
2710 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
|
2711 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
|
2712 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2713 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
|
2714 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2715 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
|
2716 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
|
2717 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
|
2718 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2719 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2720 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2721 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2722 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
|
2723 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2724 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
|
2725 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
|
2726 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
|
2727 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
|
2728 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
|
2729 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2730 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2731 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
|
2732 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
|
2733 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
|
2734 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
|
2735 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
|
2736 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
|
2737 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
|
2738 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2739 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
|
2740 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
|
2741 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
|
2742 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
|
2743 goto 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 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
|
2745 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2746 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
|
2747 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
|
2748 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
|
2749 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
|
2750 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
|
2751 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
|
2752 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2753 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
|
2754 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
|
2755 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
|
2756 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
|
2757 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2758 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
|
2759 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
|
2760 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
|
2761 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
|
2762 goto 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 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
|
2764 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2765 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
|
2766 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
|
2767 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
|
2768 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
|
2769 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
|
2770 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
|
2771 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2772 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
|
2773 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
|
2774 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
|
2775 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
|
2776 goto 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 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
|
2778 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2779 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
|
2780 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
|
2781 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
|
2782 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
|
2783 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
|
2784 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
|
2785 goto 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 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
|
2787 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
|
2788 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
|
2789 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
|
2790 goto 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 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
|
2792 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2793 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
|
2794 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
|
2795 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
|
2796 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
|
2797 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
|
2798 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
|
2799 goto 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 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
|
2801 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
|
2802 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
|
2803 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
|
2804 goto 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 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
|
2806 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
|
2807 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
|
2808 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
|
2809 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2810 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
|
2811 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2812 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
|
2813 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
|
2814 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
|
2815 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
|
2816 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
|
2817 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
|
2818 goto 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 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
|
2820 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
|
2821 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
|
2822 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
|
2823 goto 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 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
|
2825 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2826 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
|
2827 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
|
2828 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
|
2829 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
|
2830 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
|
2831 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
|
2832 goto 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 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
|
2834 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2835 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
|
2836 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
|
2837 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
|
2838 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
|
2839 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
|
2840 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
|
2841 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2842 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
|
2843 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
|
2844 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
|
2845 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
|
2846 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2847 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
|
2848 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2849 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
|
2850 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
|
2851 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
|
2852 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
|
2853 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
|
2854 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
|
2855 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2856 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
|
2857 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
|
2858 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
|
2859 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
|
2860 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2861 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
|
2862 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2863 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
|
2864 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
|
2865 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
|
2866 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
|
2867 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
|
2868 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
|
2869 goto failed; |
|
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_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
|
2871 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
|
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 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
|
2874 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2875 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
|
2876 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
|
2877 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
|
2878 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
|
2879 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2880 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
|
2881 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2882 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
|
2883 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
|
2884 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
|
2885 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
|
2886 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
|
2887 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
|
2888 goto 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 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
|
2890 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
|
2891 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
|
2892 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
|
2893 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
|
2894 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2895 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
|
2896 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2897 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
|
2898 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
|
2899 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
|
2900 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
|
2901 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
|
2902 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
|
2903 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2904 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
|
2905 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2906 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
|
2907 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
|
2908 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
|
2909 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
|
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_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
|
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 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
|
2916 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
|
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_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
|
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_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
|
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 { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2924 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
|
2925 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
|
2926 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
|
2927 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
|
2928 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
|
2929 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2930 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
|
2931 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
|
2932 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2933 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
|
2934 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
|
2935 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
|
2936 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
|
2937 goto 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 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
|
2939 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2940 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
|
2941 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
|
2942 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
|
2943 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
|
2944 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
|
2945 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
|
2946 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2947 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
|
2948 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
|
2949 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
|
2950 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
|
2951 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2952 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
|
2953 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
|
2954 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
|
2955 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
|
2956 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2957 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
|
2958 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
|
2959 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
|
2960 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
|
2961 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2962 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
|
2963 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
|
2964 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
|
2965 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
|
2966 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2967 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
|
2968 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2969 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
|
2970 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
|
2971 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
|
2972 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
|
2973 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
|
2974 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
|
2975 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2976 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
|
2977 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2978 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
|
2979 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
|
2980 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
|
2981 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
|
2982 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
|
2983 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
|
2984 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2985 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
|
2986 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2987 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
|
2988 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
|
2989 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
|
2990 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
|
2991 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
|
2992 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
|
2993 goto 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 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
|
2995 break; |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
2996 case NameConstant_kind: |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
2997 result = PyType_GenericNew(NameConstant_type, NULL, NULL); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
2998 if (!result) goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
2999 value = ast2obj_singleton(o->v.NameConstant.value); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3000 if (!value) goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3001 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3002 goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3003 Py_DECREF(value); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3004 break; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3005 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
|
3006 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
|
3007 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
|
3008 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3009 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
|
3010 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
|
3011 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
|
3012 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
|
3013 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
|
3014 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
|
3015 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3016 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
|
3017 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
|
3018 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
|
3019 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
|
3020 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3021 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
|
3022 value = ast2obj_expr_context(o->v.Attribute.ctx); |
| 36669 | 3023 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
|
3024 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
|
3025 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3026 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
|
3027 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3028 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
|
3029 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
|
3030 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
|
3031 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
|
3032 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
|
3033 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
|
3034 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3035 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
|
3036 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
|
3037 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
|
3038 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
|
3039 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3040 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
|
3041 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
|
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_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
|
3044 goto failed; |
|
36794
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
3045 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
|
3046 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3047 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
|
3048 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
|
3049 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
|
3050 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
|
3051 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
|
3052 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
|
3053 goto failed; |
|
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_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
|
3055 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
|
3056 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
|
3057 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
|
3058 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3059 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
|
3060 break; |
|
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 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
|
3062 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
|
3063 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
|
3064 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
|
3065 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
|
3066 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
|
3067 goto failed; |
|
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_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
|
3069 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
|
3070 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
|
3071 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
|
3072 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3073 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
|
3074 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3075 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
|
3076 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
|
3077 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
|
3078 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
|
3079 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
|
3080 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
|
3081 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3082 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
|
3083 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
|
3084 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
|
3085 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
|
3086 goto failed; |
|
36794
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
3087 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
|
3088 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3089 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
|
3090 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
|
3091 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
|
3092 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
|
3093 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
|
3094 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
|
3095 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3096 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
|
3097 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
|
3098 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
|
3099 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
|
3100 goto 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 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
|
3102 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3103 } |
|
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_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
|
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_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
|
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_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
|
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_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
|
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 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3115 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
|
3116 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
|
3117 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
|
3118 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3119 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3120 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3121 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
|
3122 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3123 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
|
3124 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
|
3125 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
|
3126 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
|
3127 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
|
3128 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
|
3129 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
|
3130 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
|
3131 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
|
3132 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
|
3133 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
|
3134 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
|
3135 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
|
3136 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
|
3137 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
|
3138 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
|
3139 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
|
3140 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
|
3141 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
|
3142 default: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3143 /* 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
|
3144 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
|
3145 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
|
3146 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3147 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3148 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3149 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
|
3150 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3151 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
|
3152 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
|
3153 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
|
3154 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
|
3155 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
|
3156 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3157 |
|
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->kind) { |
|
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 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
|
3160 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
|
3161 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
|
3162 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
|
3163 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
|
3164 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
|
3165 goto failed; |
|
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_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
|
3167 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
|
3168 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
|
3169 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
|
3170 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3171 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
|
3172 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
|
3173 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
|
3174 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
|
3175 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3176 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
|
3177 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3178 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
|
3179 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
|
3180 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
|
3181 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
|
3182 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
|
3183 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
|
3184 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3185 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
|
3186 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3187 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
|
3188 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
|
3189 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
|
3190 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
|
3191 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
|
3192 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
|
3193 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3194 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
|
3195 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3196 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3197 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3198 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
|
3199 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
|
3200 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
|
3201 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3202 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3203 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3204 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
|
3205 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3206 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
|
3207 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
|
3208 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
|
3209 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
|
3210 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
|
3211 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
|
3212 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
|
3213 default: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3214 /* 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
|
3215 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
|
3216 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
|
3217 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3218 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3219 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
|
3220 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3221 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
|
3222 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
|
3223 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
|
3224 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
|
3225 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
|
3226 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
|
3227 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
|
3228 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
|
3229 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
|
3230 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
|
3231 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
|
3232 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
|
3233 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
|
3234 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
|
3235 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
|
3236 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
|
3237 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
|
3238 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
|
3239 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
|
3240 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
|
3241 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
|
3242 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
|
3243 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
|
3244 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
|
3245 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
|
3246 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
|
3247 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
|
3248 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
|
3249 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
|
3250 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
|
3251 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
|
3252 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
|
3253 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
|
3254 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
|
3255 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
|
3256 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
|
3257 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
|
3258 default: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3259 /* 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
|
3260 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
|
3261 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
|
3262 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3263 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3264 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
|
3265 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3266 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
|
3267 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
|
3268 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
|
3269 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
|
3270 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
|
3271 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
|
3272 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
|
3273 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
|
3274 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
|
3275 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
|
3276 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
|
3277 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
|
3278 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
|
3279 default: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3280 /* 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
|
3281 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
|
3282 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
|
3283 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3284 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3285 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
|
3286 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3287 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
|
3288 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
|
3289 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
|
3290 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
|
3291 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
|
3292 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
|
3293 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
|
3294 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
|
3295 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
|
3296 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
|
3297 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
|
3298 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
|
3299 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
|
3300 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
|
3301 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
|
3302 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
|
3303 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
|
3304 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
|
3305 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
|
3306 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
|
3307 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
|
3308 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
|
3309 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
|
3310 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
|
3311 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
|
3312 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
|
3313 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
|
3314 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
|
3315 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
|
3316 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
|
3317 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
|
3318 default: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3319 /* 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
|
3320 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
|
3321 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
|
3322 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3323 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3324 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3325 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
|
3326 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3327 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
|
3328 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
|
3329 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
|
3330 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
|
3331 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
|
3332 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3333 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3334 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
|
3335 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
|
3336 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
|
3337 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
|
3338 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
|
3339 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3340 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
|
3341 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
|
3342 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
|
3343 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
|
3344 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3345 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
|
3346 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
|
3347 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
|
3348 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
|
3349 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3350 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
|
3351 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3352 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
|
3353 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
|
3354 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
|
3355 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3356 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3357 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3358 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3359 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
|
3360 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3361 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
|
3362 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
|
3363 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
|
3364 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
|
3365 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
|
3366 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3367 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3368 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
|
3369 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
|
3370 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
|
3371 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
|
3372 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
|
3373 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
|
3374 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
|
3375 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3376 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
|
3377 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
|
3378 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
|
3379 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
|
3380 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
|
3381 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
|
3382 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
|
3383 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
|
3384 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
|
3385 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
|
3386 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
|
3387 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3388 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3389 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
|
3390 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
|
3391 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
|
3392 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3393 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
|
3394 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
|
3395 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
|
3396 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
|
3397 goto failed; |
|
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_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
|
3399 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3400 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
|
3401 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
|
3402 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
|
3403 return NULL; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3404 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3405 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3406 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3407 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
|
3408 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3409 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
|
3410 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
|
3411 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
|
3412 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
|
3413 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
|
3414 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3415 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3416 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
|
3417 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
|
3418 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
|
3419 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
|
3420 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
|
3421 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3422 Py_DECREF(value); |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3423 value = ast2obj_arg(o->vararg); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3424 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
|
3425 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
|
3426 goto failed; |
|
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_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
|
3428 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
|
3429 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
|
3430 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
|
3431 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3432 Py_DECREF(value); |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3433 value = ast2obj_list(o->kw_defaults, ast2obj_expr); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3434 if (!value) goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3435 if (_PyObject_SetAttrId(result, &PyId_kw_defaults, value) == -1) |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3436 goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3437 Py_DECREF(value); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3438 value = ast2obj_arg(o->kwarg); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3439 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
|
3440 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
|
3441 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3442 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
|
3443 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
|
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_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
|
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 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3449 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
|
3450 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
|
3451 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
|
3452 return NULL; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3453 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3454 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3455 PyObject* |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3456 ast2obj_arg(void* _o) |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3457 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3458 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
|
3459 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
|
3460 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
|
3461 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
|
3462 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
|
3463 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3464 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3465 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
|
3466 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
|
3467 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
|
3468 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
|
3469 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
|
3470 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3471 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
|
3472 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
|
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_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
|
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); |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3477 value = ast2obj_int(o->lineno); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3478 if (!value) goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3479 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0) |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3480 goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3481 Py_DECREF(value); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3482 value = ast2obj_int(o->col_offset); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3483 if (!value) goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3484 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0) |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3485 goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3486 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
|
3487 return result; |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3488 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
|
3489 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
|
3490 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
|
3491 return NULL; |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3492 } |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3493 |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3494 PyObject* |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3495 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
|
3496 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3497 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
|
3498 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
|
3499 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
|
3500 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
|
3501 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
|
3502 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3503 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3504 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
|
3505 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
|
3506 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
|
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_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
|
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 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
|
3512 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
|
3513 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
|
3514 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3515 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
|
3516 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3517 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
|
3518 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
|
3519 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
|
3520 return NULL; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3521 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3522 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3523 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3524 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
|
3525 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3526 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
|
3527 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
|
3528 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
|
3529 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
|
3530 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
|
3531 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3532 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3533 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
|
3534 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
|
3535 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
|
3536 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
|
3537 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
|
3538 goto failed; |
|
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_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
|
3540 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
|
3541 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
|
3542 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
|
3543 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3544 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
|
3545 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3546 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
|
3547 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
|
3548 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
|
3549 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3550 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3551 |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
3552 PyObject* |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
3553 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
|
3554 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3555 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
|
3556 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
|
3557 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
|
3558 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
|
3559 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
|
3560 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3561 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3562 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
|
3563 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
|
3564 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
|
3565 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
|
3566 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
|
3567 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3568 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
|
3569 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
|
3570 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
|
3571 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
|
3572 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3573 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
|
3574 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3575 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
|
3576 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
|
3577 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
|
3578 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3579 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3580 |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3581 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3582 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3583 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
|
3584 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3585 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
|
3586 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3587 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
|
3588 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3589 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
|
3590 *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
|
3591 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
|
3592 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3593 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
|
3594 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
|
3595 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
|
3596 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3598 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
|
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 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
|
3601 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
|
3602 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
|
3603 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
|
3604 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
|
3605 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
|
3606 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
|
3607 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
|
3608 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3609 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3610 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
|
3611 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
|
3612 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
|
3613 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
|
3614 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
|
3615 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
|
3616 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
|
3617 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
|
3618 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3619 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
|
3620 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
|
3621 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3622 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
|
3623 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
3624 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3625 *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
|
3626 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
|
3627 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
|
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 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
|
3630 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
|
3631 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
|
3632 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3633 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
|
3634 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
|
3635 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3636 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
|
3637 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
|
3638 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
|
3639 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
|
3640 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
|
3641 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
|
3642 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
|
3643 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
|
3644 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3645 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3646 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
|
3647 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
|
3648 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
|
3649 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
|
3650 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
|
3651 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
|
3652 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
|
3653 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
|
3654 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3655 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
|
3656 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
|
3657 } else { |
|
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_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
|
3659 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
3660 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3661 *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
|
3662 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
|
3663 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
|
3664 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3665 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
|
3666 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
|
3667 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
|
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 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
|
3670 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
|
3671 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3672 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
|
3673 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
|
3674 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
|
3675 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
|
3676 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
|
3677 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
|
3678 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
|
3679 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
|
3680 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3681 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
|
3682 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
3683 } |
|
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 *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
|
3685 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
|
3686 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
|
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 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
|
3689 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
|
3690 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
|
3691 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3692 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
|
3693 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
|
3694 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3695 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
|
3696 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
|
3697 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
|
3698 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
|
3699 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
|
3700 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
|
3701 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
|
3702 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
|
3703 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3704 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3705 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
|
3706 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
|
3707 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
|
3708 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
|
3709 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
|
3710 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
|
3711 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
|
3712 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
|
3713 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3714 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
|
3715 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
|
3716 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3717 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
|
3718 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3719 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3720 *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
|
3721 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
|
3722 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
|
3723 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3724 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3725 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
|
3726 failed: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3727 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
|
3728 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3729 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3730 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3731 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3732 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
|
3733 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3734 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
|
3735 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3736 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
|
3737 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
|
3738 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
|
3739 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3740 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
|
3741 *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
|
3742 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
|
3743 } |
|
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 (_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
|
3745 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
|
3746 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
|
3747 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
|
3748 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
|
3749 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
|
3750 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
|
3751 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
|
3752 } else { |
|
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 \"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
|
3754 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
|
3755 } |
|
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_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
|
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 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
|
3759 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
|
3760 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
|
3761 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
|
3762 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
|
3763 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
|
3764 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3765 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
|
3766 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
|
3767 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3768 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
|
3769 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
|
3770 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
|
3771 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3773 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
|
3774 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
|
3775 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
|
3776 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
|
3777 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
|
3778 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3779 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
|
3780 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
|
3781 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
|
3782 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
|
3783 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
|
3784 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
|
3785 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
|
3786 tmp = NULL; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3787 } 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
|
3788 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
|
3789 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
|
3790 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3791 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
|
3792 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
|
3793 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
|
3794 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
|
3795 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
|
3796 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
|
3797 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
|
3798 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
|
3799 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3800 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
|
3801 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3802 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3803 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
|
3804 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
|
3805 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
|
3806 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
|
3807 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
|
3808 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
|
3809 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
|
3810 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
|
3811 goto 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 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3813 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
|
3814 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
|
3815 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
|
3816 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
|
3817 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
|
3818 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
|
3819 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
|
3820 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
|
3821 } |
|
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_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
|
3823 tmp = NULL; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3824 } 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
|
3825 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
|
3826 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3827 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3828 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
|
3829 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
|
3830 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
|
3831 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
|
3832 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
|
3833 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
|
3834 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
|
3835 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
|
3836 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3837 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3838 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
|
3839 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
|
3840 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
|
3841 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
|
3842 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
|
3843 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
|
3844 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
|
3845 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
|
3846 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3847 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
|
3848 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
|
3849 } else { |
|
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_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
|
3851 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
|
3852 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3853 if (exists_not_none(obj, &PyId_returns)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3854 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
|
3855 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
|
3856 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
|
3857 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
|
3858 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
|
3859 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
|
3860 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
|
3861 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3862 returns = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
3863 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3864 *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
|
3865 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
|
3866 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
|
3867 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
|
3868 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3869 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
|
3870 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
|
3871 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
|
3872 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3873 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
|
3874 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
|
3875 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
|
3876 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
|
3877 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
|
3878 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
|
3879 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
|
3880 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
|
3881 |
|
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 (_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
|
3883 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
|
3884 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
|
3885 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
|
3886 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
|
3887 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
|
3888 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
|
3889 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
|
3890 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3891 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
|
3892 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
|
3893 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3894 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
|
3895 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
|
3896 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
|
3897 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
|
3898 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
|
3899 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
|
3900 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
|
3901 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
|
3902 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3903 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3904 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
|
3905 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
|
3906 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
|
3907 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
|
3908 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
|
3909 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
|
3910 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
|
3911 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
|
3912 } |
|
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_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
|
3914 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
|
3915 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3916 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
|
3917 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3918 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3919 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
|
3920 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
|
3921 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
|
3922 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
|
3923 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
|
3924 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
|
3925 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
|
3926 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
|
3927 goto 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 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3929 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
|
3930 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
|
3931 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
|
3932 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
|
3933 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
|
3934 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
|
3935 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
|
3936 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
|
3937 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3938 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
|
3939 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
|
3940 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3941 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
|
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 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3944 if (exists_not_none(obj, &PyId_starargs)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3945 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
|
3946 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
|
3947 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
|
3948 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
|
3949 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
|
3950 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
|
3951 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
|
3952 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3953 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
|
3954 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
3955 if (exists_not_none(obj, &PyId_kwargs)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3956 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
|
3957 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
|
3958 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
|
3959 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
|
3960 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
|
3961 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
|
3962 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
|
3963 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3964 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
|
3965 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3966 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
|
3967 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
|
3968 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
|
3969 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
|
3970 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
|
3971 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
|
3972 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
|
3973 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
|
3974 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3975 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3976 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
|
3977 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
|
3978 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
|
3979 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
|
3980 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
|
3981 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
|
3982 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
|
3983 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
|
3984 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3985 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
|
3986 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
|
3987 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3988 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
|
3989 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
|
3990 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3991 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
|
3992 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
|
3993 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
|
3994 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
|
3995 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
|
3996 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
|
3997 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
|
3998 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
|
3999 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4000 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4001 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
|
4002 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
|
4003 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
|
4004 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
|
4005 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
|
4006 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
|
4007 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
|
4008 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
|
4009 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4010 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
|
4011 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
|
4012 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4013 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
|
4014 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4015 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4016 *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
|
4017 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
|
4018 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
|
4019 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
|
4020 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4021 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
|
4022 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
|
4023 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
|
4024 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4025 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
|
4026 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
|
4027 |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
4028 if (exists_not_none(obj, &PyId_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
|
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; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4034 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
|
4035 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
|
4036 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4037 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
|
4038 } |
|
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 = 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
|
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*)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
|
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 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
|
4049 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4050 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
|
4051 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
|
4052 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
|
4053 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
|
4054 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
|
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 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
|
4057 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
|
4058 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4059 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4060 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
|
4061 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
|
4062 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
|
4063 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
|
4064 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
|
4065 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
|
4066 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
|
4067 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
|
4068 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4069 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
|
4070 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
|
4071 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4072 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
|
4073 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4074 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4075 *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
|
4076 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
|
4077 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
|
4078 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4079 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
|
4080 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
|
4081 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
|
4082 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4083 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
|
4084 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
|
4085 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
|
4086 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4087 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
|
4088 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
|
4089 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
|
4090 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
|
4091 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
|
4092 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
|
4093 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
|
4094 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
|
4095 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4096 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4097 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
|
4098 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
|
4099 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
|
4100 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
|
4101 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
|
4102 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
|
4103 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
|
4104 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
|
4105 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4106 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
|
4107 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
|
4108 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4109 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
|
4110 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
|
4111 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4112 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
|
4113 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
|
4114 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
|
4115 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
|
4116 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
|
4117 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
|
4118 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
|
4119 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
|
4120 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4121 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
|
4122 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4123 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4124 *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
|
4125 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
|
4126 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
|
4127 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4128 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
|
4129 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
|
4130 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
|
4131 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4132 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
|
4133 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
|
4134 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
|
4135 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
|
4136 |
|
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 (_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
|
4138 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
|
4139 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
|
4140 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
|
4141 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
|
4142 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
|
4143 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
|
4144 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
|
4145 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4146 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
|
4147 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
|
4148 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4149 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
|
4150 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
|
4151 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
|
4152 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
|
4153 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
|
4154 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
|
4155 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
|
4156 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
|
4157 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4158 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
|
4159 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4160 } |
|
84850
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 (_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
|
4162 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
|
4163 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
|
4164 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
|
4165 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
|
4166 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
|
4167 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
|
4168 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
|
4169 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4170 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
|
4171 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4172 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4173 *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
|
4174 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
|
4175 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
|
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 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
|
4178 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
|
4179 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
|
4180 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4181 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
|
4182 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
|
4183 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
|
4184 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
|
4185 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
|
4186 |
|
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 (_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
|
4188 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
|
4189 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
|
4190 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
|
4191 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
|
4192 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
|
4193 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
|
4194 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
|
4195 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4196 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
|
4197 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4198 } |
|
84850
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 (_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
|
4200 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
|
4201 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
|
4202 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
|
4203 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
|
4204 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
|
4205 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
|
4206 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
|
4207 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4208 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
|
4209 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
|
4210 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4211 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
|
4212 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
|
4213 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
|
4214 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
|
4215 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
|
4216 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
|
4217 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
|
4218 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
|
4219 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4220 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4221 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
|
4222 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
|
4223 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
|
4224 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
|
4225 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
|
4226 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
|
4227 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
|
4228 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
|
4229 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4230 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
|
4231 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
|
4232 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4233 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
|
4234 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4235 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4236 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
|
4237 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
|
4238 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
|
4239 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
|
4240 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
|
4241 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
|
4242 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
|
4243 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
|
4244 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4245 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4246 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
|
4247 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
|
4248 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
|
4249 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
|
4250 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
|
4251 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
|
4252 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
|
4253 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
|
4254 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4255 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
|
4256 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
|
4257 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4258 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
|
4259 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4260 } |
|
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 *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
|
4262 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
|
4263 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
|
4264 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4265 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
|
4266 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
|
4267 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
|
4268 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4269 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
|
4270 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
|
4271 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
|
4272 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
|
4273 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4274 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
|
4275 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
|
4276 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
|
4277 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
|
4278 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
|
4279 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
|
4280 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
|
4281 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
|
4282 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4283 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
|
4284 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4285 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4286 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
|
4287 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
|
4288 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
|
4289 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
|
4290 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
|
4291 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
|
4292 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
|
4293 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
|
4294 goto 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 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4296 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
|
4297 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
|
4298 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
|
4299 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
|
4300 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
|
4301 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
|
4302 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
|
4303 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
|
4304 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4305 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
|
4306 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
|
4307 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4308 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
|
4309 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4310 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4311 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
|
4312 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
|
4313 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
|
4314 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
|
4315 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
|
4316 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
|
4317 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
|
4318 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
|
4319 goto failed; |
|
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 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
|
4322 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
|
4323 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
|
4324 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
|
4325 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
|
4326 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
|
4327 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
|
4328 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
|
4329 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4330 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
|
4331 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
|
4332 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4333 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
|
4334 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
|
4335 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4336 *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
|
4337 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
|
4338 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
|
4339 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4340 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
|
4341 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
|
4342 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
|
4343 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4344 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
|
4345 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
|
4346 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
|
4347 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
|
4348 |
|
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_test)) { |
|
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 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
|
4352 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
|
4353 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
|
4354 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
|
4355 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
|
4356 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
|
4357 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4358 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
|
4359 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4360 } |
|
84850
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 (_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
|
4362 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
|
4363 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
|
4364 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
|
4365 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
|
4366 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
|
4367 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
|
4368 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
|
4369 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4370 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4371 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
|
4372 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
|
4373 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
|
4374 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
|
4375 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
|
4376 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
|
4377 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
|
4378 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
|
4379 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4380 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
|
4381 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
|
4382 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4383 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
|
4384 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
|
4385 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4386 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
|
4387 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
|
4388 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
|
4389 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
|
4390 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
|
4391 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
|
4392 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
|
4393 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
|
4394 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4395 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4396 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
|
4397 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
|
4398 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
|
4399 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
|
4400 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
|
4401 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
|
4402 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
|
4403 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
|
4404 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4405 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
|
4406 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
|
4407 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4408 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
|
4409 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
|
4410 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4411 *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
|
4412 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
|
4413 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
|
4414 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4415 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
|
4416 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
|
4417 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
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4420 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
|
4421 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
|
4422 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4423 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
|
4424 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
|
4425 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
|
4426 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
|
4427 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
|
4428 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
|
4429 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
|
4430 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
|
4431 goto 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 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4433 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
|
4434 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
|
4435 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
|
4436 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
|
4437 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
|
4438 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
|
4439 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
|
4440 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
|
4441 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4442 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
|
4443 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
|
4444 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4445 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
|
4446 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4447 } |
|
84850
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 (_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
|
4449 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
|
4450 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
|
4451 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
|
4452 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
|
4453 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
|
4454 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
|
4455 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
|
4456 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4457 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4458 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
|
4459 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
|
4460 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
|
4461 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
|
4462 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
|
4463 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
|
4464 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
|
4465 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
|
4466 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4467 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
|
4468 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
|
4469 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4470 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
|
4471 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4472 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4473 *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
|
4474 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
|
4475 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
|
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 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
|
4478 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
|
4479 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
|
4480 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4481 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
|
4482 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
|
4483 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
|
4484 |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
4485 if (exists_not_none(obj, &PyId_exc)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4486 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
|
4487 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
|
4488 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
|
4489 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
|
4490 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
|
4491 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
|
4492 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
|
4493 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4494 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
|
4495 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
4496 if (exists_not_none(obj, &PyId_cause)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4497 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
|
4498 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
|
4499 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
|
4500 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
|
4501 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
|
4502 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
|
4503 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
|
4504 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4505 cause = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4506 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4507 *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
|
4508 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
|
4509 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
|
4510 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4511 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
|
4512 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
|
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 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
|
4516 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
|
4517 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
|
4518 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
|
4519 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
|
4520 |
|
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 (_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
|
4522 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
|
4523 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
|
4524 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
|
4525 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
|
4526 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
|
4527 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
|
4528 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
|
4529 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4530 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4531 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
|
4532 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
|
4533 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
|
4534 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
|
4535 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
|
4536 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
|
4537 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
|
4538 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
|
4539 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4540 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
|
4541 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
|
4542 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4543 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
|
4544 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4545 } |
|
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 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
|
4547 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
|
4548 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
|
4549 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
|
4550 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
|
4551 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
|
4552 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
|
4553 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
|
4554 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4555 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4556 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
|
4557 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
|
4558 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
|
4559 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
|
4560 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
|
4561 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
|
4562 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
|
4563 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
|
4564 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4565 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
|
4566 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
|
4567 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4568 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
|
4569 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4570 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4571 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
|
4572 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
|
4573 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
|
4574 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
|
4575 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
|
4576 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
|
4577 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
|
4578 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
|
4579 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4580 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4581 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
|
4582 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
|
4583 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
|
4584 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
|
4585 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
|
4586 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
|
4587 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
|
4588 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
|
4589 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4590 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
|
4591 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
|
4592 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4593 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
|
4594 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4595 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4596 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
|
4597 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
|
4598 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
|
4599 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
|
4600 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
|
4601 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
|
4602 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
|
4603 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
|
4604 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4605 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4606 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
|
4607 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
|
4608 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
|
4609 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
|
4610 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
|
4611 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
|
4612 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
|
4613 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
|
4614 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4615 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
|
4616 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
|
4617 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4618 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
|
4619 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
|
4620 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4621 *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
|
4622 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 (*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
|
4624 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
|
4625 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4626 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
|
4627 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
|
4628 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
|
4629 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4630 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
|
4631 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
|
4632 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
|
4633 |
|
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 (_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
|
4635 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
|
4636 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
|
4637 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
|
4638 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
|
4639 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
|
4640 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
|
4641 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
|
4642 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4643 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
|
4644 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
|
4645 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
4646 if (exists_not_none(obj, &PyId_msg)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4647 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
|
4648 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
|
4649 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
|
4650 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
|
4651 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
|
4652 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
|
4653 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
|
4654 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4655 msg = NULL; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4656 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4657 *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
|
4658 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
|
4659 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
|
4660 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4661 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
|
4662 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
|
4663 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
|
4664 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4665 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
|
4666 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
|
4667 |
|
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 (_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
|
4669 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
|
4670 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
|
4671 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
|
4672 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
|
4673 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
|
4674 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
|
4675 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
|
4676 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4677 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4678 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
|
4679 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
|
4680 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
|
4681 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
|
4682 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
|
4683 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
|
4684 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
|
4685 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
|
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 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
|
4688 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
|
4689 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4690 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
|
4691 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4692 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4693 *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
|
4694 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
|
4695 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
|
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 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
|
4698 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
|
4699 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
|
4700 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4701 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
|
4702 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
|
4703 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
|
4704 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
|
4705 |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
4706 if (exists_not_none(obj, &PyId_module)) { |
|
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 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
|
4708 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
|
4709 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
|
4710 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
|
4711 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
|
4712 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
|
4713 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
|
4714 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4715 module = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4716 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4717 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
|
4718 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
|
4719 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
|
4720 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
|
4721 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
|
4722 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
|
4723 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
|
4724 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
|
4725 goto 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 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4727 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
|
4728 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
|
4729 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
|
4730 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
|
4731 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
|
4732 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
|
4733 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
|
4734 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
|
4735 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4736 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
|
4737 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
|
4738 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4739 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
|
4740 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4741 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
4742 if (exists_not_none(obj, &PyId_level)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4743 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
|
4744 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
|
4745 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
|
4746 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
|
4747 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
|
4748 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
|
4749 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
|
4750 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4751 level = 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4752 } |
|
84850
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 = 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
|
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*)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
|
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 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
|
4763 |
|
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 (_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
|
4765 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
|
4766 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
|
4767 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
|
4768 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
|
4769 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
|
4770 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
|
4771 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
|
4772 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4773 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4774 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
|
4775 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
|
4776 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
|
4777 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
|
4778 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
|
4779 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
|
4780 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
|
4781 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
|
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 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
|
4784 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
|
4785 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4786 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
|
4787 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4788 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4789 *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
|
4790 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
|
4791 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
|
4792 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4793 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
|
4794 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
|
4795 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
|
4796 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4797 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
|
4798 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
|
4799 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4800 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
|
4801 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
|
4802 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
|
4803 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
|
4804 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
|
4805 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
|
4806 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
|
4807 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
|
4808 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4809 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4810 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
|
4811 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
|
4812 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
|
4813 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
|
4814 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
|
4815 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
|
4816 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
|
4817 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
|
4818 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4819 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
|
4820 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
|
4821 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4822 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
|
4823 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4824 } |
|
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 *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
|
4826 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
|
4827 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
|
4828 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4829 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
|
4830 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
|
4831 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
|
4832 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4834 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
|
4835 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4836 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
|
4837 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
|
4838 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
|
4839 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
|
4840 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
|
4841 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
|
4842 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
|
4843 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
|
4844 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4845 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
|
4846 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4847 } |
|
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 *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
|
4849 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
|
4850 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
|
4851 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4852 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
|
4853 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
|
4854 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
|
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 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
|
4857 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4858 *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
|
4859 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
|
4860 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
|
4861 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4862 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
|
4863 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4864 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
|
4865 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4866 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
|
4867 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4868 *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
|
4869 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
|
4870 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
|
4871 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4872 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
|
4873 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
|
4874 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
|
4875 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4877 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4878 *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
|
4879 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
|
4880 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
|
4881 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4882 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4883 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
|
4884 failed: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4885 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
|
4886 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4887 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4888 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4889 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4890 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
|
4891 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4892 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
|
4893 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4894 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
|
4895 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
|
4896 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
|
4897 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4898 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
|
4899 *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
|
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 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
|
4903 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
|
4904 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
|
4905 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
|
4906 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
|
4907 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
|
4908 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
|
4909 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
|
4910 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4911 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
|
4912 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
|
4913 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4914 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
|
4915 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
|
4916 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
|
4917 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
|
4918 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
|
4919 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
|
4920 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
|
4921 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
|
4922 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4923 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
|
4924 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
|
4925 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4926 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
|
4927 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
|
4928 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
|
4929 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4930 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
|
4931 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
|
4932 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
|
4933 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4934 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
|
4935 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
|
4936 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
|
4937 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
|
4938 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
|
4939 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
|
4940 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
|
4941 tmp = NULL; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4942 } 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
|
4943 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
|
4944 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4945 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4946 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
|
4947 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
|
4948 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
|
4949 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
|
4950 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
|
4951 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
|
4952 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
|
4953 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
|
4954 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4955 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4956 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
|
4957 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
|
4958 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
|
4959 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
|
4960 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
|
4961 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
|
4962 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
|
4963 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
|
4964 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4965 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
|
4966 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
|
4967 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4968 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
|
4969 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4970 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4971 *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
|
4972 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
|
4973 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
|
4974 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4975 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
|
4976 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
|
4977 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
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4980 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
|
4981 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
|
4982 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
|
4983 |
|
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 (_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
|
4985 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
|
4986 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
|
4987 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
|
4988 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
|
4989 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
|
4990 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
|
4991 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
|
4992 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4993 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
|
4994 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4995 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4996 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
|
4997 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
|
4998 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
|
4999 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
|
5000 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
|
5001 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
|
5002 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
|
5003 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
|
5004 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5005 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
|
5006 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5007 } |
|
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 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
|
5009 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
|
5010 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
|
5011 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
|
5012 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
|
5013 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
|
5014 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
|
5015 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
|
5016 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5017 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
|
5018 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5019 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5020 *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
|
5021 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
|
5022 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
|
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 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
|
5025 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
|
5026 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
|
5027 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5028 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
|
5029 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
|
5030 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
|
5031 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5032 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
|
5033 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
|
5034 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
|
5035 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
|
5036 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
|
5037 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
|
5038 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
|
5039 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
|
5040 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5041 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
|
5042 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5043 } |
|
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 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
|
5045 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
|
5046 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
|
5047 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
|
5048 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
|
5049 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
|
5050 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
|
5051 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
|
5052 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5053 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
|
5054 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5055 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5056 *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
|
5057 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
|
5058 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
|
5059 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5060 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
|
5061 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
|
5062 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
|
5063 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5065 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
|
5066 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
|
5067 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5068 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
|
5069 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
|
5070 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
|
5071 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
|
5072 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
|
5073 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
|
5074 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
|
5075 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
|
5076 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5077 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
|
5078 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5079 } |
|
84850
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 (_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
|
5081 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
|
5082 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
|
5083 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
|
5084 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
|
5085 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
|
5086 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
|
5087 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
|
5088 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5089 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
|
5090 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5091 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5092 *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
|
5093 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
|
5094 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
|
5095 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5096 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
|
5097 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
|
5098 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
|
5099 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5100 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
|
5101 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
|
5102 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
|
5103 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
|
5104 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5105 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
|
5106 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
|
5107 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
|
5108 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
|
5109 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
|
5110 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
|
5111 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
|
5112 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
|
5113 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5114 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
|
5115 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5116 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5117 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
|
5118 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
|
5119 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
|
5120 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
|
5121 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
|
5122 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
|
5123 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
|
5124 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
|
5125 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5126 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
|
5127 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5128 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5129 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
|
5130 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
|
5131 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
|
5132 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
|
5133 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
|
5134 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
|
5135 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
|
5136 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
|
5137 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5138 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
|
5139 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5140 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5141 *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
|
5142 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
|
5143 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
|
5144 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5145 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
|
5146 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
|
5147 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
|
5148 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5149 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
|
5150 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
|
5151 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
|
5152 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5153 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
|
5154 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
|
5155 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
|
5156 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
|
5157 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
|
5158 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
|
5159 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
|
5160 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
|
5161 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5162 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5163 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
|
5164 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
|
5165 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
|
5166 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
|
5167 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
|
5168 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
|
5169 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
|
5170 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
|
5171 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5172 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
|
5173 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
|
5174 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5175 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
|
5176 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5177 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5178 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
|
5179 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
|
5180 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
|
5181 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
|
5182 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
|
5183 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
|
5184 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
|
5185 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
|
5186 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5187 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5188 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
|
5189 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
|
5190 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
|
5191 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
|
5192 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
|
5193 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
|
5194 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
|
5195 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
|
5196 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5197 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
|
5198 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
|
5199 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5200 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
|
5201 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5202 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5203 *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
|
5204 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
|
5205 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
|
5206 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5207 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
|
5208 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
|
5209 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
|
5210 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5211 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
|
5212 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
|
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_elts)) { |
|
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 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
|
5217 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
|
5218 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
|
5219 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
|
5220 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
|
5221 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
|
5222 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5223 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5224 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
|
5225 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
|
5226 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
|
5227 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
|
5228 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
|
5229 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
|
5230 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
|
5231 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
|
5232 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5233 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
|
5234 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
|
5235 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5236 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
|
5237 return 1; |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
5238 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5239 *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
|
5240 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
|
5241 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
|
5242 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5243 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
|
5244 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
|
5245 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
|
5246 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5247 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
|
5248 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
|
5249 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
|
5250 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5251 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
|
5252 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
|
5253 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
|
5254 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
|
5255 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
|
5256 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
|
5257 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
|
5258 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
|
5259 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5260 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
|
5261 return 1; |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
5262 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5263 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
|
5264 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
|
5265 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
|
5266 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
|
5267 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
|
5268 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
|
5269 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
|
5270 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
|
5271 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5272 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5273 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
|
5274 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
|
5275 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
|
5276 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
|
5277 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
|
5278 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
|
5279 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
|
5280 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
|
5281 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5282 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
|
5283 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
|
5284 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5285 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
|
5286 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5287 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5288 *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
|
5289 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
|
5290 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
|
5291 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5292 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
|
5293 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
|
5294 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
|
5295 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5296 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
|
5297 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
|
5298 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
|
5299 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5300 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
|
5301 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
|
5302 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
|
5303 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
|
5304 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
|
5305 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
|
5306 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
|
5307 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
|
5308 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5309 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
|
5310 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5311 } |
|
84850
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 (_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
|
5313 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
|
5314 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
|
5315 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
|
5316 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
|
5317 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
|
5318 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
|
5319 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
|
5320 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5321 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5322 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
|
5323 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
|
5324 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
|
5325 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
|
5326 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
|
5327 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
|
5328 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
|
5329 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
|
5330 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5331 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
|
5332 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
|
5333 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5334 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
|
5335 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
|
5336 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5337 *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
|
5338 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
|
5339 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
|
5340 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5341 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
|
5342 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
|
5343 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
|
5344 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5345 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
|
5346 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
|
5347 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
|
5348 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
|
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 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
|
5351 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
|
5352 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
|
5353 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
|
5354 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
|
5355 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
|
5356 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
|
5357 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
|
5358 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5359 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
|
5360 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5361 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5362 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
|
5363 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
|
5364 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
|
5365 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
|
5366 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
|
5367 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
|
5368 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
|
5369 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
|
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 \"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
|
5372 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
|
5373 } |
|
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_generators)) { |
|
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_generators); |
|
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, "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
|
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 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
|
5386 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
|
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 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
|
5389 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
|
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(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
|
5392 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5393 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
|
5394 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
|
5395 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5396 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
|
5397 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
|
5398 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5399 *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
|
5400 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
|
5401 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
|
5402 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5403 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
|
5404 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
|
5405 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
|
5406 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5407 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
|
5408 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
|
5409 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
|
5410 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5411 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
|
5412 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
|
5413 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
|
5414 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
|
5415 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
|
5416 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
|
5417 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
|
5418 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
|
5419 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5420 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
|
5421 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5422 } |
|
84850
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 (_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
|
5424 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
|
5425 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
|
5426 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
|
5427 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
|
5428 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
|
5429 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
|
5430 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
|
5431 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5432 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5433 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
|
5434 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
|
5435 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
|
5436 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
|
5437 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
|
5438 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
|
5439 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
|
5440 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
|
5441 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5442 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
|
5443 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
|
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 \"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
|
5446 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
|
5447 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5448 *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
|
5449 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
|
5450 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
|
5451 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5452 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
|
5453 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
|
5454 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
|
5455 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5456 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
|
5457 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
|
5458 |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5459 if (exists_not_none(obj, &PyId_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
|
5460 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
|
5461 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
|
5462 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
|
5463 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
|
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 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
|
5466 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
|
5467 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5468 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
|
5469 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5470 *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
|
5471 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
|
5472 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
|
5473 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5474 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
|
5475 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
|
5476 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
|
5477 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5479 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
|
5480 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5481 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
|
5482 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
|
5483 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
|
5484 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
|
5485 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
|
5486 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
|
5487 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
|
5488 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
|
5489 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5490 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
|
5491 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
|
5492 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5493 *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
|
5494 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
|
5495 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
|
5496 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5497 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
|
5498 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
|
5499 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
|
5500 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5502 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
|
5503 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
|
5504 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
|
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_left)) { |
|
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_left); |
|
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, &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
|
5511 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
|
5512 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
|
5513 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
|
5514 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5515 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
|
5516 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5517 } |
|
84850
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 (_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
|
5519 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
|
5520 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
|
5521 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
|
5522 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
|
5523 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
|
5524 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
|
5525 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
|
5526 goto failed; |
|
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 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
|
5529 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
|
5530 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
|
5531 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
|
5532 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
|
5533 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
|
5534 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
|
5535 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
|
5536 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5537 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
|
5538 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
|
5539 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5540 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
|
5541 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5542 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5543 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
|
5544 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
|
5545 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
|
5546 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
|
5547 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
|
5548 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
|
5549 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
|
5550 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
|
5551 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5552 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5553 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
|
5554 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
|
5555 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
|
5556 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
|
5557 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
|
5558 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
|
5559 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
|
5560 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
|
5561 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5562 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
|
5563 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
|
5564 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5565 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
|
5566 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5567 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5568 *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
|
5569 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
|
5570 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
|
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 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
|
5573 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
|
5574 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
|
5575 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5576 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
|
5577 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
|
5578 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
|
5579 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
|
5580 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
|
5581 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
|
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 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
|
5584 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
|
5585 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
|
5586 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
|
5587 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
|
5588 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
|
5589 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
|
5590 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
|
5591 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5592 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
|
5593 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5594 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5595 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
|
5596 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
|
5597 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
|
5598 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
|
5599 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
|
5600 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
|
5601 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
|
5602 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
|
5603 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5604 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5605 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
|
5606 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
|
5607 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
|
5608 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
|
5609 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
|
5610 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
|
5611 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
|
5612 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
|
5613 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5614 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
|
5615 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
|
5616 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5617 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
|
5618 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5619 } |
|
84850
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 (_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
|
5621 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
|
5622 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
|
5623 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
|
5624 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
|
5625 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
|
5626 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
|
5627 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
|
5628 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5629 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5630 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
|
5631 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
|
5632 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
|
5633 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
|
5634 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
|
5635 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
|
5636 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
|
5637 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
|
5638 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5639 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
|
5640 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
|
5641 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5642 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
|
5643 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
|
5644 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5645 if (exists_not_none(obj, &PyId_starargs)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5646 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
|
5647 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
|
5648 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
|
5649 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
|
5650 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
|
5651 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
|
5652 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
|
5653 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5654 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
|
5655 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5656 if (exists_not_none(obj, &PyId_kwargs)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5657 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
|
5658 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
|
5659 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
|
5660 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
|
5661 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
|
5662 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
|
5663 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
|
5664 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5665 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
|
5666 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5667 *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
|
5668 arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5669 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
|
5670 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
|
5671 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5672 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
|
5673 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
|
5674 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
|
5675 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5676 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
|
5677 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
|
5678 |
|
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 (_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
|
5680 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
|
5681 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
|
5682 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
|
5683 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
|
5684 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
|
5685 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
|
5686 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
|
5687 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5688 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
|
5689 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5690 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5691 *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
|
5692 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
|
5693 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
|
5694 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5695 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
|
5696 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
|
5697 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
|
5698 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5699 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
|
5700 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
|
5701 |
|
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 (_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
|
5703 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
|
5704 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
|
5705 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
|
5706 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
|
5707 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
|
5708 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
|
5709 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
|
5710 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5711 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
|
5712 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5713 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5714 *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
|
5715 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
|
5716 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
|
5717 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5718 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
|
5719 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
|
5720 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
|
5721 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5722 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
|
5723 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
|
5724 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5725 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
|
5726 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
|
5727 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
|
5728 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
|
5729 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
|
5730 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
|
5731 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
|
5732 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
|
5733 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5734 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
|
5735 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
|
5736 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5737 *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
|
5738 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
|
5739 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
|
5740 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5741 isinstance = PyObject_IsInstance(obj, (PyObject*)NameConstant_type); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5742 if (isinstance == -1) { |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5743 return 1; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5744 } |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5745 if (isinstance) { |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5746 singleton value; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5747 |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5748 if (_PyObject_HasAttrId(obj, &PyId_value)) { |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5749 int res; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5750 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5751 if (tmp == NULL) goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5752 res = obj2ast_singleton(tmp, &value, arena); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5753 if (res != 0) goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5754 Py_XDECREF(tmp); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5755 tmp = NULL; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5756 } else { |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5757 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NameConstant"); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5758 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5759 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5760 *out = NameConstant(value, lineno, col_offset, arena); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5761 if (*out == NULL) goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5762 return 0; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
5763 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5764 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
|
5765 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
|
5766 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
|
5767 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5768 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
|
5769 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5770 *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
|
5771 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
|
5772 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
|
5773 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5774 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
|
5775 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
|
5776 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
|
5777 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5778 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
|
5779 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
|
5780 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
|
5781 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
|
5782 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5783 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
|
5784 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
|
5785 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
|
5786 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
|
5787 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
|
5788 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
|
5789 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
|
5790 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
|
5791 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5792 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
|
5793 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5794 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5795 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
|
5796 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
|
5797 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
|
5798 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
|
5799 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
|
5800 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
|
5801 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
|
5802 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
|
5803 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5804 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
|
5805 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
|
5806 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5807 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
|
5808 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
|
5809 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
|
5810 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
|
5811 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
|
5812 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
|
5813 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
|
5814 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
|
5815 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5816 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
|
5817 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5818 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5819 *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
|
5820 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
|
5821 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
|
5822 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5823 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
|
5824 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
|
5825 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
|
5826 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5827 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
|
5828 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
|
5829 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
|
5830 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
|
5831 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5832 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
|
5833 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
|
5834 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
|
5835 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
|
5836 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
|
5837 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
|
5838 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
|
5839 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
|
5840 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5841 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
|
5842 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
|
5843 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5844 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
|
5845 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
|
5846 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
|
5847 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
|
5848 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
|
5849 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
|
5850 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
|
5851 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
|
5852 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5853 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
|
5854 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
|
5855 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5856 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
|
5857 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
|
5858 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
|
5859 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
|
5860 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
|
5861 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
|
5862 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
|
5863 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
|
5864 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5865 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
|
5866 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5867 } |
|
84850
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 = 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
|
5869 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
|
5870 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
|
5871 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5872 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
|
5873 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
|
5874 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
|
5875 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5876 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
|
5877 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
|
5878 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
|
5879 |
|
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 (_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
|
5881 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
|
5882 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
|
5883 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
|
5884 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
|
5885 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
|
5886 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
|
5887 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
|
5888 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5889 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
|
5890 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
|
5891 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5892 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
|
5893 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
|
5894 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
|
5895 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
|
5896 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
|
5897 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
|
5898 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
|
5899 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
|
5900 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5901 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
|
5902 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5903 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5904 *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
|
5905 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
|
5906 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
|
5907 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5908 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
|
5909 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
|
5910 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
|
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 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
|
5913 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
|
5914 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
|
5915 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5916 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
|
5917 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
|
5918 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
|
5919 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
|
5920 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
|
5921 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
|
5922 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
|
5923 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
|
5924 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5925 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
|
5926 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5927 } |
|
84850
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 (_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
|
5929 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
|
5930 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
|
5931 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
|
5932 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
|
5933 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
|
5934 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
|
5935 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
|
5936 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5937 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
|
5938 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
|
5939 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5940 *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
|
5941 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
|
5942 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
|
5943 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5944 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
|
5945 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
|
5946 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
|
5947 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5948 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
|
5949 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
|
5950 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
|
5951 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5952 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
|
5953 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
|
5954 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
|
5955 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
|
5956 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
|
5957 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
|
5958 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
|
5959 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
|
5960 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5961 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5962 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
|
5963 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
|
5964 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
|
5965 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
|
5966 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
|
5967 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
|
5968 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
|
5969 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
|
5970 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5971 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
|
5972 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
|
5973 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5974 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
|
5975 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5976 } |
|
84850
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_ctx)) { |
|
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 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
|
5980 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
|
5981 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
|
5982 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
|
5983 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
|
5984 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
|
5985 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5986 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
|
5987 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5988 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5989 *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
|
5990 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
|
5991 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
|
5992 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5993 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
|
5994 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
|
5995 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
|
5996 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5997 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
|
5998 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
|
5999 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
|
6000 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6001 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
|
6002 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
|
6003 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
|
6004 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
|
6005 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
|
6006 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
|
6007 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
|
6008 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
|
6009 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6010 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6011 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
|
6012 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
|
6013 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
|
6014 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
|
6015 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
|
6016 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
|
6017 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
|
6018 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
|
6019 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6020 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
|
6021 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
|
6022 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6023 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
|
6024 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6025 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6026 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
|
6027 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
|
6028 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
|
6029 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
|
6030 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
|
6031 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
|
6032 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
|
6033 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
|
6034 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6035 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
|
6036 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6037 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6038 *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
|
6039 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
|
6040 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
|
6041 } |
|
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 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
|
6044 failed: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6045 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
|
6046 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6047 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6048 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6049 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6050 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
|
6051 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6052 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
|
6053 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6054 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
|
6055 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
|
6056 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
|
6057 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6058 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
|
6059 *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
|
6060 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
|
6061 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6062 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
|
6063 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
|
6064 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
|
6065 } |
|
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) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6067 *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
|
6068 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
|
6069 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6070 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
|
6071 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6072 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
|
6073 } |
|
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) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6075 *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
|
6076 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
|
6077 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6078 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
|
6079 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
|
6080 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
|
6081 } |
|
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) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6083 *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
|
6084 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
|
6085 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6086 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
|
6087 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
|
6088 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
|
6089 } |
|
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) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6091 *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
|
6092 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
|
6093 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6094 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
|
6095 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
|
6096 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
|
6097 } |
|
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) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6099 *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
|
6100 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
|
6101 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6102 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6103 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
|
6104 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6105 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6106 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6107 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6108 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
|
6109 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6110 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
|
6111 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6112 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
|
6113 |
|
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 (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
|
6115 *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
|
6116 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
|
6117 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6118 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
|
6119 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
|
6120 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
|
6121 } |
|
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) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6123 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
|
6124 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
|
6125 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
|
6126 |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6127 if (exists_not_none(obj, &PyId_lower)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6128 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
|
6129 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
|
6130 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
|
6131 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
|
6132 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
|
6133 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
|
6134 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
|
6135 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6136 lower = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6137 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6138 if (exists_not_none(obj, &PyId_upper)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6139 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
|
6140 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
|
6141 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
|
6142 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
|
6143 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
|
6144 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
|
6145 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
|
6146 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6147 upper = NULL; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6148 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6149 if (exists_not_none(obj, &PyId_step)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6150 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
|
6151 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
|
6152 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
|
6153 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
|
6154 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
|
6155 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
|
6156 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
|
6157 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6158 step = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6159 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6160 *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
|
6161 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
|
6162 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
|
6163 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6164 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
|
6165 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
|
6166 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
|
6167 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6168 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
|
6169 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
|
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 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
|
6172 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
|
6173 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
|
6174 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
|
6175 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
|
6176 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
|
6177 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
|
6178 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
|
6179 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6180 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6181 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
|
6182 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
|
6183 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
|
6184 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
|
6185 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
|
6186 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
|
6187 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
|
6188 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
|
6189 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6190 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
|
6191 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
|
6192 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6193 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
|
6194 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6195 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6196 *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
|
6197 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
|
6198 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
|
6199 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6200 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
|
6201 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
|
6202 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
|
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 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
|
6205 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
|
6206 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6207 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
|
6208 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
|
6209 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
|
6210 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
|
6211 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
|
6212 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
|
6213 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
|
6214 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
|
6215 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6216 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
|
6217 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6218 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6219 *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
|
6220 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
|
6221 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
|
6222 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6223 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6224 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
|
6225 failed: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6226 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
|
6227 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6228 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6229 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6230 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6231 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
|
6232 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6233 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
|
6234 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6235 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
|
6236 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6237 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
|
6238 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6239 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
|
6240 *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
|
6241 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
|
6242 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6243 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
|
6244 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
|
6245 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
|
6246 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6247 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
|
6248 *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
|
6249 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
|
6250 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6251 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6252 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
|
6253 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6254 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6255 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6256 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6257 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
|
6258 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6259 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
|
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 *)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
|
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 = Add; |
|
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 *)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
|
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 = Sub; |
|
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 *)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
|
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 = Mult; |
|
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 *)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
|
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 = Div; |
|
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 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
|
6294 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
|
6295 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
|
6296 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6297 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
|
6298 *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
|
6299 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
|
6300 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6301 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
|
6302 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6303 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
|
6304 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6305 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
|
6306 *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
|
6307 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
|
6308 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6309 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
|
6310 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
|
6311 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
|
6312 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6313 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
|
6314 *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
|
6315 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
|
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 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
|
6318 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
|
6319 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
|
6320 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6321 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
|
6322 *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
|
6323 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
|
6324 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6325 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
|
6326 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
|
6327 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
|
6328 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6329 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
|
6330 *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
|
6331 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
|
6332 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6333 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
|
6334 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
|
6335 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
|
6336 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6337 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
|
6338 *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
|
6339 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
|
6340 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6341 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
|
6342 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
|
6343 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
|
6344 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6345 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
|
6346 *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
|
6347 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
|
6348 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6349 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
|
6350 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
|
6351 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
|
6352 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6353 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
|
6354 *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
|
6355 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
|
6356 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6357 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6358 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
|
6359 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6360 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6361 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6362 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6363 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
|
6364 { |
|
84850
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 isinstance; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6366 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6367 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
|
6368 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
|
6369 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
|
6370 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6371 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
|
6372 *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
|
6373 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
|
6374 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6375 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
|
6376 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6377 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
|
6378 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6379 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
|
6380 *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
|
6381 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
|
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 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
|
6384 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
|
6385 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
|
6386 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6387 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
|
6388 *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
|
6389 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
|
6390 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6391 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
|
6392 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
|
6393 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
|
6394 } |
|
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) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6396 *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
|
6397 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
|
6398 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6399 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6400 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
|
6401 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6402 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6403 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6404 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6405 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
|
6406 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6407 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
|
6408 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6409 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
|
6410 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
|
6411 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
|
6412 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6414 *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
|
6415 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
|
6416 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6417 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
|
6418 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
|
6419 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
|
6420 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6421 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
|
6422 *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
|
6423 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
|
6424 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6425 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
|
6426 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
|
6427 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
|
6428 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6430 *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
|
6431 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
|
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 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
|
6434 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
|
6435 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
|
6436 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6437 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
|
6438 *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
|
6439 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
|
6440 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6441 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
|
6442 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6443 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
|
6444 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6445 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
|
6446 *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
|
6447 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
|
6448 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6449 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
|
6450 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
|
6451 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
|
6452 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6453 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
|
6454 *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
|
6455 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
|
6456 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6457 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
|
6458 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
|
6459 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
|
6460 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6461 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
|
6462 *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
|
6463 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
|
6464 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6465 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
|
6466 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
|
6467 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
|
6468 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6469 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
|
6470 *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
|
6471 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
|
6472 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6473 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
|
6474 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
|
6475 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
|
6476 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6478 *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
|
6479 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
|
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 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
|
6482 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
|
6483 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
|
6484 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6485 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
|
6486 *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
|
6487 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
|
6488 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6489 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6490 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
|
6491 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6492 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6493 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6494 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6495 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
|
6496 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6497 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
|
6498 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
|
6499 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
|
6500 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
|
6501 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6502 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
|
6503 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
|
6504 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
|
6505 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
|
6506 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
|
6507 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
|
6508 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
|
6509 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
|
6510 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6511 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
|
6512 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
|
6513 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6514 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
|
6515 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
|
6516 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
|
6517 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
|
6518 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
|
6519 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
|
6520 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
|
6521 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
|
6522 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6523 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
|
6524 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
|
6525 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6526 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
|
6527 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
|
6528 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
|
6529 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
|
6530 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
|
6531 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
|
6532 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
|
6533 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
|
6534 goto failed; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6535 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6536 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
|
6537 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
|
6538 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
|
6539 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
|
6540 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
|
6541 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
|
6542 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
|
6543 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
|
6544 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6545 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
|
6546 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
|
6547 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6548 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
|
6549 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
|
6550 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6551 *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
|
6552 return 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6553 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
|
6554 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
|
6555 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6556 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6557 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6558 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6559 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
|
6560 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6561 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
|
6562 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6563 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
|
6564 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
|
6565 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
|
6566 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6567 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
|
6568 *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
|
6569 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
|
6570 } |
|
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 (_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
|
6572 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
|
6573 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
|
6574 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
|
6575 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
|
6576 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
|
6577 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
|
6578 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
|
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 \"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
|
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_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
|
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 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
|
6586 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
|
6587 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
|
6588 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
|
6589 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
|
6590 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
|
6591 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6592 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
|
6593 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
|
6594 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6595 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
|
6596 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
|
6597 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
|
6598 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6600 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
|
6601 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
|
6602 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
|
6603 |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6604 if (exists_not_none(obj, &PyId_type)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6605 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
|
6606 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
|
6607 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
|
6608 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
|
6609 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
|
6610 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
|
6611 tmp = NULL; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6612 } 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
|
6613 type = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6614 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6615 if (exists_not_none(obj, &PyId_name)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6616 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
|
6617 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
|
6618 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
|
6619 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
|
6620 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
|
6621 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
|
6622 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
|
6623 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6624 name = NULL; |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
6625 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6626 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
|
6627 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
|
6628 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
|
6629 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
|
6630 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
|
6631 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
|
6632 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
|
6633 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
|
6634 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6635 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6636 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
|
6637 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
|
6638 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
|
6639 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
|
6640 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
|
6641 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
|
6642 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
|
6643 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
|
6644 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6645 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
|
6646 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
|
6647 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6648 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
|
6649 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
|
6650 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6651 *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
|
6652 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
|
6653 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
|
6654 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6655 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6656 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
|
6657 failed: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6658 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
|
6659 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6660 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6661 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6662 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6663 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
|
6664 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6665 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
|
6666 asdl_seq* args; |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6667 arg_ty vararg; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6668 asdl_seq* kwonlyargs; |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6669 asdl_seq* kw_defaults; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6670 arg_ty kwarg; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6671 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
|
6672 |
|
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 (_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
|
6674 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
|
6675 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
|
6676 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
|
6677 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
|
6678 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
|
6679 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
|
6680 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
|
6681 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6682 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6683 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
|
6684 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
|
6685 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
|
6686 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
|
6687 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
|
6688 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
|
6689 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
|
6690 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
|
6691 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6692 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
|
6693 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
|
6694 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6695 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
|
6696 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
|
6697 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6698 if (exists_not_none(obj, &PyId_vararg)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6699 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
|
6700 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
|
6701 if (tmp == NULL) goto failed; |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6702 res = obj2ast_arg(tmp, &vararg, arena); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6703 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
|
6704 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
|
6705 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
|
6706 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6707 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
|
6708 } |
|
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 (_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
|
6710 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
|
6711 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
|
6712 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
|
6713 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
|
6714 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
|
6715 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
|
6716 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
|
6717 goto failed; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6718 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6719 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
|
6720 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
|
6721 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
|
6722 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
|
6723 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
|
6724 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
|
6725 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
|
6726 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
|
6727 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6728 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
|
6729 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
|
6730 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6731 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
|
6732 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
|
6733 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6734 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
|
6735 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
|
6736 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
|
6737 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
|
6738 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
|
6739 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
|
6740 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
|
6741 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
|
6742 goto failed; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6743 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6744 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
|
6745 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
|
6746 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
|
6747 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
|
6748 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
|
6749 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
|
6750 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
|
6751 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
|
6752 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6753 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
|
6754 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
|
6755 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6756 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
|
6757 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
|
6758 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6759 if (exists_not_none(obj, &PyId_kwarg)) { |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6760 int res; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6761 tmp = _PyObject_GetAttrId(obj, &PyId_kwarg); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6762 if (tmp == NULL) goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6763 res = obj2ast_arg(tmp, &kwarg, arena); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6764 if (res != 0) goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6765 Py_XDECREF(tmp); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6766 tmp = NULL; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6767 } else { |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6768 kwarg = NULL; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6769 } |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6770 if (_PyObject_HasAttrId(obj, &PyId_defaults)) { |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6771 int res; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6772 Py_ssize_t len; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6773 Py_ssize_t i; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6774 tmp = _PyObject_GetAttrId(obj, &PyId_defaults); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6775 if (tmp == NULL) goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6776 if (!PyList_Check(tmp)) { |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6777 PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6778 goto failed; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6779 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6780 len = PyList_GET_SIZE(tmp); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6781 defaults = asdl_seq_new(len, arena); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6782 if (defaults == NULL) goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6783 for (i = 0; i < len; i++) { |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6784 expr_ty value; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6785 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6786 if (res != 0) goto failed; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6787 asdl_seq_SET(defaults, i, value); |
|
82732
7c5c678e4164
unify some ast.argument's attrs; change Attribute column offset (closes #16795)
Benjamin Peterson <benjamin@python.org>
parents:
81039
diff
changeset
|
6788 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6789 Py_XDECREF(tmp); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6790 tmp = NULL; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6791 } else { |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6792 PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments"); |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6793 return 1; |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6794 } |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6795 *out = arguments(args, vararg, kwonlyargs, kw_defaults, kwarg, defaults, |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6796 arena); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6797 return 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6798 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
|
6799 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
|
6800 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6801 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6802 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6803 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6804 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
|
6805 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6806 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
|
6807 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
|
6808 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
|
6809 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6810 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
|
6811 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
|
6812 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
|
6813 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
|
6814 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
|
6815 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
|
6816 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
|
6817 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
|
6818 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6819 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
|
6820 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
|
6821 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6822 if (exists_not_none(obj, &PyId_annotation)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6823 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
|
6824 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
|
6825 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
|
6826 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
|
6827 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
|
6828 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
|
6829 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
|
6830 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6831 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
|
6832 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6833 *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
|
6834 return 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6835 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
|
6836 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
|
6837 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6838 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6839 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6840 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6841 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
|
6842 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6843 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
|
6844 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
|
6845 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
|
6846 |
|
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 (_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
|
6848 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
|
6849 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
|
6850 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
|
6851 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
|
6852 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
|
6853 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
|
6854 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
|
6855 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6856 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
|
6857 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
|
6858 } |
|
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 (_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
|
6860 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
|
6861 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
|
6862 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
|
6863 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
|
6864 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
|
6865 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
|
6866 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
|
6867 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6868 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
|
6869 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
|
6870 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6871 *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
|
6872 return 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6873 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
|
6874 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
|
6875 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6876 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6877 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6878 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6879 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
|
6880 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6881 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
|
6882 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
|
6883 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
|
6884 |
|
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 (_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
|
6886 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
|
6887 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
|
6888 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
|
6889 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
|
6890 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
|
6891 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
|
6892 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
|
6893 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6894 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
|
6895 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
|
6896 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6897 if (exists_not_none(obj, &PyId_asname)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6898 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
|
6899 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
|
6900 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
|
6901 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
|
6902 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
|
6903 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
|
6904 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
|
6905 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6906 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
|
6907 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6908 *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
|
6909 return 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6910 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
|
6911 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
|
6912 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6913 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6914 |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
6915 int |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
6916 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
|
6917 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6918 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
|
6919 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
|
6920 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
|
6921 |
|
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 (_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
|
6923 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
|
6924 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
|
6925 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
|
6926 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
|
6927 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
|
6928 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
|
6929 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
|
6930 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6931 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
|
6932 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
|
6933 } |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6934 if (exists_not_none(obj, &PyId_optional_vars)) { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6935 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
|
6936 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
|
6937 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
|
6938 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
|
6939 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
|
6940 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
|
6941 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
|
6942 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6943 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
|
6944 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6945 *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
|
6946 return 0; |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
6947 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
|
6948 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
|
6949 return 1; |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
6950 } |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
6951 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6952 |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
47301
diff
changeset
|
6953 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
|
6954 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
|
6955 }; |
| 36669 | 6956 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
|
6957 PyInit__ast(void) |
| 36669 | 6958 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6959 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
|
6960 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
|
6961 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
|
6962 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
|
6963 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
|
6964 if (PyDict_SetItemString(d, "AST", (PyObject*)&AST_type) < 0) return NULL; |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
6965 if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0) |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6966 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
|
6967 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
|
6968 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
|
6969 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6970 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
|
6971 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
|
6972 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
|
6973 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
|
6974 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
|
6975 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6976 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
|
6977 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
|
6978 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
|
6979 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
|
6980 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
|
6981 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
|
6982 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6983 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
|
6984 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6985 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
|
6986 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6987 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
|
6988 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
|
6989 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
|
6990 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
|
6991 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6992 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
|
6993 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
|
6994 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
|
6995 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6996 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
|
6997 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
|
6998 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6999 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
|
7000 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7001 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
|
7002 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
|
7003 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
|
7004 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7005 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
|
7006 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
|
7007 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
|
7008 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
|
7009 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
|
7010 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7011 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
|
7012 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
|
7013 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
|
7014 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
|
7015 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7016 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
|
7017 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7018 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
|
7019 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7020 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
|
7021 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7022 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
|
7023 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7024 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
|
7025 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
|
7026 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
|
7027 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
|
7028 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
|
7029 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7030 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
|
7031 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
|
7032 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
|
7033 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
|
7034 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
|
7035 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7036 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
|
7037 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
|
7038 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
|
7039 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7040 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
|
7041 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
|
7042 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
|
7043 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
|
7044 NULL; |
|
84851
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
7045 if (PyDict_SetItemString(d, "NameConstant", (PyObject*)NameConstant_type) < |
|
1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
diff
changeset
|
7046 0) return NULL; |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7047 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
|
7048 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
|
7049 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
|
7050 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
|
7051 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
|
7052 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
|
7053 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
|
7054 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7055 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
|
7056 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
|
7057 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
|
7058 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7059 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
|
7060 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
|
7061 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
|
7062 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
|
7063 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7064 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
|
7065 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
|
7066 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7067 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
|
7068 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
|
7069 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
|
7070 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7071 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
|
7072 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7073 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
|
7074 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7075 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
|
7076 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
|
7077 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
|
7078 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7079 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
|
7080 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7081 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
|
7082 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
|
7083 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
|
7084 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
|
7085 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
|
7086 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
|
7087 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
|
7088 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
|
7089 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
|
7090 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
|
7091 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
|
7092 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7093 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
|
7094 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7095 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
|
7096 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7097 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
|
7098 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7099 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
|
7100 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7101 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
|
7102 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
|
7103 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
|
7104 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7105 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
|
7106 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7107 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
|
7108 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
|
7109 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
|
7110 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
|
7111 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7112 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
|
7113 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
|
7114 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7115 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
|
7116 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
|
7117 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
|
7118 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
|
7119 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
|
7120 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
|
7121 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7122 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
|
7123 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
|
7124 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7125 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
|
7126 < 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
|
7127 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
|
7128 < 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
|
7129 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
|
7130 < 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
|
7131 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
|
7132 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
|
7133 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
|
7134 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
|
7135 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7136 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
|
7137 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
7138 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
|
7139 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
|
7140 return m; |
| 36669 | 7141 } |
| 7142 | |
| 35742 | 7143 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
7144 PyObject* PyAST_mod2obj(mod_ty t) |
| 35742 | 7145 { |
|
84679
cf8f42eadbd0
Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError)
Victor Stinner <victor.stinner@gmail.com>
parents:
83867
diff
changeset
|
7146 if (!init_types()) |
|
cf8f42eadbd0
Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError)
Victor Stinner <victor.stinner@gmail.com>
parents:
83867
diff
changeset
|
7147 return NULL; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
7148 return ast2obj_mod(t); |
| 35742 | 7149 } |
|
42013
cd125fe83051
Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents:
41825
diff
changeset
|
7150 |
|
46227
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
7151 /* 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
|
7152 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
|
7153 { |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
7154 mod_ty res; |
|
46227
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
7155 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
|
7156 (PyObject*)Interactive_type}; |
|
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
7157 char *req_name[] = {"Module", "Expression", "Interactive"}; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
7158 int isinstance; |
|
46227
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
7159 assert(0 <= mode && mode <= 2); |
|
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
7160 |
|
84679
cf8f42eadbd0
Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError)
Victor Stinner <victor.stinner@gmail.com>
parents:
83867
diff
changeset
|
7161 if (!init_types()) |
|
cf8f42eadbd0
Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError)
Victor Stinner <victor.stinner@gmail.com>
parents:
83867
diff
changeset
|
7162 return NULL; |
|
46227
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
7163 |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
7164 isinstance = PyObject_IsInstance(ast, req_type[mode]); |
|
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
7165 if (isinstance == -1) |
|
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
7166 return NULL; |
|
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
7167 if (!isinstance) { |
|
46227
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
7168 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
|
7169 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
|
7170 return NULL; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
7171 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
7172 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
|
7173 return NULL; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
7174 else |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
7175 return res; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
7176 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
7177 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
7178 int PyAST_Check(PyObject* obj) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
7179 { |
|
84679
cf8f42eadbd0
Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError)
Victor Stinner <victor.stinner@gmail.com>
parents:
83867
diff
changeset
|
7180 if (!init_types()) |
|
cf8f42eadbd0
Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError)
Victor Stinner <victor.stinner@gmail.com>
parents:
83867
diff
changeset
|
7181 return -1; |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
7182 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
|
7183 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
7184 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
7185 |
