Mercurial > cpython-lru_cache-weakref
annotate Python/Python-ast.c @ 84855:65121aa79ab3 3.3
Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
| author | Christian Heimes <christian@cheimes.de> |
|---|---|
| date | Sat, 27 Jul 2013 00:33:13 +0200 |
| parents | d14f40c87438 |
| children | ad90fc28769a |
| rev | line source |
|---|---|
|
40893
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40819
diff
changeset
|
1 /* File automatically generated by Parser/asdl_c.py. */ |
|
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40819
diff
changeset
|
2 |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
3 #include <stddef.h> |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
4 |
| 35742 | 5 #include "Python.h" |
| 6 #include "Python-ast.h" | |
| 7 | |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
8 static PyTypeObject AST_type; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
9 static PyTypeObject *mod_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
10 static PyObject* ast2obj_mod(void*); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
11 static PyTypeObject *Module_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
12 _Py_IDENTIFIER(body); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
13 static char *Module_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
14 "body", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
15 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
16 static PyTypeObject *Interactive_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
17 static char *Interactive_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
18 "body", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
19 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
20 static PyTypeObject *Expression_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
21 static char *Expression_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
22 "body", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
23 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
24 static PyTypeObject *Suite_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
25 static char *Suite_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
26 "body", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
27 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
28 static PyTypeObject *stmt_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
29 _Py_IDENTIFIER(lineno); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
30 _Py_IDENTIFIER(col_offset); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
31 static char *stmt_attributes[] = { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
32 "lineno", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
33 "col_offset", |
| 36669 | 34 }; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
35 static PyObject* ast2obj_stmt(void*); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
36 static PyTypeObject *FunctionDef_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
37 _Py_IDENTIFIER(name); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
38 _Py_IDENTIFIER(args); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
39 _Py_IDENTIFIER(decorator_list); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
40 _Py_IDENTIFIER(returns); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
41 static char *FunctionDef_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
42 "name", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
43 "args", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
44 "body", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
45 "decorator_list", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
46 "returns", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
47 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
48 static PyTypeObject *ClassDef_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
49 _Py_IDENTIFIER(bases); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
50 _Py_IDENTIFIER(keywords); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
51 _Py_IDENTIFIER(starargs); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
52 _Py_IDENTIFIER(kwargs); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
53 static char *ClassDef_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
54 "name", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
55 "bases", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
56 "keywords", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
57 "starargs", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
58 "kwargs", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
59 "body", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
60 "decorator_list", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
61 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
62 static PyTypeObject *Return_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
63 _Py_IDENTIFIER(value); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
64 static char *Return_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
65 "value", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
66 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
67 static PyTypeObject *Delete_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
68 _Py_IDENTIFIER(targets); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
69 static char *Delete_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
70 "targets", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
71 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
72 static PyTypeObject *Assign_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
73 static char *Assign_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
74 "targets", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
75 "value", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
76 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
77 static PyTypeObject *AugAssign_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
78 _Py_IDENTIFIER(target); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
79 _Py_IDENTIFIER(op); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
80 static char *AugAssign_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
81 "target", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
82 "op", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
83 "value", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
84 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
85 static PyTypeObject *For_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
86 _Py_IDENTIFIER(iter); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
87 _Py_IDENTIFIER(orelse); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
88 static char *For_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
89 "target", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
90 "iter", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
91 "body", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
92 "orelse", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
93 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
94 static PyTypeObject *While_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
95 _Py_IDENTIFIER(test); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
96 static char *While_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
97 "test", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
98 "body", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
99 "orelse", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
100 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
101 static PyTypeObject *If_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
102 static char *If_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
103 "test", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
104 "body", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
105 "orelse", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
106 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
107 static PyTypeObject *With_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
108 _Py_IDENTIFIER(items); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
109 static char *With_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
110 "items", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
111 "body", |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
112 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
113 static PyTypeObject *Raise_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
114 _Py_IDENTIFIER(exc); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
115 _Py_IDENTIFIER(cause); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
116 static char *Raise_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
117 "exc", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
118 "cause", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
119 }; |
|
70499
e0e663132363
unify TryExcept and TryFinally (closes #12199)
Benjamin Peterson <benjamin@python.org>
parents:
70439
diff
changeset
|
120 static PyTypeObject *Try_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
121 _Py_IDENTIFIER(handlers); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
122 _Py_IDENTIFIER(finalbody); |
|
70499
e0e663132363
unify TryExcept and TryFinally (closes #12199)
Benjamin Peterson <benjamin@python.org>
parents:
70439
diff
changeset
|
123 static char *Try_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
124 "body", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
125 "handlers", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
126 "orelse", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
127 "finalbody", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
128 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
129 static PyTypeObject *Assert_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
130 _Py_IDENTIFIER(msg); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
131 static char *Assert_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
132 "test", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
133 "msg", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
134 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
135 static PyTypeObject *Import_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
136 _Py_IDENTIFIER(names); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
137 static char *Import_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
138 "names", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
139 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
140 static PyTypeObject *ImportFrom_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
141 _Py_IDENTIFIER(module); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
142 _Py_IDENTIFIER(level); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
143 static char *ImportFrom_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
144 "module", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
145 "names", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
146 "level", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
147 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
148 static PyTypeObject *Global_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
149 static char *Global_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
150 "names", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
151 }; |
|
40965
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
152 static PyTypeObject *Nonlocal_type; |
|
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
153 static char *Nonlocal_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
154 "names", |
|
40965
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
155 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
156 static PyTypeObject *Expr_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
157 static char *Expr_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
158 "value", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
159 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
160 static PyTypeObject *Pass_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
161 static PyTypeObject *Break_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
162 static PyTypeObject *Continue_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
163 static PyTypeObject *expr_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
164 static char *expr_attributes[] = { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
165 "lineno", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
166 "col_offset", |
| 36669 | 167 }; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
168 static PyObject* ast2obj_expr(void*); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
169 static PyTypeObject *BoolOp_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
170 _Py_IDENTIFIER(values); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
171 static char *BoolOp_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
172 "op", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
173 "values", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
174 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
175 static PyTypeObject *BinOp_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
176 _Py_IDENTIFIER(left); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
177 _Py_IDENTIFIER(right); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
178 static char *BinOp_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
179 "left", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
180 "op", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
181 "right", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
182 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
183 static PyTypeObject *UnaryOp_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
184 _Py_IDENTIFIER(operand); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
185 static char *UnaryOp_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
186 "op", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
187 "operand", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
188 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
189 static PyTypeObject *Lambda_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
190 static char *Lambda_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
191 "args", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
192 "body", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
193 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
194 static PyTypeObject *IfExp_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
195 static char *IfExp_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
196 "test", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
197 "body", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
198 "orelse", |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
199 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
200 static PyTypeObject *Dict_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
201 _Py_IDENTIFIER(keys); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
202 static char *Dict_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
203 "keys", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
204 "values", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
205 }; |
|
39693
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
206 static PyTypeObject *Set_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
207 _Py_IDENTIFIER(elts); |
|
39693
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
208 static char *Set_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
209 "elts", |
|
39693
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
210 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
211 static PyTypeObject *ListComp_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
212 _Py_IDENTIFIER(elt); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
213 _Py_IDENTIFIER(generators); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
214 static char *ListComp_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
215 "elt", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
216 "generators", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
217 }; |
|
41464
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
218 static PyTypeObject *SetComp_type; |
|
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
219 static char *SetComp_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
220 "elt", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
221 "generators", |
|
41464
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
222 }; |
|
42193
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
223 static PyTypeObject *DictComp_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
224 _Py_IDENTIFIER(key); |
|
42193
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
225 static char *DictComp_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
226 "key", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
227 "value", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
228 "generators", |
|
42193
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
229 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
230 static PyTypeObject *GeneratorExp_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
231 static char *GeneratorExp_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
232 "elt", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
233 "generators", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
234 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
235 static PyTypeObject *Yield_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
236 static char *Yield_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
237 "value", |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
238 }; |
|
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
239 static PyTypeObject *YieldFrom_type; |
|
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
240 static char *YieldFrom_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
241 "value", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
242 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
243 static PyTypeObject *Compare_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
244 _Py_IDENTIFIER(ops); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
245 _Py_IDENTIFIER(comparators); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
246 static char *Compare_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
247 "left", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
248 "ops", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
249 "comparators", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
250 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
251 static PyTypeObject *Call_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
252 _Py_IDENTIFIER(func); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
253 static char *Call_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
254 "func", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
255 "args", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
256 "keywords", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
257 "starargs", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
258 "kwargs", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
259 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
260 static PyTypeObject *Num_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
261 _Py_IDENTIFIER(n); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
262 static char *Num_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
263 "n", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
264 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
265 static PyTypeObject *Str_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
266 _Py_IDENTIFIER(s); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
267 static char *Str_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
268 "s", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
269 }; |
| 40894 | 270 static PyTypeObject *Bytes_type; |
| 271 static char *Bytes_fields[]={ | |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
272 "s", |
| 40894 | 273 }; |
|
39783
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
274 static PyTypeObject *Ellipsis_type; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
275 static PyTypeObject *Attribute_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
276 _Py_IDENTIFIER(attr); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
277 _Py_IDENTIFIER(ctx); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
278 static char *Attribute_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
279 "value", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
280 "attr", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
281 "ctx", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
282 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
283 static PyTypeObject *Subscript_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
284 _Py_IDENTIFIER(slice); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
285 static char *Subscript_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
286 "value", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
287 "slice", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
288 "ctx", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
289 }; |
|
41699
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
290 static PyTypeObject *Starred_type; |
|
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
291 static char *Starred_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
292 "value", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
293 "ctx", |
|
41699
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
294 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
295 static PyTypeObject *Name_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
296 _Py_IDENTIFIER(id); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
297 static char *Name_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
298 "id", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
299 "ctx", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
300 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
301 static PyTypeObject *List_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
302 static char *List_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
303 "elts", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
304 "ctx", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
305 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
306 static PyTypeObject *Tuple_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
307 static char *Tuple_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
308 "elts", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
309 "ctx", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
310 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
311 static PyTypeObject *expr_context_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
312 static PyObject *Load_singleton, *Store_singleton, *Del_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
313 *AugLoad_singleton, *AugStore_singleton, *Param_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
314 static PyObject* ast2obj_expr_context(expr_context_ty); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
315 static PyTypeObject *Load_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
316 static PyTypeObject *Store_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
317 static PyTypeObject *Del_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
318 static PyTypeObject *AugLoad_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
319 static PyTypeObject *AugStore_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
320 static PyTypeObject *Param_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
321 static PyTypeObject *slice_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
322 static PyObject* ast2obj_slice(void*); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
323 static PyTypeObject *Slice_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
324 _Py_IDENTIFIER(lower); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
325 _Py_IDENTIFIER(upper); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
326 _Py_IDENTIFIER(step); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
327 static char *Slice_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
328 "lower", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
329 "upper", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
330 "step", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
331 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
332 static PyTypeObject *ExtSlice_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
333 _Py_IDENTIFIER(dims); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
334 static char *ExtSlice_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
335 "dims", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
336 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
337 static PyTypeObject *Index_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
338 static char *Index_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
339 "value", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
340 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
341 static PyTypeObject *boolop_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
342 static PyObject *And_singleton, *Or_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
343 static PyObject* ast2obj_boolop(boolop_ty); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
344 static PyTypeObject *And_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
345 static PyTypeObject *Or_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
346 static PyTypeObject *operator_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
347 static PyObject *Add_singleton, *Sub_singleton, *Mult_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
348 *Div_singleton, *Mod_singleton, *Pow_singleton, *LShift_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
349 *RShift_singleton, *BitOr_singleton, *BitXor_singleton, *BitAnd_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
350 *FloorDiv_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
351 static PyObject* ast2obj_operator(operator_ty); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
352 static PyTypeObject *Add_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
353 static PyTypeObject *Sub_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
354 static PyTypeObject *Mult_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
355 static PyTypeObject *Div_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
356 static PyTypeObject *Mod_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
357 static PyTypeObject *Pow_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
358 static PyTypeObject *LShift_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
359 static PyTypeObject *RShift_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
360 static PyTypeObject *BitOr_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
361 static PyTypeObject *BitXor_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
362 static PyTypeObject *BitAnd_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
363 static PyTypeObject *FloorDiv_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
364 static PyTypeObject *unaryop_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
365 static PyObject *Invert_singleton, *Not_singleton, *UAdd_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
366 *USub_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
367 static PyObject* ast2obj_unaryop(unaryop_ty); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
368 static PyTypeObject *Invert_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
369 static PyTypeObject *Not_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
370 static PyTypeObject *UAdd_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
371 static PyTypeObject *USub_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
372 static PyTypeObject *cmpop_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
373 static PyObject *Eq_singleton, *NotEq_singleton, *Lt_singleton, *LtE_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
374 *Gt_singleton, *GtE_singleton, *Is_singleton, *IsNot_singleton, *In_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
375 *NotIn_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
376 static PyObject* ast2obj_cmpop(cmpop_ty); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
377 static PyTypeObject *Eq_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
378 static PyTypeObject *NotEq_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
379 static PyTypeObject *Lt_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
380 static PyTypeObject *LtE_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
381 static PyTypeObject *Gt_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
382 static PyTypeObject *GtE_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
383 static PyTypeObject *Is_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
384 static PyTypeObject *IsNot_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
385 static PyTypeObject *In_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
386 static PyTypeObject *NotIn_type; |
|
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
387 static PyTypeObject *comprehension_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
388 static PyObject* ast2obj_comprehension(void*); |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
389 _Py_IDENTIFIER(ifs); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
390 static char *comprehension_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
391 "target", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
392 "iter", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
393 "ifs", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
394 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
395 static PyTypeObject *excepthandler_type; |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
396 static char *excepthandler_attributes[] = { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
397 "lineno", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
398 "col_offset", |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
399 }; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
400 static PyObject* ast2obj_excepthandler(void*); |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
401 static PyTypeObject *ExceptHandler_type; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
402 _Py_IDENTIFIER(type); |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
403 static char *ExceptHandler_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
404 "type", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
405 "name", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
406 "body", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
407 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
408 static PyTypeObject *arguments_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
409 static PyObject* ast2obj_arguments(void*); |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
410 _Py_IDENTIFIER(vararg); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
411 _Py_IDENTIFIER(varargannotation); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
412 _Py_IDENTIFIER(kwonlyargs); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
413 _Py_IDENTIFIER(kwarg); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
414 _Py_IDENTIFIER(kwargannotation); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
415 _Py_IDENTIFIER(defaults); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
416 _Py_IDENTIFIER(kw_defaults); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
417 static char *arguments_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
418 "args", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
419 "vararg", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
420 "varargannotation", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
421 "kwonlyargs", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
422 "kwarg", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
423 "kwargannotation", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
424 "defaults", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
425 "kw_defaults", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
426 }; |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
427 static PyTypeObject *arg_type; |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
428 static PyObject* ast2obj_arg(void*); |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
429 _Py_IDENTIFIER(arg); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
430 _Py_IDENTIFIER(annotation); |
|
41717
9ad84070b22d
Merged revisions 55328-55341 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41699
diff
changeset
|
431 static char *arg_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
432 "arg", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
433 "annotation", |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
434 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
435 static PyTypeObject *keyword_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
436 static PyObject* ast2obj_keyword(void*); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
437 static char *keyword_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
438 "arg", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
439 "value", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
440 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
441 static PyTypeObject *alias_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
442 static PyObject* ast2obj_alias(void*); |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
443 _Py_IDENTIFIER(asname); |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
444 static char *alias_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
445 "name", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
446 "asname", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
447 }; |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
448 static PyTypeObject *withitem_type; |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
449 static PyObject* ast2obj_withitem(void*); |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
450 _Py_IDENTIFIER(context_expr); |
|
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
451 _Py_IDENTIFIER(optional_vars); |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
452 static char *withitem_fields[]={ |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
453 "context_expr", |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
454 "optional_vars", |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
455 }; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
456 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
457 |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
458 typedef struct { |
|
75567
6bee4eea1efa
Try to fix compilation of Python-ast.c on Visual Studio 2008
Victor Stinner <victor.stinner@gmail.com>
parents:
75542
diff
changeset
|
459 PyObject_HEAD |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
460 PyObject *dict; |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
461 } AST_object; |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
462 |
| 75686 | 463 static void |
| 464 ast_dealloc(AST_object *self) | |
| 465 { | |
| 466 Py_CLEAR(self->dict); | |
|
77998
048d8d9aecf1
Issue #15291: Fix a memory leak where AST nodes where not properly deallocated.
Antoine Pitrou <solipsis@pitrou.net>
parents:
76964
diff
changeset
|
467 Py_TYPE(self)->tp_free(self); |
| 75686 | 468 } |
| 469 | |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
470 static int |
|
78006
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
471 ast_traverse(AST_object *self, visitproc visit, void *arg) |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
472 { |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
473 Py_VISIT(self->dict); |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
474 return 0; |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
475 } |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
476 |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
477 static void |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
478 ast_clear(AST_object *self) |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
479 { |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
480 Py_CLEAR(self->dict); |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
481 } |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
482 |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
483 static int |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
484 ast_type_init(PyObject *self, PyObject *args, PyObject *kw) |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
485 { |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
486 _Py_IDENTIFIER(_fields); |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
487 Py_ssize_t i, numfields = 0; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
488 int res = -1; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
489 PyObject *key, *value, *fields; |
|
72848
81380082d216
Use identifier API for PyObject_GetAttrString.
Martin v. Löwis <martin@v.loewis.de>
parents:
72195
diff
changeset
|
490 fields = _PyObject_GetAttrId((PyObject*)Py_TYPE(self), &PyId__fields); |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
491 if (!fields) |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
492 PyErr_Clear(); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
493 if (fields) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
494 numfields = PySequence_Size(fields); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
495 if (numfields == -1) |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
496 goto cleanup; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
497 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
498 res = 0; /* if no error occurs, this stays 0 to the end */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
499 if (PyTuple_GET_SIZE(args) > 0) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
500 if (numfields != PyTuple_GET_SIZE(args)) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
501 PyErr_Format(PyExc_TypeError, "%.400s constructor takes %s" |
|
49139
6ae2d4b507a2
Merged revisions 66377 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47580
diff
changeset
|
502 "%zd positional argument%s", |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
503 Py_TYPE(self)->tp_name, |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
504 numfields == 0 ? "" : "either 0 or ", |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
505 numfields, numfields == 1 ? "" : "s"); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
506 res = -1; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
507 goto cleanup; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
508 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
509 for (i = 0; i < PyTuple_GET_SIZE(args); i++) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
510 /* cannot be reached when fields is NULL */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
511 PyObject *name = PySequence_GetItem(fields, i); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
512 if (!name) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
513 res = -1; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
514 goto cleanup; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
515 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
516 res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i)); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
517 Py_DECREF(name); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
518 if (res < 0) |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
519 goto cleanup; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
520 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
521 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
522 if (kw) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
523 i = 0; /* needed by PyDict_Next */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
524 while (PyDict_Next(kw, &i, &key, &value)) { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
525 res = PyObject_SetAttr(self, key, value); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
526 if (res < 0) |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
527 goto cleanup; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
528 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
529 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
530 cleanup: |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
531 Py_XDECREF(fields); |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
532 return res; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
533 } |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
534 |
|
46233
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
535 /* Pickling support */ |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
536 static PyObject * |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
537 ast_type_reduce(PyObject *self, PyObject *unused) |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
538 { |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
539 PyObject *res; |
|
72925
7109f31300fb
Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents:
72848
diff
changeset
|
540 _Py_IDENTIFIER(__dict__); |
|
72848
81380082d216
Use identifier API for PyObject_GetAttrString.
Martin v. Löwis <martin@v.loewis.de>
parents:
72195
diff
changeset
|
541 PyObject *dict = _PyObject_GetAttrId(self, &PyId___dict__); |
|
46233
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
542 if (dict == NULL) { |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
543 if (PyErr_ExceptionMatches(PyExc_AttributeError)) |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
544 PyErr_Clear(); |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
545 else |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
546 return NULL; |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
547 } |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
548 if (dict) { |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
549 res = Py_BuildValue("O()O", Py_TYPE(self), dict); |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
550 Py_DECREF(dict); |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
551 return res; |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
552 } |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
553 return Py_BuildValue("O()", Py_TYPE(self)); |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
554 } |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
555 |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
556 static PyMethodDef ast_type_methods[] = { |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
557 {"__reduce__", ast_type_reduce, METH_NOARGS, NULL}, |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
558 {NULL} |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
559 }; |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
560 |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
561 static PyGetSetDef ast_type_getsets[] = { |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
562 {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict}, |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
563 {NULL} |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
564 }; |
|
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
565 |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
566 static PyTypeObject AST_type = { |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
567 PyVarObject_HEAD_INIT(&PyType_Type, 0) |
|
46233
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
568 "_ast.AST", |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
569 sizeof(AST_object), |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
570 0, |
| 75686 | 571 (destructor)ast_dealloc, /* tp_dealloc */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
572 0, /* tp_print */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
573 0, /* tp_getattr */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
574 0, /* tp_setattr */ |
|
51270
debd14c489b9
Issue #1717: rename tp_compare to tp_reserved. I'll change the
Mark Dickinson <dickinsm@gmail.com>
parents:
50076
diff
changeset
|
575 0, /* tp_reserved */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
576 0, /* tp_repr */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
577 0, /* tp_as_number */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
578 0, /* tp_as_sequence */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
579 0, /* tp_as_mapping */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
580 0, /* tp_hash */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
581 0, /* tp_call */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
582 0, /* tp_str */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
583 PyObject_GenericGetAttr, /* tp_getattro */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
584 PyObject_GenericSetAttr, /* tp_setattro */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
585 0, /* tp_as_buffer */ |
|
78006
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
586 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
587 0, /* tp_doc */ |
|
78006
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
588 (traverseproc)ast_traverse, /* tp_traverse */ |
|
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
589 (inquiry)ast_clear, /* tp_clear */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
590 0, /* tp_richcompare */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
591 0, /* tp_weaklistoffset */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
592 0, /* tp_iter */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
593 0, /* tp_iternext */ |
|
46233
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
594 ast_type_methods, /* tp_methods */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
595 0, /* tp_members */ |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
596 ast_type_getsets, /* tp_getset */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
597 0, /* tp_base */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
598 0, /* tp_dict */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
599 0, /* tp_descr_get */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
600 0, /* tp_descr_set */ |
|
75542
3877bf2e3235
give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents:
74391
diff
changeset
|
601 offsetof(AST_object, dict),/* tp_dictoffset */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
602 (initproc)ast_type_init, /* tp_init */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
603 PyType_GenericAlloc, /* tp_alloc */ |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
604 PyType_GenericNew, /* tp_new */ |
|
78006
85cccc38d01c
add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents:
77998
diff
changeset
|
605 PyObject_GC_Del, /* tp_free */ |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
606 }; |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
607 |
|
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
608 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
609 static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int num_fields) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
610 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
611 PyObject *fnames, *result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
612 int i; |
|
46233
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
613 fnames = PyTuple_New(num_fields); |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
614 if (!fnames) return NULL; |
|
61c92923cf7f
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46231
diff
changeset
|
615 for (i = 0; i < num_fields; i++) { |
|
42816
872c7c3f0af3
Use unicode for AST attributes
Neal Norwitz <nnorwitz@gmail.com>
parents:
42206
diff
changeset
|
616 PyObject *field = PyUnicode_FromString(fields[i]); |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
617 if (!field) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
618 Py_DECREF(fnames); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
619 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
620 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
621 PyTuple_SET_ITEM(fnames, i, field); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
622 } |
|
62155
600c23127207
Issue #8848: U / U# formats of Py_BuildValue() are just alias to s / s#
Victor Stinner <victor.stinner@haypocalc.com>
parents:
57676
diff
changeset
|
623 result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}", |
| 36669 | 624 type, base, "_fields", fnames, "__module__", "_ast"); |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
625 Py_DECREF(fnames); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
626 return (PyTypeObject*)result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
627 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
628 |
| 36669 | 629 static int add_attributes(PyTypeObject* type, char**attrs, int num_fields) |
| 630 { | |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36794
diff
changeset
|
631 int i, result; |
|
72926
db4aa878cea2
Port SetAttrString/HasAttrString to SetAttrId/GetAttrId.
Martin v. Löwis <martin@v.loewis.de>
parents:
72925
diff
changeset
|
632 _Py_IDENTIFIER(_attributes); |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
633 PyObject *s, *l = PyTuple_New(num_fields); |
|
62566
504c499e8c95
Merged revisions 81465-81466,81468,81679,81735,81760,81868,82183 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
62464
diff
changeset
|
634 if (!l) |
|
504c499e8c95
Merged revisions 81465-81466,81468,81679,81735,81760,81868,82183 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
62464
diff
changeset
|
635 return 0; |
|
504c499e8c95
Merged revisions 81465-81466,81468,81679,81735,81760,81868,82183 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
62464
diff
changeset
|
636 for (i = 0; i < num_fields; i++) { |
|
42816
872c7c3f0af3
Use unicode for AST attributes
Neal Norwitz <nnorwitz@gmail.com>
parents:
42206
diff
changeset
|
637 s = PyUnicode_FromString(attrs[i]); |
| 36669 | 638 if (!s) { |
| 639 Py_DECREF(l); | |
| 640 return 0; | |
| 641 } | |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
642 PyTuple_SET_ITEM(l, i, s); |
| 36669 | 643 } |
|
72926
db4aa878cea2
Port SetAttrString/HasAttrString to SetAttrId/GetAttrId.
Martin v. Löwis <martin@v.loewis.de>
parents:
72925
diff
changeset
|
644 result = _PyObject_SetAttrId((PyObject*)type, &PyId__attributes, l) >= 0; |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36794
diff
changeset
|
645 Py_DECREF(l); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
36794
diff
changeset
|
646 return result; |
| 36669 | 647 } |
| 648 | |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
649 /* Conversion AST -> Python */ |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
650 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
651 static PyObject* ast2obj_list(asdl_seq *seq, PyObject* (*func)(void*)) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
652 { |
|
76964
c18a1a82bb07
use Py_ssize_t for ast sequence lengths
Benjamin Peterson <benjamin@python.org>
parents:
76948
diff
changeset
|
653 Py_ssize_t i, n = asdl_seq_LEN(seq); |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
654 PyObject *result = PyList_New(n); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
655 PyObject *value; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
656 if (!result) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
657 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
658 for (i = 0; i < n; i++) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
659 value = func(asdl_seq_GET(seq, i)); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
660 if (!value) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
661 Py_DECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
662 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
663 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
664 PyList_SET_ITEM(result, i, value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
665 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
666 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
667 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
668 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
669 static PyObject* ast2obj_object(void *o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
670 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
671 if (!o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
672 o = Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
673 Py_INCREF((PyObject*)o); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
674 return (PyObject*)o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
675 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
676 #define ast2obj_identifier ast2obj_object |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
677 #define ast2obj_string ast2obj_object |
|
71792
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
678 #define ast2obj_bytes ast2obj_object |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
679 |
|
40937
6aa1be5dd009
Merged revisions 53912-53951 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40896
diff
changeset
|
680 static PyObject* ast2obj_int(long b) |
| 36669 | 681 { |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43755
diff
changeset
|
682 return PyLong_FromLong(b); |
| 36669 | 683 } |
| 684 | |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
685 /* Conversion Python -> AST */ |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
686 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
687 static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
688 { |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
689 if (obj == Py_None) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
690 obj = NULL; |
|
84855
65121aa79ab3
Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
Christian Heimes <christian@cheimes.de>
parents:
84852
diff
changeset
|
691 if (obj) { |
|
65121aa79ab3
Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
Christian Heimes <christian@cheimes.de>
parents:
84852
diff
changeset
|
692 if (PyArena_AddPyObject(arena, obj) < 0) { |
|
65121aa79ab3
Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
Christian Heimes <christian@cheimes.de>
parents:
84852
diff
changeset
|
693 *out = NULL; |
|
65121aa79ab3
Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
Christian Heimes <christian@cheimes.de>
parents:
84852
diff
changeset
|
694 return -1; |
|
65121aa79ab3
Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
Christian Heimes <christian@cheimes.de>
parents:
84852
diff
changeset
|
695 } |
|
65121aa79ab3
Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
Christian Heimes <christian@cheimes.de>
parents:
84852
diff
changeset
|
696 Py_INCREF(obj); |
|
65121aa79ab3
Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
Christian Heimes <christian@cheimes.de>
parents:
84852
diff
changeset
|
697 } |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
698 *out = obj; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
699 return 0; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
700 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
701 |
|
71458
c9ebae3285e3
None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents:
71455
diff
changeset
|
702 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
|
703 { |
|
71458
c9ebae3285e3
None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents:
71455
diff
changeset
|
704 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
|
705 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
|
706 return 1; |
|
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
707 } |
|
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
708 return obj2ast_object(obj, out, arena); |
|
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
709 } |
|
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
710 |
|
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
711 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
|
712 { |
|
72154
c8b6d4417274
accept bytes for the AST 'string' type
Benjamin Peterson <benjamin@python.org>
parents:
71458
diff
changeset
|
713 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
|
714 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
|
715 return 1; |
|
c9ebae3285e3
None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents:
71455
diff
changeset
|
716 } |
|
c9ebae3285e3
None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents:
71455
diff
changeset
|
717 return obj2ast_object(obj, out, arena); |
|
71454
3301689bd78d
type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents:
68257
diff
changeset
|
718 } |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
719 |
|
71792
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
720 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
|
721 { |
|
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
722 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
|
723 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
|
724 return 1; |
|
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
725 } |
|
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
726 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
|
727 } |
|
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
728 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
729 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
|
730 { |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
731 int i; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
732 if (!PyLong_Check(obj)) { |
|
73700
470f7d7c57ce
Issue #13436: commit regenerated Python-ast.c
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
72154
diff
changeset
|
733 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
|
734 return 1; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
735 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
736 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
737 i = (int)PyLong_AsLong(obj); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
738 if (i == -1 && PyErr_Occurred()) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
739 return 1; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
740 *out = i; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
741 return 0; |
|
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 |
|
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
|
744 static int add_ast_fields(void) |
|
49583
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
745 { |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
746 PyObject *empty_tuple, *d; |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
747 if (PyType_Ready(&AST_type) < 0) |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
748 return -1; |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
749 d = AST_type.tp_dict; |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
750 empty_tuple = PyTuple_New(0); |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
751 if (!empty_tuple || |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
752 PyDict_SetItemString(d, "_fields", empty_tuple) < 0 || |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
753 PyDict_SetItemString(d, "_attributes", empty_tuple) < 0) { |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
754 Py_XDECREF(empty_tuple); |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
755 return -1; |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
756 } |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
757 Py_DECREF(empty_tuple); |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
758 return 0; |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
759 } |
|
2a38771cecdd
update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents:
49139
diff
changeset
|
760 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
761 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
762 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
|
763 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
764 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
|
765 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
|
766 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
|
767 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
|
768 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
|
769 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
|
770 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
|
771 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
|
772 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
|
773 1); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
774 if (!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
|
775 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
|
776 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
|
777 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
|
778 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
|
779 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
|
780 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
|
781 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
|
782 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
|
783 5); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
784 if (!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
|
785 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
|
786 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
|
787 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
|
788 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
|
789 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
|
790 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
|
791 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
|
792 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
|
793 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
|
794 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
|
795 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
|
796 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
|
797 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
|
798 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
|
799 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
|
800 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
|
801 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
|
802 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
|
803 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
|
804 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
|
805 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
|
806 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
|
807 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
|
808 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
|
809 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
|
810 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
|
811 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
|
812 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
|
813 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
|
814 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
|
815 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
|
816 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
|
817 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
|
818 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
|
819 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
|
820 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
|
821 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
|
822 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
|
823 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
|
824 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
|
825 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
|
826 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
|
827 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
|
828 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
|
829 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
|
830 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
|
831 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
|
832 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
|
833 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
|
834 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
|
835 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
|
836 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
|
837 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
|
838 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
|
839 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
|
840 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
|
841 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
|
842 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
|
843 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
|
844 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
|
845 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
|
846 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
|
847 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
|
848 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
|
849 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
|
850 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
|
851 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
|
852 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
|
853 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
|
854 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
|
855 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
|
856 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
|
857 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
|
858 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
|
859 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
|
860 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
|
861 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
|
862 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
|
863 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
|
864 if (!Bytes_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
865 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
|
866 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
|
867 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
|
868 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
|
869 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
|
870 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
|
871 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
|
872 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
|
873 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
|
874 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
|
875 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
|
876 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
|
877 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
|
878 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
|
879 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
|
880 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
|
881 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
|
882 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
|
883 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
|
884 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
|
885 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
|
886 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
|
887 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
|
888 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
|
889 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
|
890 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
|
891 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
|
892 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
|
893 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
|
894 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
|
895 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
|
896 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
|
897 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
|
898 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
|
899 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
|
900 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
|
901 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
|
902 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
|
903 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
|
904 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
|
905 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
|
906 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
|
907 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
|
908 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
|
909 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
|
910 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
|
911 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
|
912 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
|
913 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
|
914 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
|
915 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
|
916 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
|
917 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
|
918 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
|
919 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
|
920 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
|
921 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
|
922 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
|
923 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
|
924 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
|
925 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
|
926 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
|
927 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
|
928 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
|
929 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
|
930 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
|
931 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
|
932 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
|
933 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
|
934 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
|
935 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
|
936 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
|
937 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
|
938 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
|
939 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
|
940 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
|
941 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
|
942 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
|
943 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
|
944 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
|
945 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
|
946 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
|
947 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
|
948 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
|
949 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
|
950 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
|
951 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
|
952 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
|
953 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
|
954 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
|
955 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
|
956 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
|
957 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
|
958 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
|
959 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
|
960 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
|
961 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
|
962 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
|
963 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
|
964 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
|
965 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
|
966 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
|
967 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
|
968 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
|
969 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
|
970 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
|
971 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
|
972 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
|
973 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
|
974 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
|
975 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
|
976 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
|
977 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
|
978 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
|
979 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
|
980 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
|
981 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
|
982 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
|
983 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
|
984 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
|
985 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
|
986 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
|
987 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
|
988 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
|
989 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
|
990 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
|
991 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
|
992 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
|
993 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
|
994 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
|
995 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
|
996 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
|
997 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
|
998 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
|
999 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
|
1000 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
|
1001 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
|
1002 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
|
1003 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
|
1004 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
|
1005 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
|
1006 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
|
1007 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
|
1008 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
|
1009 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
|
1010 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
|
1011 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
|
1012 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
|
1013 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
|
1014 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
|
1015 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
|
1016 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
|
1017 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
|
1018 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
|
1019 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
|
1020 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
|
1021 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
|
1022 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
|
1023 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
|
1024 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
|
1025 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
|
1026 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
|
1027 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
|
1028 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
|
1029 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
|
1030 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
|
1031 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
|
1032 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
|
1033 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
|
1034 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
|
1035 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
|
1036 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
|
1037 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
|
1038 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
|
1039 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
|
1040 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
|
1041 if (!comprehension_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1042 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
|
1043 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
|
1044 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
|
1045 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1046 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
|
1047 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
|
1048 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
|
1049 arguments_type = make_type("arguments", &AST_type, arguments_fields, 8); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1050 if (!arguments_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1051 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
|
1052 if (!arg_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1053 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
|
1054 if (!keyword_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1055 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
|
1056 if (!alias_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1057 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
|
1058 if (!withitem_type) return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1059 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
|
1060 return 1; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1061 } |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1062 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1063 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
|
1064 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
|
1065 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
|
1066 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
|
1067 arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1068 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
|
1069 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
|
1070 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
|
1071 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
|
1072 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
|
1073 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
|
1074 arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1075 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
|
1076 arena); |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
1077 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
|
1078 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
|
1079 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
|
1080 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
|
1081 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
|
1082 |
| 35742 | 1083 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
|
1084 Module(asdl_seq * body, PyArena *arena) |
| 35742 | 1085 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1086 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
|
1087 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
|
1088 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
|
1089 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1090 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
|
1091 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
|
1092 return p; |
| 35742 | 1093 } |
| 1094 | |
| 1095 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
|
1096 Interactive(asdl_seq * body, PyArena *arena) |
| 35742 | 1097 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1098 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
|
1099 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
|
1100 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
|
1101 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1102 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
|
1103 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
|
1104 return p; |
| 35742 | 1105 } |
| 1106 | |
| 1107 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
|
1108 Expression(expr_ty body, PyArena *arena) |
| 35742 | 1109 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1110 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
|
1111 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
|
1112 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
|
1113 "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
|
1114 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1115 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1116 p = (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
|
1117 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
|
1118 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1119 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
|
1120 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
|
1121 return p; |
| 35742 | 1122 } |
| 1123 | |
| 1124 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
|
1125 Suite(asdl_seq * body, PyArena *arena) |
| 35742 | 1126 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1127 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
|
1128 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
|
1129 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
|
1130 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1131 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
|
1132 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
|
1133 return p; |
| 35742 | 1134 } |
| 1135 | |
| 1136 stmt_ty | |
| 1137 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
|
1138 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
|
1139 PyArena *arena) |
| 35742 | 1140 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1141 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
|
1142 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
|
1143 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
|
1144 "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
|
1145 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1146 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1147 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
|
1148 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
|
1149 "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
|
1150 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1151 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1152 p = (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
|
1153 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
|
1154 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1155 p->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
|
1156 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
|
1157 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
|
1158 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
|
1159 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
|
1160 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
|
1161 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
|
1162 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
|
1163 return p; |
| 35742 | 1164 } |
| 1165 | |
| 1166 stmt_ty | |
|
41226
19f7ff443718
Implement PEP 3115 -- new metaclass syntax and semantics.
Guido van Rossum <guido@python.org>
parents:
40980
diff
changeset
|
1167 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
|
1168 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
|
1169 int lineno, int col_offset, PyArena *arena) |
| 35742 | 1170 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1171 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
|
1172 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
|
1173 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
|
1174 "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
|
1175 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1176 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1177 p = (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
|
1178 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
|
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 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
|
1181 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
|
1182 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
|
1183 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
|
1184 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
|
1185 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
|
1186 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
|
1187 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
|
1188 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
|
1189 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
|
1190 return p; |
| 35742 | 1191 } |
| 1192 | |
| 1193 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
|
1194 Return(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1195 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1196 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
|
1197 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
|
1198 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
|
1199 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1200 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
|
1201 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
|
1202 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
|
1203 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
|
1204 return p; |
| 35742 | 1205 } |
| 1206 | |
| 1207 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
|
1208 Delete(asdl_seq * targets, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1209 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1210 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
|
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 = 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
|
1215 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
|
1216 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
|
1217 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
|
1218 return p; |
| 35742 | 1219 } |
| 1220 | |
| 1221 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
|
1222 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
|
1223 *arena) |
| 35742 | 1224 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1225 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
|
1226 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
|
1227 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
|
1228 "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
|
1229 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1230 } |
|
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 = 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
|
1235 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
|
1236 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
|
1237 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
|
1238 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
|
1239 return p; |
| 35742 | 1240 } |
| 1241 | |
| 1242 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
|
1243 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
|
1244 col_offset, PyArena *arena) |
| 35742 | 1245 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1246 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
|
1247 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
|
1248 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
|
1249 "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
|
1250 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1251 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1252 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
|
1253 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
|
1254 "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
|
1255 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1256 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1257 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
|
1258 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
|
1259 "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
|
1260 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1261 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1262 p = (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
|
1263 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
|
1264 return NULL; |
|
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->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
|
1266 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
|
1267 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
|
1268 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
|
1269 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
|
1270 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
|
1271 return p; |
| 35742 | 1272 } |
| 1273 | |
| 1274 stmt_ty | |
| 1275 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
|
1276 lineno, int col_offset, PyArena *arena) |
| 35742 | 1277 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1278 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
|
1279 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
|
1280 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
|
1281 "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
|
1282 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1283 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1284 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
|
1285 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
|
1286 "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
|
1287 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1288 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1289 p = (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
|
1290 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
|
1291 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1292 p->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
|
1293 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
|
1294 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
|
1295 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
|
1296 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
|
1297 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
|
1298 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
|
1299 return p; |
| 35742 | 1300 } |
| 1301 | |
| 1302 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
|
1303 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
|
1304 col_offset, PyArena *arena) |
| 35742 | 1305 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1306 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
|
1307 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
|
1308 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
|
1309 "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
|
1310 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1311 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1312 p = (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
|
1313 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
|
1314 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1315 p->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
|
1316 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
|
1317 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
|
1318 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
|
1319 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
|
1320 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
|
1321 return p; |
| 35742 | 1322 } |
| 1323 | |
| 1324 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
|
1325 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
|
1326 col_offset, PyArena *arena) |
| 35742 | 1327 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1328 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
|
1329 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
|
1330 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
|
1331 "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
|
1332 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1333 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1334 p = (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
|
1335 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
|
1336 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1337 p->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
|
1338 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
|
1339 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
|
1340 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
|
1341 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
|
1342 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
|
1343 return p; |
| 35742 | 1344 } |
| 1345 | |
| 1346 stmt_ty | |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
1347 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
|
1348 *arena) |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1349 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1350 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
|
1351 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
|
1352 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
|
1353 return NULL; |
|
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->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
|
1355 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
|
1356 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
|
1357 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
|
1358 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
|
1359 return p; |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1360 } |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1361 |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1362 stmt_ty |
|
43102
981ecc526703
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents:
42844
diff
changeset
|
1363 Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1364 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1365 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
|
1366 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
|
1367 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
|
1368 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1369 p->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
|
1370 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
|
1371 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
|
1372 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
|
1373 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
|
1374 return p; |
| 35742 | 1375 } |
| 1376 | |
| 1377 stmt_ty | |
|
70499
e0e663132363
unify TryExcept and TryFinally (closes #12199)
Benjamin Peterson <benjamin@python.org>
parents:
70439
diff
changeset
|
1378 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
|
1379 finalbody, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1380 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1381 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
|
1382 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
|
1383 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
|
1384 return NULL; |
|
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->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
|
1386 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
|
1387 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
|
1388 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
|
1389 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
|
1390 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
|
1391 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
|
1392 return p; |
| 35742 | 1393 } |
| 1394 | |
| 1395 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
|
1396 Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1397 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1398 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
|
1399 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
|
1400 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
|
1401 "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
|
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 } |
|
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 = (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
|
1405 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
|
1406 return NULL; |
|
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->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
|
1408 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
|
1409 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
|
1410 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
|
1411 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
|
1412 return p; |
| 35742 | 1413 } |
| 1414 | |
| 1415 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
|
1416 Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1417 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1418 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
|
1419 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
|
1420 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
|
1421 return NULL; |
|
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->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
|
1423 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
|
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 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
|
1431 col_offset, PyArena *arena) |
| 35742 | 1432 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1433 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
|
1434 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
|
1435 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
|
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 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
|
1438 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
|
1439 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
|
1440 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
|
1441 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
|
1442 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
|
1443 return p; |
| 35742 | 1444 } |
| 1445 | |
| 1446 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
|
1447 Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1448 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1449 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
|
1450 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
|
1451 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
|
1452 return NULL; |
|
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->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
|
1454 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
|
1455 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
|
1456 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
|
1457 return p; |
| 35742 | 1458 } |
| 1459 | |
| 1460 stmt_ty | |
|
40965
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
1461 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
|
1462 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1463 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
|
1464 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
|
1465 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
|
1466 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1467 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
|
1468 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
|
1469 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
|
1470 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
|
1471 return p; |
|
40965
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
1472 } |
|
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
1473 |
|
30e5cb3a55ac
Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
40941
diff
changeset
|
1474 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
|
1475 Expr(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1476 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1477 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
|
1478 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
|
1479 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
|
1480 "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
|
1481 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1482 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1483 p = (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
|
1484 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
|
1485 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1486 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
|
1487 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
|
1488 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
|
1489 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
|
1490 return p; |
| 35742 | 1491 } |
| 1492 | |
| 1493 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
|
1494 Pass(int lineno, int col_offset, PyArena *arena) |
| 35742 | 1495 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1496 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
|
1497 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
|
1498 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
|
1499 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1500 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
|
1501 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
|
1502 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
|
1503 return p; |
| 35742 | 1504 } |
| 1505 | |
| 1506 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
|
1507 Break(int lineno, int col_offset, PyArena *arena) |
| 35742 | 1508 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1509 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
|
1510 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
|
1511 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
|
1512 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1513 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
|
1514 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
|
1515 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
|
1516 return p; |
| 35742 | 1517 } |
| 1518 | |
| 1519 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
|
1520 Continue(int lineno, int col_offset, PyArena *arena) |
| 35742 | 1521 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1522 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
|
1523 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
|
1524 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
|
1525 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1526 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
|
1527 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
|
1528 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
|
1529 return p; |
| 35742 | 1530 } |
| 1531 | |
| 1532 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
|
1533 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
|
1534 *arena) |
| 35742 | 1535 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1536 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
|
1537 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
|
1538 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
|
1539 "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
|
1540 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1541 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1542 p = (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
|
1543 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
|
1544 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1545 p->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
|
1546 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
|
1547 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
|
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 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
|
1554 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
|
1555 PyArena *arena) |
| 35742 | 1556 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1557 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
|
1558 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
|
1559 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
|
1560 "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
|
1561 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1562 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1563 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
|
1564 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
|
1565 "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
|
1566 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1567 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1568 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
|
1569 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
|
1570 "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
|
1571 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1572 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1573 p = (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
|
1574 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
|
1575 return NULL; |
|
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->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
|
1577 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
|
1578 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
|
1579 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
|
1580 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
|
1581 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
|
1582 return p; |
| 35742 | 1583 } |
| 1584 | |
| 1585 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
|
1586 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
|
1587 *arena) |
| 35742 | 1588 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1589 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
|
1590 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
|
1591 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
|
1592 "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
|
1593 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1594 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1595 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
|
1596 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
|
1597 "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
|
1598 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1599 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1600 p = (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
|
1601 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
|
1602 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1603 p->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
|
1604 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
|
1605 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
|
1606 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
|
1607 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
|
1608 return p; |
| 35742 | 1609 } |
| 1610 | |
| 1611 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
|
1612 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
|
1613 *arena) |
| 35742 | 1614 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1615 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
|
1616 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
|
1617 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
|
1618 "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
|
1619 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1620 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1621 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
|
1622 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
|
1623 "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
|
1624 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1625 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1626 p = (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
|
1627 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
|
1628 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1629 p->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
|
1630 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
|
1631 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
|
1632 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
|
1633 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
|
1634 return p; |
| 35742 | 1635 } |
| 1636 | |
| 1637 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
|
1638 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
|
1639 PyArena *arena) |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1640 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1641 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
|
1642 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
|
1643 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
|
1644 "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
|
1645 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1646 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1647 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
|
1648 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
|
1649 "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
|
1650 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1651 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1652 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
|
1653 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
|
1654 "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
|
1655 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1656 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1657 p = (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
|
1658 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
|
1659 return NULL; |
|
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->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
|
1661 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
|
1662 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
|
1663 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
|
1664 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
|
1665 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
|
1666 return p; |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1667 } |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1668 |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1669 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
|
1670 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
|
1671 *arena) |
| 35742 | 1672 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1673 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
|
1674 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
|
1675 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
|
1676 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1677 p->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
|
1678 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
|
1679 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
|
1680 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
|
1681 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
|
1682 return p; |
| 35742 | 1683 } |
| 1684 | |
| 1685 expr_ty | |
|
39693
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
1686 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
|
1687 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1688 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
|
1689 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
|
1690 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
|
1691 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1692 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
|
1693 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
|
1694 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
|
1695 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
|
1696 return p; |
|
39693
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
1697 } |
|
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
1698 |
|
d0b83c4630c0
SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents:
39691
diff
changeset
|
1699 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
|
1700 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
|
1701 PyArena *arena) |
| 35742 | 1702 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1703 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
|
1704 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
|
1705 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
|
1706 "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
|
1707 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1708 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1709 p = (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
|
1710 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
|
1711 return NULL; |
|
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->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
|
1713 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
|
1714 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
|
1715 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
|
1716 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
|
1717 return p; |
| 35742 | 1718 } |
| 1719 | |
| 1720 expr_ty | |
|
41464
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
1721 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
|
1722 *arena) |
|
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
1723 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1724 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
|
1725 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
|
1726 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
|
1727 "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
|
1728 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1729 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1730 p = (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
|
1731 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
|
1732 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1733 p->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
|
1734 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
|
1735 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
|
1736 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
|
1737 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
|
1738 return p; |
|
41464
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
1739 } |
|
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
1740 |
|
060c79f6d919
Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents:
41227
diff
changeset
|
1741 expr_ty |
|
42193
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
1742 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
|
1743 col_offset, PyArena *arena) |
|
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
1744 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1745 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
|
1746 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
|
1747 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
|
1748 "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
|
1749 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1750 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1751 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
|
1752 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
|
1753 "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
|
1754 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1755 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1756 p = (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
|
1757 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
|
1758 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1759 p->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
|
1760 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
|
1761 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
|
1762 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
|
1763 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
|
1764 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
|
1765 return p; |
|
42193
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
1766 } |
|
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
1767 |
|
090588a17490
Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42013
diff
changeset
|
1768 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
|
1769 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
|
1770 PyArena *arena) |
| 35742 | 1771 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1772 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
|
1773 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
|
1774 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
|
1775 "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
|
1776 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1777 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1778 p = (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
|
1779 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
|
1780 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1781 p->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
|
1782 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
|
1783 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
|
1784 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
|
1785 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
|
1786 return p; |
| 35742 | 1787 } |
| 1788 | |
| 1789 expr_ty | |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
1790 Yield(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1791 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1792 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
|
1793 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
|
1794 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
|
1795 return NULL; |
|
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->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
|
1797 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
|
1798 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
|
1799 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
|
1800 return p; |
| 35742 | 1801 } |
| 1802 | |
| 1803 expr_ty | |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
1804 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
|
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 (!value) { |
|
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 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
|
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 = 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
|
1816 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
|
1817 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
|
1818 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
|
1819 return p; |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
1820 } |
|
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
1821 |
|
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
1822 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
|
1823 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
|
1824 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 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
|
1828 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
|
1829 "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
|
1830 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1831 } |
|
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 = (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
|
1833 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
|
1834 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1835 p->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
|
1836 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
|
1837 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
|
1838 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
|
1839 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
|
1840 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
|
1841 return p; |
| 35742 | 1842 } |
| 1843 | |
| 1844 expr_ty | |
| 1845 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
|
1846 expr_ty kwargs, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1847 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1848 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
|
1849 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
|
1850 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
|
1851 "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
|
1852 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1853 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1854 p = (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
|
1855 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
|
1856 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1857 p->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
|
1858 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
|
1859 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
|
1860 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
|
1861 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
|
1862 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
|
1863 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
|
1864 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
|
1865 return p; |
| 35742 | 1866 } |
| 1867 | |
| 1868 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
|
1869 Num(object n, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1870 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1871 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
|
1872 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
|
1873 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
|
1874 "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
|
1875 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1876 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1877 p = (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
|
1878 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
|
1879 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1880 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
|
1881 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
|
1882 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
|
1883 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
|
1884 return p; |
| 35742 | 1885 } |
| 1886 | |
| 1887 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
|
1888 Str(string s, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1889 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1890 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
|
1891 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
|
1892 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
|
1893 "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
|
1894 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1895 } |
|
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 = (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
|
1897 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
|
1898 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1899 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
|
1900 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
|
1901 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
|
1902 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
|
1903 return p; |
| 35742 | 1904 } |
| 1905 | |
| 1906 expr_ty | |
|
71792
f578ca44193d
add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents:
71459
diff
changeset
|
1907 Bytes(bytes s, int lineno, int col_offset, PyArena *arena) |
| 40894 | 1908 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1909 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
|
1910 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
|
1911 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
|
1912 "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
|
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 } |
|
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 = (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
|
1916 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
|
1917 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1918 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
|
1919 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
|
1920 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
|
1921 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
|
1922 return p; |
| 40894 | 1923 } |
| 1924 | |
| 1925 expr_ty | |
|
39783
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
1926 Ellipsis(int lineno, int col_offset, PyArena *arena) |
|
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
1927 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1928 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
|
1929 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
|
1930 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
|
1931 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1932 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
|
1933 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
|
1934 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
|
1935 return p; |
|
39783
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
1936 } |
|
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
1937 |
|
7a0ad110e91e
Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents:
39782
diff
changeset
|
1938 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
|
1939 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
|
1940 col_offset, PyArena *arena) |
| 35742 | 1941 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1942 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
|
1943 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
|
1944 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
|
1945 "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
|
1946 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1947 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1948 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
|
1949 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
|
1950 "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
|
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 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1953 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
|
1954 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
|
1955 "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
|
1956 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1957 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1958 p = (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
|
1959 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
|
1960 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1961 p->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
|
1962 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
|
1963 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
|
1964 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
|
1965 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
|
1966 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
|
1967 return p; |
| 35742 | 1968 } |
| 1969 | |
| 1970 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
|
1971 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
|
1972 col_offset, PyArena *arena) |
| 35742 | 1973 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1974 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
|
1975 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
|
1976 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
|
1977 "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
|
1978 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1979 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1980 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
|
1981 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
|
1982 "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
|
1983 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1984 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1985 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
|
1986 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
|
1987 "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
|
1988 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1989 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1990 p = (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
|
1991 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
|
1992 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
1993 p->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
|
1994 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
|
1995 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
|
1996 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
|
1997 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
|
1998 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
|
1999 return p; |
| 35742 | 2000 } |
| 2001 | |
| 2002 expr_ty | |
|
41699
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
2003 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
|
2004 *arena) |
|
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
2005 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2006 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
|
2007 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
|
2008 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
|
2009 "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
|
2010 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2011 } |
|
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 (!ctx) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2013 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
|
2014 "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
|
2015 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2016 } |
|
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 = (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
|
2018 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
|
2019 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2020 p->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
|
2021 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
|
2022 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
|
2023 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
|
2024 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
|
2025 return p; |
|
41699
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
2026 } |
|
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
2027 |
|
e16c8e5c5ca4
Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41471
diff
changeset
|
2028 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
|
2029 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
|
2030 *arena) |
| 35742 | 2031 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2032 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
|
2033 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
|
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 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
|
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 Name"); |
|
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 = 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
|
2047 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
|
2048 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
|
2049 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
|
2050 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
|
2051 return p; |
| 35742 | 2052 } |
| 2053 | |
| 2054 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
|
2055 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
|
2056 *arena) |
| 35742 | 2057 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2058 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
|
2059 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
|
2060 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
|
2061 "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
|
2062 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2063 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2064 p = (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
|
2065 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
|
2066 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2067 p->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
|
2068 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
|
2069 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
|
2070 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
|
2071 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
|
2072 return p; |
| 35742 | 2073 } |
| 2074 | |
| 2075 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
|
2076 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
|
2077 *arena) |
| 35742 | 2078 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2079 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
|
2080 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
|
2081 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
|
2082 "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
|
2083 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2084 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2085 p = (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
|
2086 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
|
2087 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2088 p->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
|
2089 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
|
2090 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
|
2091 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
|
2092 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
|
2093 return p; |
| 35742 | 2094 } |
| 2095 | |
| 2096 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
|
2097 Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena) |
| 35742 | 2098 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2099 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
|
2100 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
|
2101 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
|
2102 return NULL; |
|
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->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
|
2104 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
|
2105 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
|
2106 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
|
2107 return p; |
| 35742 | 2108 } |
| 2109 | |
| 2110 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
|
2111 ExtSlice(asdl_seq * dims, PyArena *arena) |
| 35742 | 2112 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2113 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
|
2114 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
|
2115 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
|
2116 return NULL; |
|
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->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
|
2118 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
|
2119 return p; |
| 35742 | 2120 } |
| 2121 | |
| 2122 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
|
2123 Index(expr_ty value, PyArena *arena) |
| 35742 | 2124 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2125 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
|
2126 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
|
2127 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
|
2128 "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
|
2129 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2130 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2131 p = (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
|
2132 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
|
2133 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2134 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
|
2135 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
|
2136 return p; |
| 35742 | 2137 } |
| 2138 | |
| 2139 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
|
2140 comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena) |
| 35742 | 2141 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2142 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
|
2143 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
|
2144 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
|
2145 "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
|
2146 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2147 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2148 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
|
2149 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
|
2150 "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
|
2151 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2152 } |
|
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 = (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
|
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->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
|
2157 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
|
2158 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
|
2159 return p; |
| 35742 | 2160 } |
| 2161 | |
| 2162 excepthandler_ty | |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
2163 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
|
2164 col_offset, 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 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
|
2167 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
|
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 = 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
|
2171 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
|
2172 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
|
2173 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
|
2174 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
|
2175 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
|
2176 return p; |
| 35742 | 2177 } |
| 2178 | |
| 2179 arguments_ty | |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
2180 arguments(asdl_seq * args, identifier vararg, expr_ty varargannotation, |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
2181 asdl_seq * kwonlyargs, identifier kwarg, expr_ty kwargannotation, |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
2182 asdl_seq * defaults, asdl_seq * kw_defaults, PyArena *arena) |
| 35742 | 2183 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2184 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
|
2185 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
|
2186 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
|
2187 return NULL; |
|
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->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
|
2189 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
|
2190 p->varargannotation = varargannotation; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2191 p->kwonlyargs = kwonlyargs; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2192 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
|
2193 p->kwargannotation = kwargannotation; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2194 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
|
2195 p->kw_defaults = kw_defaults; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2196 return p; |
| 35742 | 2197 } |
| 2198 | |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
2199 arg_ty |
|
41717
9ad84070b22d
Merged revisions 55328-55341 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41699
diff
changeset
|
2200 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
|
2201 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2202 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
|
2203 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
|
2204 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
|
2205 "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
|
2206 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2207 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2208 p = (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
|
2209 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
|
2210 return NULL; |
|
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->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
|
2212 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
|
2213 return p; |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
2214 } |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
2215 |
| 35742 | 2216 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
|
2217 keyword(identifier arg, expr_ty value, 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 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
|
2220 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
|
2221 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
|
2222 "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
|
2223 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2224 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2225 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
|
2226 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
|
2227 "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
|
2228 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2229 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2230 p = (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
|
2231 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
|
2232 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2233 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
|
2234 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
|
2235 return p; |
| 35742 | 2236 } |
| 2237 | |
| 2238 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
|
2239 alias(identifier name, identifier asname, PyArena *arena) |
| 35742 | 2240 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2241 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
|
2242 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
|
2243 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
|
2244 "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
|
2245 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2246 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2247 p = (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
|
2248 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
|
2249 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2250 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
|
2251 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
|
2252 return p; |
| 35742 | 2253 } |
| 2254 | |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
2255 withitem_ty |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
2256 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
|
2257 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2258 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
|
2259 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
|
2260 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
|
2261 "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
|
2262 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2263 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2264 p = (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
|
2265 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
|
2266 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2267 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
|
2268 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
|
2269 return p; |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
2270 } |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
2271 |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2272 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2273 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2274 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
|
2275 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2276 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
|
2277 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
|
2278 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
|
2279 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
|
2280 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
|
2281 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2282 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2283 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
|
2284 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
|
2285 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
|
2286 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
|
2287 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
|
2288 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
|
2289 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
|
2290 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2291 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
|
2292 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2293 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
|
2294 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
|
2295 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
|
2296 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
|
2297 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
|
2298 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
|
2299 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2300 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
|
2301 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2302 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
|
2303 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
|
2304 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
|
2305 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
|
2306 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
|
2307 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
|
2308 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2309 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
|
2310 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2311 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
|
2312 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
|
2313 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
|
2314 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
|
2315 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
|
2316 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
|
2317 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2318 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
|
2319 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2320 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2321 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2322 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
|
2323 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
|
2324 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
|
2325 return NULL; |
| 36174 | 2326 } |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2327 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2328 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2329 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
|
2330 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2331 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
|
2332 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
|
2333 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
|
2334 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
|
2335 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
|
2336 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2337 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2338 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
|
2339 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
|
2340 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
|
2341 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
|
2342 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
|
2343 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
|
2344 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
|
2345 goto 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 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
|
2347 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
|
2348 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
|
2349 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
|
2350 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2351 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
|
2352 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
|
2353 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
|
2354 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
|
2355 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2356 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
|
2357 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
|
2358 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
|
2359 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
|
2360 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2361 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
|
2362 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
|
2363 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
|
2364 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
|
2365 goto 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 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
|
2367 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2368 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
|
2369 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
|
2370 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
|
2371 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
|
2372 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
|
2373 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
|
2374 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2375 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
|
2376 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
|
2377 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
|
2378 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
|
2379 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2380 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
|
2381 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
|
2382 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
|
2383 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
|
2384 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2385 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
|
2386 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
|
2387 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
|
2388 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
|
2389 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2390 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
|
2391 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
|
2392 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
|
2393 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
|
2394 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2395 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
|
2396 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
|
2397 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
|
2398 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
|
2399 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2400 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
|
2401 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
|
2402 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
|
2403 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
|
2404 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2405 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
|
2406 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2407 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
|
2408 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
|
2409 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
|
2410 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
|
2411 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
|
2412 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
|
2413 goto 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 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
|
2415 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2416 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
|
2417 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
|
2418 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
|
2419 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
|
2420 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
|
2421 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
|
2422 goto 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 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
|
2424 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2425 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
|
2426 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
|
2427 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
|
2428 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
|
2429 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
|
2430 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
|
2431 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2432 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
|
2433 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
|
2434 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
|
2435 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
|
2436 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2437 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
|
2438 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2439 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
|
2440 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
|
2441 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
|
2442 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
|
2443 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
|
2444 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
|
2445 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2446 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
|
2447 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
|
2448 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
|
2449 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
|
2450 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2451 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
|
2452 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
|
2453 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
|
2454 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
|
2455 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2456 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
|
2457 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2458 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
|
2459 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
|
2460 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
|
2461 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
|
2462 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
|
2463 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
|
2464 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2465 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
|
2466 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
|
2467 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
|
2468 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
|
2469 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2470 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
|
2471 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
|
2472 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
|
2473 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
|
2474 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2475 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
|
2476 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
|
2477 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
|
2478 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
|
2479 goto 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 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
|
2481 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2482 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
|
2483 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
|
2484 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
|
2485 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
|
2486 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
|
2487 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
|
2488 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2489 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
|
2490 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
|
2491 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
|
2492 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
|
2493 goto 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 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
|
2495 value = ast2obj_list(o->v.While.orelse, ast2obj_stmt); |
| 36669 | 2496 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
|
2497 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
|
2498 goto 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 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
|
2500 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2501 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
|
2502 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
|
2503 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
|
2504 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
|
2505 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
|
2506 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
|
2507 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2508 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
|
2509 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
|
2510 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
|
2511 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
|
2512 goto 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 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
|
2514 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
|
2515 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
|
2516 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
|
2517 goto 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 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
|
2519 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2520 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
|
2521 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
|
2522 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
|
2523 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
|
2524 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
|
2525 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
|
2526 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2527 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
|
2528 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
|
2529 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
|
2530 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
|
2531 goto failed; |
|
36794
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2532 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
|
2533 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2534 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
|
2535 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
|
2536 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
|
2537 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
|
2538 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
|
2539 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
|
2540 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2541 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
|
2542 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
|
2543 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
|
2544 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
|
2545 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2546 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
|
2547 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2548 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
|
2549 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
|
2550 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
|
2551 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
|
2552 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
|
2553 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
|
2554 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2555 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
|
2556 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
|
2557 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
|
2558 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
|
2559 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2560 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
|
2561 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
|
2562 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
|
2563 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
|
2564 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2565 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
|
2566 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
|
2567 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
|
2568 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
|
2569 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2570 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
|
2571 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2572 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
|
2573 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
|
2574 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
|
2575 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
|
2576 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
|
2577 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
|
2578 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2579 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
|
2580 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
|
2581 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
|
2582 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
|
2583 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2584 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
|
2585 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2586 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
|
2587 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
|
2588 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
|
2589 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
|
2590 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
|
2591 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
|
2592 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2593 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
|
2594 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2595 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
|
2596 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
|
2597 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
|
2598 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
|
2599 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
|
2600 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
|
2601 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2602 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
|
2603 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
|
2604 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
|
2605 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
|
2606 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2607 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
|
2608 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
|
2609 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
|
2610 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
|
2611 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2612 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
|
2613 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2614 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
|
2615 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
|
2616 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
|
2617 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
|
2618 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
|
2619 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
|
2620 goto failed; |
|
36794
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2621 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
|
2622 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2623 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
|
2624 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
|
2625 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
|
2626 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
|
2627 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
|
2628 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
|
2629 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2630 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
|
2631 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2632 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
|
2633 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
|
2634 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
|
2635 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
|
2636 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
|
2637 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
|
2638 goto 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 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
|
2640 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2641 case 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
|
2642 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
|
2643 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2644 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2645 case 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
|
2646 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
|
2647 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2648 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2649 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
|
2650 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
|
2651 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
|
2652 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2653 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2654 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
|
2655 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
|
2656 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
|
2657 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2658 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
|
2659 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
|
2660 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
|
2661 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
|
2662 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2663 Py_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
|
2664 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2665 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
|
2666 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
|
2667 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
|
2668 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2669 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2670 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2671 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2672 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
|
2673 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2674 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
|
2675 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
|
2676 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
|
2677 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
|
2678 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
|
2679 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2680 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2681 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
|
2682 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
|
2683 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
|
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_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
|
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_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
|
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 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
|
2691 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
|
2692 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
|
2693 goto 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 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
|
2695 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2696 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
|
2697 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
|
2698 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
|
2699 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
|
2700 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
|
2701 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
|
2702 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2703 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
|
2704 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
|
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_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
|
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_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
|
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_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
|
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 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2715 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
|
2716 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
|
2717 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
|
2718 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
|
2719 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
|
2720 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
|
2721 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2722 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
|
2723 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
|
2724 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
|
2725 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
|
2726 goto failed; |
|
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_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
|
2728 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2729 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
|
2730 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
|
2731 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
|
2732 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
|
2733 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
|
2734 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
|
2735 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2736 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
|
2737 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
|
2738 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
|
2739 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
|
2740 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2741 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
|
2742 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2743 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
|
2744 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
|
2745 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
|
2746 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
|
2747 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
|
2748 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
|
2749 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2750 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
|
2751 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
|
2752 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
|
2753 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
|
2754 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2755 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
|
2756 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
|
2757 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
|
2758 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
|
2759 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2760 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
|
2761 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2762 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
|
2763 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
|
2764 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
|
2765 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
|
2766 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
|
2767 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
|
2768 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2769 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
|
2770 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
|
2771 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
|
2772 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
|
2773 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2774 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
|
2775 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2776 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
|
2777 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
|
2778 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
|
2779 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
|
2780 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
|
2781 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
|
2782 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2783 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
|
2784 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2785 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
|
2786 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
|
2787 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
|
2788 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
|
2789 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
|
2790 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
|
2791 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2792 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
|
2793 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
|
2794 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
|
2795 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
|
2796 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2797 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
|
2798 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2799 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
|
2800 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
|
2801 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
|
2802 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
|
2803 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
|
2804 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
|
2805 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2806 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
|
2807 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
|
2808 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
|
2809 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
|
2810 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2811 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
|
2812 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2813 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
|
2814 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
|
2815 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
|
2816 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
|
2817 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
|
2818 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
|
2819 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2820 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
|
2821 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
|
2822 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
|
2823 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
|
2824 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2825 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
|
2826 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
|
2827 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
|
2828 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
|
2829 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2830 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
|
2831 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2832 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
|
2833 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
|
2834 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
|
2835 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
|
2836 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
|
2837 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
|
2838 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2839 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
|
2840 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
|
2841 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
|
2842 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
|
2843 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
|
2844 goto 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 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
|
2846 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2847 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
|
2848 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
|
2849 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
|
2850 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
|
2851 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
|
2852 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
|
2853 goto 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 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
|
2855 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2856 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
|
2857 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
|
2858 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
|
2859 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
|
2860 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
|
2861 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
|
2862 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2863 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
|
2864 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2865 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
|
2866 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
|
2867 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
|
2868 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
|
2869 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
|
2870 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
|
2871 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2872 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
|
2873 { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2874 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
|
2875 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
|
2876 if (!value) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2877 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
|
2878 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
|
2879 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2880 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
|
2881 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
|
2882 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2883 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
|
2884 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
|
2885 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
|
2886 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
|
2887 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2888 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
|
2889 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2890 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
|
2891 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
|
2892 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
|
2893 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
|
2894 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
|
2895 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
|
2896 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2897 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
|
2898 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
|
2899 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
|
2900 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
|
2901 goto 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 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
|
2903 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
|
2904 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
|
2905 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
|
2906 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2907 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
|
2908 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
|
2909 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
|
2910 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
|
2911 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2912 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
|
2913 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
|
2914 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
|
2915 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
|
2916 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2917 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
|
2918 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2919 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
|
2920 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
|
2921 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
|
2922 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
|
2923 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
|
2924 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
|
2925 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2926 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
|
2927 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2928 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
|
2929 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
|
2930 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
|
2931 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
|
2932 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
|
2933 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
|
2934 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2935 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
|
2936 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2937 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
|
2938 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
|
2939 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
|
2940 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
|
2941 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
|
2942 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
|
2943 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2944 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
|
2945 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2946 case 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
|
2947 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
|
2948 if (!result) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2949 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2950 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
|
2951 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
|
2952 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
|
2953 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
|
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_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
|
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_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
|
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_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
|
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_context(o->v.Attribute.ctx); |
| 36669 | 2964 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
|
2965 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
|
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 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
|
2970 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
|
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_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
|
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_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
|
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 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
|
2978 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
|
2979 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
|
2980 goto 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 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
|
2982 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
|
2983 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
|
2984 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
|
2985 goto failed; |
|
36794
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2986 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
|
2987 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2988 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
|
2989 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
|
2990 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
|
2991 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
|
2992 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
|
2993 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
|
2994 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
2995 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
|
2996 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
|
2997 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
|
2998 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
|
2999 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3000 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
|
3001 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3002 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
|
3003 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
|
3004 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
|
3005 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
|
3006 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
|
3007 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
|
3008 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3009 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
|
3010 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
|
3011 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
|
3012 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
|
3013 goto 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 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
|
3015 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3016 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
|
3017 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
|
3018 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
|
3019 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
|
3020 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
|
3021 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
|
3022 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3023 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
|
3024 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
|
3025 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
|
3026 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
|
3027 goto failed; |
|
36794
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
3028 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
|
3029 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3030 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
|
3031 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
|
3032 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
|
3033 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
|
3034 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
|
3035 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
|
3036 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3037 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
|
3038 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
|
3039 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
|
3040 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
|
3041 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3042 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
|
3043 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3044 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3045 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
|
3046 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
|
3047 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
|
3048 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3049 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
|
3050 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
|
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_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
|
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 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3056 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
|
3057 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
|
3058 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
|
3059 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3060 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3061 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3062 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
|
3063 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3064 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
|
3065 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
|
3066 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
|
3067 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
|
3068 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
|
3069 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
|
3070 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
|
3071 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
|
3072 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
|
3073 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
|
3074 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
|
3075 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
|
3076 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
|
3077 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
|
3078 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
|
3079 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
|
3080 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
|
3081 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
|
3082 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
|
3083 default: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3084 /* 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
|
3085 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
|
3086 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3087 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3088 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3089 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3090 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
|
3091 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3092 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
|
3093 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
|
3094 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
|
3095 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
|
3096 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
|
3097 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3098 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3099 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
|
3100 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
|
3101 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
|
3102 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
|
3103 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
|
3104 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
|
3105 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
|
3106 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3107 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
|
3108 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
|
3109 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
|
3110 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
|
3111 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3112 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
|
3113 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
|
3114 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
|
3115 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
|
3116 goto failed; |
|
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_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
|
3118 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3119 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
|
3120 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
|
3121 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
|
3122 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
|
3123 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
|
3124 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
|
3125 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3126 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
|
3127 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3128 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
|
3129 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
|
3130 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
|
3131 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
|
3132 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
|
3133 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
|
3134 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3135 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
|
3136 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3137 } |
|
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 result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3139 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
|
3140 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
|
3141 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
|
3142 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3143 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3144 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3145 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
|
3146 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3147 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
|
3148 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
|
3149 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
|
3150 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
|
3151 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
|
3152 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
|
3153 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
|
3154 default: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3155 /* 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
|
3156 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
|
3157 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3158 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3159 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3160 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
|
3161 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3162 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
|
3163 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
|
3164 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
|
3165 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
|
3166 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
|
3167 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
|
3168 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
|
3169 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
|
3170 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
|
3171 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
|
3172 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
|
3173 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
|
3174 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
|
3175 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
|
3176 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
|
3177 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
|
3178 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
|
3179 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
|
3180 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
|
3181 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
|
3182 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
|
3183 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
|
3184 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
|
3185 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
|
3186 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
|
3187 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
|
3188 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
|
3189 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
|
3190 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
|
3191 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
|
3192 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
|
3193 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
|
3194 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
|
3195 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
|
3196 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
|
3197 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
|
3198 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
|
3199 default: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3200 /* 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
|
3201 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
|
3202 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
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 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3205 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
|
3206 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3207 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
|
3208 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
|
3209 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
|
3210 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
|
3211 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
|
3212 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
|
3213 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
|
3214 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
|
3215 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
|
3216 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
|
3217 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
|
3218 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
|
3219 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
|
3220 default: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3221 /* 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
|
3222 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
|
3223 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3224 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3225 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3226 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
|
3227 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3228 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
|
3229 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
|
3230 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
|
3231 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
|
3232 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
|
3233 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
|
3234 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
|
3235 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
|
3236 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
|
3237 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
|
3238 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
|
3239 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
|
3240 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
|
3241 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
|
3242 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
|
3243 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
|
3244 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
|
3245 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
|
3246 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
|
3247 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
|
3248 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
|
3249 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
|
3250 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
|
3251 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
|
3252 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
|
3253 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
|
3254 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
|
3255 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
|
3256 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
|
3257 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
|
3258 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
|
3259 default: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3260 /* 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
|
3261 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
|
3262 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3263 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3264 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3265 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3266 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
|
3267 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3268 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
|
3269 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
|
3270 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
|
3271 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
|
3272 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
|
3273 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3274 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3275 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
|
3276 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
|
3277 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
|
3278 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
|
3279 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
|
3280 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3281 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
|
3282 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
|
3283 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
|
3284 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
|
3285 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3286 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
|
3287 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
|
3288 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
|
3289 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
|
3290 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3291 Py_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
|
3292 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3293 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
|
3294 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
|
3295 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
|
3296 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3297 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3298 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3299 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3300 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
|
3301 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3302 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
|
3303 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
|
3304 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
|
3305 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
|
3306 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
|
3307 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3308 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3309 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
|
3310 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
|
3311 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
|
3312 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
|
3313 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
|
3314 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
|
3315 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
|
3316 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3317 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
|
3318 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
|
3319 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
|
3320 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
|
3321 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
|
3322 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
|
3323 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
|
3324 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
|
3325 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
|
3326 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
|
3327 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
|
3328 break; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3329 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3330 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
|
3331 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
|
3332 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
|
3333 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3334 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
|
3335 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
|
3336 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
|
3337 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
|
3338 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3339 Py_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
|
3340 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3341 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
|
3342 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
|
3343 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
|
3344 return NULL; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3345 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3346 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3347 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3348 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
|
3349 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3350 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
|
3351 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
|
3352 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
|
3353 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
|
3354 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
|
3355 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3356 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3357 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
|
3358 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
|
3359 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
|
3360 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
|
3361 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
|
3362 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3363 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
|
3364 value = ast2obj_identifier(o->vararg); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3365 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
|
3366 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
|
3367 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3368 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
|
3369 value = ast2obj_expr(o->varargannotation); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3370 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
|
3371 if (_PyObject_SetAttrId(result, &PyId_varargannotation, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3372 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3373 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
|
3374 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
|
3375 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
|
3376 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
|
3377 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3378 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
|
3379 value = ast2obj_identifier(o->kwarg); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3380 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
|
3381 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
|
3382 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3383 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
|
3384 value = ast2obj_expr(o->kwargannotation); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3385 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
|
3386 if (_PyObject_SetAttrId(result, &PyId_kwargannotation, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3387 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3388 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
|
3389 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
|
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_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
|
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_list(o->kw_defaults, ast2obj_expr); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
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_kw_defaults, value) == -1) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
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* |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3407 ast2obj_arg(void* _o) |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
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 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
|
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(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
|
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_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
|
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_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
|
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); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3423 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
|
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_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
|
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 return result; |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3429 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
|
3430 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
|
3431 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
|
3432 return NULL; |
|
40529
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3433 } |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3434 |
|
54cd47788811
PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents:
40215
diff
changeset
|
3435 PyObject* |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3436 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
|
3437 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3438 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
|
3439 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
|
3440 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
|
3441 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
|
3442 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
|
3443 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3444 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3445 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
|
3446 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
|
3447 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
|
3448 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
|
3449 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
|
3450 goto failed; |
|
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_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
|
3452 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
|
3453 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
|
3454 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
|
3455 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3456 Py_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
|
3457 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3458 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
|
3459 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
|
3460 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
|
3461 return NULL; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3462 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3463 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3464 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3465 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
|
3466 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3467 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
|
3468 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
|
3469 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
|
3470 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
|
3471 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
|
3472 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3473 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3474 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
|
3475 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
|
3476 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
|
3477 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
|
3478 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
|
3479 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3480 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
|
3481 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
|
3482 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
|
3483 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
|
3484 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3485 Py_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
|
3486 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3487 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
|
3488 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
|
3489 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
|
3490 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3491 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3492 |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
3493 PyObject* |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
3494 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
|
3495 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3496 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
|
3497 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
|
3498 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
|
3499 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
|
3500 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
|
3501 } |
|
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 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
|
3504 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
|
3505 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
|
3506 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
|
3507 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
|
3508 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3509 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
|
3510 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
|
3511 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
|
3512 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
|
3513 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3514 Py_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
|
3515 return result; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3516 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
|
3517 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
|
3518 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
|
3519 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3520 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3521 |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3522 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3523 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3524 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
|
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 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
|
3527 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3528 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
|
3529 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3530 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
|
3531 *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
|
3532 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3533 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3534 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
|
3535 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
|
3536 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
|
3537 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3538 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
|
3539 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
|
3540 |
|
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 (_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
|
3542 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3543 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
|
3544 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
|
3545 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
|
3546 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3547 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
|
3548 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
|
3549 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3550 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3551 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
|
3552 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
|
3553 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
|
3554 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
|
3555 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
|
3556 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
|
3557 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
|
3558 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
|
3559 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3560 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3561 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3562 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
|
3563 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
3564 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3565 *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
|
3566 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
|
3567 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3568 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3569 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
|
3570 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
|
3571 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
|
3572 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3573 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
|
3574 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
|
3575 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3576 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
|
3577 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3578 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
|
3579 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
|
3580 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
|
3581 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3582 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
|
3583 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
|
3584 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3585 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3586 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
|
3587 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
|
3588 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
|
3589 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
|
3590 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
|
3591 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
|
3592 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
|
3593 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
|
3594 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3595 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3596 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3597 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
|
3598 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
3599 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3600 *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
|
3601 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
|
3602 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3603 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3604 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
|
3605 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
|
3606 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
|
3607 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3608 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
|
3609 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
|
3610 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3611 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
|
3612 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3613 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
|
3614 if (tmp == NULL) goto failed; |
|
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_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
|
3616 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3617 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3618 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3619 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
|
3620 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
3621 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3622 *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
|
3623 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
|
3624 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3625 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3626 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
|
3627 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
|
3628 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
|
3629 } |
|
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) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3631 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
|
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 (_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
|
3634 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3635 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
|
3636 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
|
3637 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
|
3638 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3639 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
|
3640 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
|
3641 goto 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 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3643 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
|
3644 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
|
3645 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
|
3646 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
|
3647 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
|
3648 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
|
3649 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
|
3650 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
|
3651 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3652 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3653 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3654 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
|
3655 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3656 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3657 *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
|
3658 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
|
3659 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3660 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3661 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3662 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
|
3663 failed: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3664 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
|
3665 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3666 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3667 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3668 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3669 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
|
3670 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3671 int isinstance; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3672 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3673 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
|
3674 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
|
3675 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
|
3676 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3677 if (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
|
3678 *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
|
3679 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3680 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3681 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
|
3682 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3683 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
|
3684 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3685 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
|
3686 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3687 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3688 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3689 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
|
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 (_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
|
3693 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3694 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
|
3695 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3696 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
|
3697 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3698 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3699 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3700 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
|
3701 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3702 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3703 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
|
3704 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
|
3705 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
|
3706 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3708 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
|
3709 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
|
3710 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
|
3711 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
|
3712 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
|
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 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
|
3715 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3716 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
|
3717 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3718 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
|
3719 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3720 Py_CLEAR(tmp); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3721 } 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
|
3722 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
|
3723 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
|
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 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
|
3726 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3727 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
|
3728 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3729 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
|
3730 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3731 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3732 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3733 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
|
3734 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3735 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3736 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
|
3737 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3738 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
|
3739 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
|
3740 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
|
3741 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3742 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
|
3743 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
|
3744 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3745 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3746 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
|
3747 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
|
3748 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
|
3749 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
|
3750 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
|
3751 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
|
3752 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
|
3753 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
|
3754 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3755 Py_CLEAR(tmp); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3756 } 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
|
3757 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
|
3758 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3759 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3760 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
|
3761 int res; |
|
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_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
|
3763 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
|
3764 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
|
3765 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3766 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
|
3767 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
|
3768 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3769 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3770 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
|
3771 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
|
3772 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
|
3773 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
|
3774 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
|
3775 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
|
3776 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
|
3777 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
|
3778 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3779 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3780 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3781 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
|
3782 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
|
3783 } |
|
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 (_PyObject_HasAttrId(obj, &PyId_returns)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3785 int res; |
|
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 = _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
|
3787 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3788 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
|
3789 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3790 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3791 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3792 returns = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
3793 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3794 *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
|
3795 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
|
3796 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
|
3797 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3798 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3799 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
|
3800 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
|
3801 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
|
3802 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3804 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
|
3805 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
|
3806 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
|
3807 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
|
3808 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
|
3809 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
|
3810 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
|
3811 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3812 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
|
3813 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3814 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
|
3815 if (tmp == NULL) goto 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 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
|
3817 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3818 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3819 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3820 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
|
3821 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
|
3822 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3823 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
|
3824 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3825 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
|
3826 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
|
3827 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
|
3828 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3829 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
|
3830 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
|
3831 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3832 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3833 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
|
3834 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
|
3835 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
|
3836 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
|
3837 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
|
3838 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
|
3839 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
|
3840 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
|
3841 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3842 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3843 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3844 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
|
3845 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3846 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3847 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
|
3848 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3849 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
|
3850 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
|
3851 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
|
3852 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3853 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
|
3854 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
|
3855 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3856 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3857 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
|
3858 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
|
3859 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
|
3860 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
|
3861 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
|
3862 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
|
3863 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
|
3864 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
|
3865 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3866 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3867 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3868 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
|
3869 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
|
3870 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3871 if (_PyObject_HasAttrId(obj, &PyId_starargs)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3872 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3873 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
|
3874 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3875 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
|
3876 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3877 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3878 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3879 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
|
3880 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3881 if (_PyObject_HasAttrId(obj, &PyId_kwargs)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3882 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3883 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
|
3884 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3885 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
|
3886 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3887 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3888 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3889 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
|
3890 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3891 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
|
3892 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3893 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
|
3894 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
|
3895 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
|
3896 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3897 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
|
3898 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
|
3899 goto 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 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3901 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
|
3902 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
|
3903 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
|
3904 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
|
3905 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
|
3906 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
|
3907 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
|
3908 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
|
3909 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3910 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3911 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3912 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
|
3913 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
|
3914 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3915 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
|
3916 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3917 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
|
3918 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
|
3919 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
|
3920 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3921 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
|
3922 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
|
3923 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3924 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3925 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
|
3926 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
|
3927 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
|
3928 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
|
3929 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
|
3930 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
|
3931 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
|
3932 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
|
3933 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3934 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3935 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3936 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
|
3937 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
3938 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3939 *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
|
3940 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
|
3941 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
|
3942 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3943 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3944 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
|
3945 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
|
3946 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
|
3947 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3948 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
|
3949 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
|
3950 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3951 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
|
3952 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3953 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
|
3954 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3955 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
|
3956 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3957 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3958 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3959 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
|
3960 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3961 *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
|
3962 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
|
3963 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3964 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3965 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
|
3966 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
|
3967 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
|
3968 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3969 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
|
3970 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
|
3971 |
|
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 (_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
|
3973 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3974 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
|
3975 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
|
3976 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
|
3977 if (tmp == NULL) goto failed; |
|
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 (!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
|
3979 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
|
3980 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3981 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3982 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
|
3983 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
|
3984 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
|
3985 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
|
3986 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
|
3987 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
|
3988 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
|
3989 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
|
3990 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
3991 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3992 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3993 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
|
3994 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
3995 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3996 *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
|
3997 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
|
3998 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
3999 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4000 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
|
4001 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
|
4002 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
|
4003 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4004 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4005 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
|
4006 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
|
4007 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4008 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
|
4009 int res; |
|
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_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
|
4011 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
|
4012 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
|
4013 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4014 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
|
4015 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
|
4016 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4017 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4018 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
|
4019 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
|
4020 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
|
4021 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
|
4022 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
|
4023 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
|
4024 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
|
4025 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
|
4026 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4027 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4028 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4029 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
|
4030 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
|
4031 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4032 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
|
4033 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4034 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
|
4035 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4036 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
|
4037 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4038 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4039 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4040 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
|
4041 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4042 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4043 *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
|
4044 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
|
4045 return 0; |
|
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 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
|
4048 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
|
4049 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
|
4050 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4051 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
|
4052 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
|
4053 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
|
4054 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
|
4055 |
|
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 (_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
|
4057 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4058 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
|
4059 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4060 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
|
4061 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4062 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4063 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4064 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
|
4065 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
|
4066 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4067 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
|
4068 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4069 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
|
4070 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4071 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
|
4072 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4073 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4074 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4075 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
|
4076 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4077 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4078 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
|
4079 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4080 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
|
4081 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4082 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
|
4083 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4084 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4085 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4086 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
|
4087 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4088 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4089 *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
|
4090 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
|
4091 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4092 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4093 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
|
4094 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
|
4095 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
|
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 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
|
4098 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
|
4099 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
|
4100 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
|
4101 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
|
4102 |
|
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 (_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
|
4104 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4105 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
|
4106 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4107 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
|
4108 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4109 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4110 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4111 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
|
4112 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4113 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4114 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
|
4115 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4116 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
|
4117 if (tmp == NULL) goto 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 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
|
4119 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4120 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4121 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4122 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
|
4123 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
|
4124 } |
|
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 (_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
|
4126 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4127 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
|
4128 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
|
4129 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
|
4130 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4131 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
|
4132 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
|
4133 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4134 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4135 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
|
4136 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
|
4137 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
|
4138 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
|
4139 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
|
4140 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
|
4141 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
|
4142 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
|
4143 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4144 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
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 \"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
|
4147 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4148 } |
|
84850
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_orelse)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4150 int 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 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
|
4152 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
|
4153 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
|
4154 if (tmp == NULL) goto 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 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
|
4156 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
|
4157 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4158 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4159 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
|
4160 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
|
4161 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
|
4162 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
|
4163 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
|
4164 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
|
4165 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
|
4166 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
|
4167 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4168 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
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 \"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
|
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 = 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
|
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*)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
|
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 test; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4183 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
|
4184 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
|
4185 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4186 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
|
4187 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4188 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
|
4189 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4190 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
|
4191 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4192 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4193 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4194 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
|
4195 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4196 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4197 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
|
4198 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4199 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
|
4200 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
|
4201 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
|
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 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
|
4204 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
|
4205 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4206 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4207 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
|
4208 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
|
4209 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
|
4210 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
|
4211 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
|
4212 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
|
4213 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
|
4214 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
|
4215 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4216 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4217 } else { |
|
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_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
|
4219 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4220 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4221 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
|
4222 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4223 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
|
4224 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
|
4225 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
|
4226 if (tmp == NULL) goto failed; |
|
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 (!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
|
4228 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
|
4229 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4230 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4231 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
|
4232 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
|
4233 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
|
4234 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
|
4235 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
|
4236 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
|
4237 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
|
4238 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
|
4239 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4240 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4241 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4242 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
|
4243 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
|
4244 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4245 *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
|
4246 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
|
4247 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4248 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4249 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
|
4250 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
|
4251 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
|
4252 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4253 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
|
4254 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
|
4255 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
|
4256 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
|
4257 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4258 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
|
4259 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4260 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
|
4261 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4262 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
|
4263 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4264 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4265 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4266 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
|
4267 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4268 } |
|
84850
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 (_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
|
4270 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4271 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
|
4272 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
|
4273 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
|
4274 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4275 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
|
4276 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
|
4277 goto 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 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4279 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
|
4280 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
|
4281 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
|
4282 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
|
4283 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
|
4284 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
|
4285 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
|
4286 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
|
4287 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4288 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4289 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4290 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
|
4291 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
|
4292 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4293 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
|
4294 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4295 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
|
4296 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
|
4297 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
|
4298 if (tmp == NULL) goto 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 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
|
4300 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
|
4301 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4302 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4303 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
|
4304 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
|
4305 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
|
4306 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
|
4307 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
|
4308 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
|
4309 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
|
4310 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
|
4311 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4312 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4313 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4314 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
|
4315 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
|
4316 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4317 *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
|
4318 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
|
4319 return 0; |
|
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 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
|
4322 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
|
4323 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
|
4324 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4325 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4326 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
|
4327 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
|
4328 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4329 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
|
4330 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4331 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
|
4332 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
|
4333 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
|
4334 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4335 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
|
4336 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
|
4337 goto 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 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4339 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
|
4340 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
|
4341 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
|
4342 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
|
4343 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
|
4344 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
|
4345 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
|
4346 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
|
4347 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4348 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4349 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4350 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
|
4351 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4352 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4353 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
|
4354 int res; |
|
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_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
|
4356 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
|
4357 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
|
4358 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4359 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
|
4360 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
|
4361 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4362 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4363 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
|
4364 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
|
4365 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
|
4366 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
|
4367 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
|
4368 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
|
4369 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
|
4370 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
|
4371 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4372 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4373 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4374 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
|
4375 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4376 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4377 *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
|
4378 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
|
4379 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4380 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4381 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
|
4382 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
|
4383 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
|
4384 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4385 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4386 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
|
4387 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
|
4388 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4389 if (_PyObject_HasAttrId(obj, &PyId_exc)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4390 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4391 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
|
4392 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4393 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
|
4394 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4395 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4396 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4397 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
|
4398 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4399 if (_PyObject_HasAttrId(obj, &PyId_cause)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4400 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4401 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
|
4402 if (tmp == NULL) goto 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 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
|
4404 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4405 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4406 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4407 cause = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4408 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4409 *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
|
4410 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
|
4411 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4412 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4413 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
|
4414 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
|
4415 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
|
4416 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4417 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
|
4418 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
|
4419 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
|
4420 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
|
4421 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
|
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_body)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4424 int 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_body); |
|
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, "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
|
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 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
|
4435 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
|
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 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
|
4438 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
|
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(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
|
4441 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4442 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4443 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4444 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
|
4445 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4446 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4447 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
|
4448 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4449 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
|
4450 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
|
4451 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
|
4452 if (tmp == NULL) goto failed; |
|
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 (!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
|
4454 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
|
4455 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4456 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4457 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
|
4458 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
|
4459 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
|
4460 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
|
4461 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
|
4462 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
|
4463 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
|
4464 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
|
4465 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4466 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4467 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4468 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
|
4469 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4470 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4471 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
|
4472 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4473 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
|
4474 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
|
4475 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
|
4476 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4477 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
|
4478 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
|
4479 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4480 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4481 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
|
4482 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
|
4483 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
|
4484 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
|
4485 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
|
4486 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
|
4487 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
|
4488 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
|
4489 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4490 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4491 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4492 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
|
4493 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4494 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4495 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
|
4496 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4497 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
|
4498 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
|
4499 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
|
4500 if (tmp == NULL) goto failed; |
|
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 (!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
|
4502 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
|
4503 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4504 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4505 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
|
4506 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
|
4507 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
|
4508 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
|
4509 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
|
4510 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
|
4511 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
|
4512 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
|
4513 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4514 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4515 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4516 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
|
4517 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
|
4518 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4519 *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
|
4520 arena); |
|
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 (*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
|
4522 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4523 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4524 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
|
4525 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
|
4526 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
|
4527 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4528 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4529 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
|
4530 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
|
4531 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4532 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
|
4533 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4534 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
|
4535 if (tmp == NULL) goto failed; |
|
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_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
|
4537 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4538 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4539 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4540 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
|
4541 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
|
4542 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4543 if (_PyObject_HasAttrId(obj, &PyId_msg)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4544 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4545 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
|
4546 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4547 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
|
4548 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4549 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4550 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4551 msg = NULL; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4552 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4553 *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
|
4554 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
|
4555 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4556 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4557 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
|
4558 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
|
4559 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
|
4560 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4561 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
|
4562 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
|
4563 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4564 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
|
4565 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4566 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
|
4567 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
|
4568 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
|
4569 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4570 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
|
4571 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
|
4572 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4573 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4574 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
|
4575 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
|
4576 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
|
4577 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
|
4578 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
|
4579 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
|
4580 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
|
4581 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
|
4582 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4583 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4584 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4585 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
|
4586 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4587 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4588 *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
|
4589 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
|
4590 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4591 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4592 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
|
4593 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
|
4594 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
|
4595 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4597 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
|
4598 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
|
4599 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
|
4600 |
|
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 (_PyObject_HasAttrId(obj, &PyId_module)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4602 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4603 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
|
4604 if (tmp == NULL) goto 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 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
|
4606 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4607 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4608 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4609 module = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4610 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4611 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
|
4612 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4613 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
|
4614 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
|
4615 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
|
4616 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4617 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
|
4618 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
|
4619 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4620 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4621 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
|
4622 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
|
4623 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
|
4624 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
|
4625 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
|
4626 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
|
4627 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
|
4628 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
|
4629 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4630 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4631 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4632 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
|
4633 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4634 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4635 if (_PyObject_HasAttrId(obj, &PyId_level)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4636 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4637 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
|
4638 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4639 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
|
4640 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4641 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
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 level = 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4644 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4645 *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
|
4646 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
|
4647 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4648 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4649 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
|
4650 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
|
4651 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
|
4652 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4653 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
|
4654 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
|
4655 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4656 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
|
4657 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4658 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
|
4659 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
|
4660 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
|
4661 if (tmp == NULL) goto failed; |
|
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 (!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
|
4663 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
|
4664 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4665 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4666 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
|
4667 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
|
4668 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
|
4669 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
|
4670 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
|
4671 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
|
4672 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
|
4673 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
|
4674 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4675 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4676 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4677 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
|
4678 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4679 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4680 *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
|
4681 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
|
4682 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4683 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4684 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
|
4685 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
|
4686 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
|
4687 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4688 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
|
4689 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
|
4690 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4691 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
|
4692 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4693 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
|
4694 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
|
4695 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
|
4696 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4697 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
|
4698 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
|
4699 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4700 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4701 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
|
4702 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
|
4703 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
|
4704 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
|
4705 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
|
4706 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
|
4707 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
|
4708 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
|
4709 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4710 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4711 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4712 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
|
4713 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4714 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4715 *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
|
4716 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
|
4717 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4718 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4719 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
|
4720 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
|
4721 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
|
4722 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4724 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
|
4725 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4726 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
|
4727 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4728 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
|
4729 if (tmp == NULL) goto 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 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
|
4731 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4732 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4733 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4734 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
|
4735 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4736 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4737 *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
|
4738 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
|
4739 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4740 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4741 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
|
4742 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
|
4743 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
|
4744 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4746 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4747 *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
|
4748 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
|
4749 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4750 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4751 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
|
4752 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4753 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
|
4754 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4755 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
|
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 *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
|
4758 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
|
4759 return 0; |
|
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 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
|
4762 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
|
4763 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
|
4764 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4765 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
|
4766 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4767 *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
|
4768 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
|
4769 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4770 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4771 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4772 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
|
4773 failed: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4774 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
|
4775 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4776 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4777 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4778 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4779 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
|
4780 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4781 int isinstance; |
|
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 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
|
4784 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
|
4785 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
|
4786 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4787 if (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
|
4788 *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
|
4789 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4790 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4791 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
|
4792 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4793 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
|
4794 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4795 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
|
4796 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4797 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4798 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4799 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
|
4800 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
|
4801 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4802 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
|
4803 int res; |
|
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_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
|
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 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
|
4807 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4808 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4809 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4810 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
|
4811 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4812 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4813 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
|
4814 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
|
4815 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
|
4816 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4817 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4818 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
|
4819 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
|
4820 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4821 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
|
4822 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4823 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
|
4824 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4825 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
|
4826 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4827 Py_CLEAR(tmp); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4828 } 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
|
4829 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
|
4830 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4831 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4832 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
|
4833 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4834 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
|
4835 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
|
4836 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
|
4837 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4838 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
|
4839 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
|
4840 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4841 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4842 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
|
4843 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
|
4844 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
|
4845 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
|
4846 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
|
4847 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
|
4848 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
|
4849 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
|
4850 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4851 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4852 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4853 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
|
4854 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4855 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4856 *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
|
4857 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
|
4858 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4859 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4860 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
|
4861 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
|
4862 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
|
4863 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4864 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
|
4865 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
|
4866 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
|
4867 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
|
4868 |
|
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 (_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
|
4870 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4871 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
|
4872 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4873 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
|
4874 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4875 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4876 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4877 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
|
4878 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4879 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4880 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
|
4881 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4882 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
|
4883 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4884 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
|
4885 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4886 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4887 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4888 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
|
4889 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4890 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4891 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
|
4892 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4893 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
|
4894 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4895 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
|
4896 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4897 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4898 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4899 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
|
4900 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4901 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4902 *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
|
4903 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
|
4904 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4905 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4906 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
|
4907 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
|
4908 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
|
4909 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4910 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4911 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
|
4912 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
|
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_op)) { |
|
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_op); |
|
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_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
|
4919 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4920 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4921 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4922 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
|
4923 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4924 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4925 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
|
4926 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4927 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
|
4928 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4929 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
|
4930 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4931 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4932 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4933 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
|
4934 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4935 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4936 *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
|
4937 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
|
4938 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4939 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4940 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
|
4941 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
|
4942 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
|
4943 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4944 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4945 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
|
4946 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
|
4947 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4948 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
|
4949 int res; |
|
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_args); |
|
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 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
|
4953 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4954 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4955 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4956 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
|
4957 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
4958 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4959 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
|
4960 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4961 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
|
4962 if (tmp == NULL) goto 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 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
|
4964 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4965 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4966 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4967 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
|
4968 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4969 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4970 *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
|
4971 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
|
4972 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4973 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4974 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
|
4975 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
|
4976 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
|
4977 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4978 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
|
4979 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
|
4980 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
|
4981 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
|
4982 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4983 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
|
4984 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4985 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
|
4986 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4987 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
|
4988 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
4989 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4990 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4991 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
|
4992 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
4993 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4994 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
|
4995 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4996 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
|
4997 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
4998 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
|
4999 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5000 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5001 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5002 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
|
5003 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5004 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5005 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
|
5006 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5007 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
|
5008 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5009 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
|
5010 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5011 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5012 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5013 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
|
5014 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5015 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5016 *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
|
5017 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
|
5018 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5019 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5020 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
|
5021 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
|
5022 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
|
5023 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5024 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5025 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
|
5026 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
|
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 (_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
|
5029 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5030 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
|
5031 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
|
5032 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
|
5033 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5034 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
|
5035 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
|
5036 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5037 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5038 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
|
5039 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
|
5040 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
|
5041 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
|
5042 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
|
5043 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
|
5044 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
|
5045 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
|
5046 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5047 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5048 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5049 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
|
5050 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5051 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5052 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
|
5053 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5054 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
|
5055 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
|
5056 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
|
5057 if (tmp == NULL) goto 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 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
|
5059 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
|
5060 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5061 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5062 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
|
5063 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
|
5064 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
|
5065 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
|
5066 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
|
5067 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
|
5068 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
|
5069 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
|
5070 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5071 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5072 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5073 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
|
5074 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5075 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5076 *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
|
5077 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
|
5078 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5079 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5080 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
|
5081 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
|
5082 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
|
5083 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5084 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
|
5085 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
|
5086 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5087 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
|
5088 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5089 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
|
5090 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
|
5091 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
|
5092 if (tmp == NULL) goto failed; |
|
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 (!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
|
5094 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
|
5095 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5096 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5097 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
|
5098 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
|
5099 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
|
5100 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
|
5101 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
|
5102 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
|
5103 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
|
5104 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
|
5105 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5106 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5107 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5108 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
|
5109 return 1; |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
5110 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5111 *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
|
5112 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
|
5113 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5114 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5115 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
|
5116 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
|
5117 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
|
5118 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5119 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5120 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
|
5121 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
|
5122 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5123 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
|
5124 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5125 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
|
5126 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5127 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
|
5128 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5129 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5130 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5131 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
|
5132 return 1; |
|
74391
e1177b9167ce
make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents:
74358
diff
changeset
|
5133 } |
|
84850
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 (_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
|
5135 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5136 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
|
5137 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
|
5138 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
|
5139 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5140 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
|
5141 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
|
5142 goto 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 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5144 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
|
5145 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
|
5146 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
|
5147 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
|
5148 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
|
5149 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
|
5150 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
|
5151 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
|
5152 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5153 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5154 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5155 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
|
5156 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5157 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5158 *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
|
5159 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
|
5160 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5161 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5162 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
|
5163 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
|
5164 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
|
5165 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5166 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5167 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
|
5168 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
|
5169 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5170 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
|
5171 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5172 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
|
5173 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5174 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
|
5175 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5176 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5177 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5178 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
|
5179 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5180 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5181 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
|
5182 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5183 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
|
5184 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
|
5185 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
|
5186 if (tmp == NULL) goto 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 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
|
5188 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
|
5189 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5190 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5191 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
|
5192 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
|
5193 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
|
5194 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
|
5195 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
|
5196 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
|
5197 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
|
5198 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
|
5199 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5200 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5201 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5202 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
|
5203 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
|
5204 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5205 *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
|
5206 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
|
5207 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5208 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5209 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
|
5210 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
|
5211 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
|
5212 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5213 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
|
5214 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
|
5215 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
|
5216 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
|
5217 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5218 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
|
5219 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5220 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
|
5221 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5222 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
|
5223 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5224 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5225 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5226 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
|
5227 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5228 } |
|
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 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
|
5230 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5231 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
|
5232 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5233 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
|
5234 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5235 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5236 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5237 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
|
5238 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
|
5239 } |
|
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 (_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
|
5241 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5242 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
|
5243 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
|
5244 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
|
5245 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5246 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
|
5247 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
|
5248 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5249 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5250 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
|
5251 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
|
5252 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
|
5253 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
|
5254 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
|
5255 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
|
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 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
|
5258 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5259 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5260 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5261 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
|
5262 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
|
5263 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5264 *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
|
5265 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
|
5266 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5267 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5268 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
|
5269 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
|
5270 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
|
5271 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5272 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5273 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
|
5274 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
|
5275 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5276 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
|
5277 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5278 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
|
5279 if (tmp == NULL) goto 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 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
|
5281 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5282 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5283 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5284 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
|
5285 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5286 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5287 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
|
5288 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5289 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
|
5290 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
|
5291 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
|
5292 if (tmp == NULL) goto failed; |
|
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 (!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
|
5294 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
|
5295 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5296 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5297 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
|
5298 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
|
5299 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
|
5300 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
|
5301 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
|
5302 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
|
5303 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
|
5304 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
|
5305 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5306 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5307 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5308 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
|
5309 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
|
5310 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5311 *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
|
5312 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
|
5313 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5314 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5315 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
|
5316 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
|
5317 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
|
5318 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5319 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
|
5320 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
|
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 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
|
5323 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5324 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
|
5325 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5326 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
|
5327 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5328 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5329 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5330 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
|
5331 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5332 *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
|
5333 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
|
5334 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5335 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5336 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
|
5337 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
|
5338 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
|
5339 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5340 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
|
5341 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
|
5342 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5343 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
|
5344 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5345 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
|
5346 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5347 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
|
5348 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5349 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5350 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5351 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
|
5352 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
|
5353 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5354 *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
|
5355 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
|
5356 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5357 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5358 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
|
5359 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
|
5360 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
|
5361 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5363 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
|
5364 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
|
5365 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
|
5366 |
|
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 (_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
|
5368 int res; |
|
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 = _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
|
5370 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5371 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
|
5372 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5373 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5374 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5375 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
|
5376 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5377 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5378 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
|
5379 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5380 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
|
5381 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
|
5382 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
|
5383 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5384 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
|
5385 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
|
5386 goto 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 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5388 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
|
5389 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
|
5390 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
|
5391 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
|
5392 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
|
5393 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
|
5394 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
|
5395 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
|
5396 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5397 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5398 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5399 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
|
5400 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5401 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5402 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
|
5403 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5404 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
|
5405 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
|
5406 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
|
5407 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5408 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
|
5409 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
|
5410 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5411 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5412 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
|
5413 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
|
5414 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
|
5415 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
|
5416 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
|
5417 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
|
5418 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
|
5419 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
|
5420 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5421 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5422 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5423 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
|
5424 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5425 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5426 *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
|
5427 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
|
5428 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5429 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5430 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
|
5431 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
|
5432 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
|
5433 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5434 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
|
5435 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
|
5436 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
|
5437 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
|
5438 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
|
5439 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
|
5440 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5441 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
|
5442 int res; |
|
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 = _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
|
5444 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5445 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
|
5446 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5447 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5448 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5449 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
|
5450 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5451 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5452 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
|
5453 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5454 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
|
5455 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
|
5456 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
|
5457 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5458 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
|
5459 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
|
5460 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5461 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5462 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
|
5463 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
|
5464 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
|
5465 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
|
5466 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
|
5467 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
|
5468 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
|
5469 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
|
5470 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5471 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5472 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5473 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
|
5474 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5475 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5476 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
|
5477 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5478 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
|
5479 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
|
5480 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
|
5481 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5482 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
|
5483 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
|
5484 goto 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 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5486 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
|
5487 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
|
5488 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
|
5489 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
|
5490 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
|
5491 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
|
5492 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
|
5493 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
|
5494 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5495 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5496 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5497 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
|
5498 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
|
5499 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5500 if (_PyObject_HasAttrId(obj, &PyId_starargs)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5501 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5502 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
|
5503 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5504 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
|
5505 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5506 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5507 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5508 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
|
5509 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5510 if (_PyObject_HasAttrId(obj, &PyId_kwargs)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5511 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5512 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
|
5513 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5514 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
|
5515 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5516 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5517 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5518 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
|
5519 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5520 *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
|
5521 arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5522 if (*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
|
5523 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5524 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5525 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
|
5526 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
|
5527 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
|
5528 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5529 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
|
5530 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
|
5531 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5532 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
|
5533 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5534 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
|
5535 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5536 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
|
5537 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5538 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
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 \"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
|
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 *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
|
5544 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
|
5545 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5546 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5547 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
|
5548 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
|
5549 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
|
5550 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5551 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
|
5552 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
|
5553 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5554 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
|
5555 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5556 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
|
5557 if (tmp == NULL) goto failed; |
|
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_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
|
5559 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5560 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5561 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5562 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
|
5563 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5564 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5565 *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
|
5566 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
|
5567 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5568 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5569 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
|
5570 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
|
5571 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
|
5572 } |
|
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) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5574 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
|
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 (_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
|
5577 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5578 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
|
5579 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5580 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
|
5581 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5582 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5583 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5584 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
|
5585 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
|
5586 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5587 *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
|
5588 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
|
5589 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5590 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5591 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
|
5592 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
|
5593 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
|
5594 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5596 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5597 *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
|
5598 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
|
5599 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5600 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5601 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
|
5602 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
|
5603 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
|
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 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
|
5606 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
|
5607 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
|
5608 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
|
5609 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5610 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
|
5611 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5612 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
|
5613 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5614 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
|
5615 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5616 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5617 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5618 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
|
5619 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5620 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5621 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
|
5622 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5623 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
|
5624 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5625 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
|
5626 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5627 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5628 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5629 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
|
5630 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
|
5631 } |
|
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 (_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
|
5633 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5634 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
|
5635 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5636 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
|
5637 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5638 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5639 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5640 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
|
5641 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5642 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5643 *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
|
5644 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
|
5645 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5646 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5647 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
|
5648 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
|
5649 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
|
5650 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5651 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
|
5652 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
|
5653 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
|
5654 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
|
5655 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5656 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
|
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_value); |
|
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, &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
|
5661 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5662 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5663 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5664 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
|
5665 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
|
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 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
|
5668 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5669 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
|
5670 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5671 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
|
5672 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5673 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5674 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5675 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
|
5676 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
|
5677 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5678 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
|
5679 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5680 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
|
5681 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5682 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
|
5683 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5684 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5685 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5686 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
|
5687 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5688 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5689 *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
|
5690 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
|
5691 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5692 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5693 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
|
5694 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
|
5695 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
|
5696 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5697 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5698 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
|
5699 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
|
5700 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5701 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
|
5702 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5703 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
|
5704 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5705 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
|
5706 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5707 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5708 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5709 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
|
5710 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
|
5711 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5712 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
|
5713 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5714 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
|
5715 if (tmp == NULL) goto 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 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
|
5717 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5718 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5719 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5720 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
|
5721 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5722 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5723 *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
|
5724 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
|
5725 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5726 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5727 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
|
5728 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
|
5729 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
|
5730 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5731 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5732 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
|
5733 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
|
5734 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5735 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
|
5736 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5737 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
|
5738 if (tmp == NULL) goto 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 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
|
5740 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5741 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5742 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5743 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
|
5744 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5745 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5746 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
|
5747 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5748 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
|
5749 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5750 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
|
5751 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5752 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5753 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5754 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
|
5755 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
|
5756 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5757 *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
|
5758 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
|
5759 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5760 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5761 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
|
5762 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
|
5763 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
|
5764 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5765 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5766 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
|
5767 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
|
5768 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5769 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
|
5770 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5771 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
|
5772 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
|
5773 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
|
5774 if (tmp == NULL) goto failed; |
|
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 (!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
|
5776 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
|
5777 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5778 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5779 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
|
5780 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
|
5781 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
|
5782 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
|
5783 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
|
5784 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
|
5785 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
|
5786 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
|
5787 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5788 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5789 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5790 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
|
5791 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5792 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5793 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
|
5794 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5795 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
|
5796 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5797 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
|
5798 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5799 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5800 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5801 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
|
5802 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5803 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5804 *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
|
5805 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
|
5806 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5807 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5808 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
|
5809 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
|
5810 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
|
5811 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5812 if (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5813 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
|
5814 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
|
5815 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5816 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
|
5817 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5818 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
|
5819 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
|
5820 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
|
5821 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5822 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
|
5823 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
|
5824 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5825 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5826 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
|
5827 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
|
5828 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
|
5829 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
|
5830 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
|
5831 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
|
5832 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
|
5833 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
|
5834 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5835 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5836 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5837 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
|
5838 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5839 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5840 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
|
5841 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5842 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
|
5843 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5844 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
|
5845 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5846 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5847 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5848 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
|
5849 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5850 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5851 *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
|
5852 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
|
5853 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5854 } |
|
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 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
|
5857 failed: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5858 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
|
5859 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5860 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5861 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5862 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5863 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
|
5864 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5865 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
|
5866 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5867 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
|
5868 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
|
5869 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
|
5870 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5871 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
|
5872 *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
|
5873 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5874 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5875 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
|
5876 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
|
5877 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
|
5878 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5879 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
|
5880 *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
|
5881 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5882 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5883 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
|
5884 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5885 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
|
5886 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5887 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
|
5888 *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
|
5889 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5890 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5891 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
|
5892 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
|
5893 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
|
5894 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5895 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
|
5896 *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
|
5897 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5898 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5899 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
|
5900 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
|
5901 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
|
5902 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5903 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
|
5904 *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
|
5905 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5906 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5907 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
|
5908 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
|
5909 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
|
5910 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5911 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
|
5912 *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
|
5913 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5914 } |
|
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 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
|
5917 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5918 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5919 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5920 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5921 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
|
5922 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5923 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
|
5924 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5925 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
|
5926 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5927 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
|
5928 *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
|
5929 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5930 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5931 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
|
5932 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
|
5933 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
|
5934 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5935 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
|
5936 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
|
5937 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
|
5938 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
|
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 if (_PyObject_HasAttrId(obj, &PyId_lower)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5941 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5942 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
|
5943 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5944 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
|
5945 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5946 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5947 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5948 lower = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5949 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5950 if (_PyObject_HasAttrId(obj, &PyId_upper)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5951 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5952 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
|
5953 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5954 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
|
5955 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5956 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5957 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5958 upper = NULL; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
5959 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5960 if (_PyObject_HasAttrId(obj, &PyId_step)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5961 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5962 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
|
5963 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5964 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
|
5965 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
5966 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5967 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5968 step = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
5969 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5970 *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
|
5971 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
|
5972 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5973 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5974 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
|
5975 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
|
5976 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
|
5977 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5978 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
|
5979 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
|
5980 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5981 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
|
5982 int res; |
|
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_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
|
5984 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
|
5985 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
|
5986 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5987 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
|
5988 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
|
5989 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5990 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
5991 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
|
5992 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
|
5993 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
|
5994 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
|
5995 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
|
5996 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
|
5997 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
|
5998 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
|
5999 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6000 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6001 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6002 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
|
6003 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6004 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6005 *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
|
6006 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
|
6007 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6008 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6009 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
|
6010 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
|
6011 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
|
6012 } |
|
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 (isinstance) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6014 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
|
6015 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6016 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
|
6017 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6018 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
|
6019 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6020 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
|
6021 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6022 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6023 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6024 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
|
6025 return 1; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6026 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6027 *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
|
6028 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
|
6029 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6030 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6031 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6032 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
|
6033 failed: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6034 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
|
6035 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6036 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6037 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6038 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6039 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
|
6040 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6041 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
|
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 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
|
6044 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6045 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
|
6046 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6047 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
|
6048 *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
|
6049 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6050 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6051 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
|
6052 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
|
6053 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
|
6054 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6055 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
|
6056 *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
|
6057 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6058 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6059 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6060 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
|
6061 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6062 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6063 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6064 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6065 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
|
6066 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6067 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
|
6068 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6069 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
|
6070 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
|
6071 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
|
6072 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6073 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
|
6074 *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
|
6075 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6076 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6077 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
|
6078 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
|
6079 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
|
6080 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6081 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
|
6082 *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
|
6083 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6084 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6085 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
|
6086 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
|
6087 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
|
6088 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6089 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
|
6090 *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
|
6091 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6092 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6093 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
|
6094 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
|
6095 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
|
6096 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6097 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
|
6098 *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
|
6099 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6100 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6101 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
|
6102 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
|
6103 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
|
6104 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6105 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
|
6106 *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
|
6107 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6108 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6109 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
|
6110 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6111 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
|
6112 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6113 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
|
6114 *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
|
6115 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6116 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6117 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
|
6118 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
|
6119 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
|
6120 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6121 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
|
6122 *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
|
6123 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6124 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6125 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
|
6126 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
|
6127 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
|
6128 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6129 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
|
6130 *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
|
6131 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6132 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6133 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
|
6134 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
|
6135 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
|
6136 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6137 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
|
6138 *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
|
6139 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6140 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6141 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
|
6142 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
|
6143 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
|
6144 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6145 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
|
6146 *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
|
6147 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6148 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6149 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
|
6150 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
|
6151 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
|
6152 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6153 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
|
6154 *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
|
6155 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6156 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6157 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
|
6158 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
|
6159 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
|
6160 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6161 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
|
6162 *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
|
6163 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6164 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6165 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6166 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
|
6167 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6168 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6169 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6170 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6171 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
|
6172 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6173 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
|
6174 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6175 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
|
6176 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
|
6177 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
|
6178 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6179 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
|
6180 *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
|
6181 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6182 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6183 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
|
6184 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6185 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
|
6186 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6187 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
|
6188 *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
|
6189 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6190 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6191 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
|
6192 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
|
6193 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
|
6194 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6195 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
|
6196 *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
|
6197 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6198 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6199 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
|
6200 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
|
6201 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
|
6202 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6203 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
|
6204 *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
|
6205 return 0; |
|
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 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6208 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
|
6209 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6210 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6211 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6212 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6213 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
|
6214 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6215 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
|
6216 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6217 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
|
6218 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
|
6219 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
|
6220 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6221 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
|
6222 *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
|
6223 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6224 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6225 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
|
6226 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
|
6227 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
|
6228 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6229 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
|
6230 *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
|
6231 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6232 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6233 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
|
6234 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
|
6235 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
|
6236 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6237 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
|
6238 *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
|
6239 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6240 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6241 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
|
6242 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
|
6243 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
|
6244 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6245 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
|
6246 *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
|
6247 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6248 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6249 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
|
6250 if (isinstance == -1) { |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6251 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
|
6252 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6253 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
|
6254 *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
|
6255 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6256 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6257 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
|
6258 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
|
6259 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
|
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 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
|
6262 *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
|
6263 return 0; |
|
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 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
|
6266 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
|
6267 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
|
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 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
|
6270 *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
|
6271 return 0; |
|
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 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
|
6274 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
|
6275 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
|
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 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
|
6278 *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
|
6279 return 0; |
|
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 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
|
6282 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
|
6283 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
|
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 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
|
6286 *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
|
6287 return 0; |
|
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 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
|
6290 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
|
6291 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
|
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 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
|
6294 *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
|
6295 return 0; |
|
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 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6298 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
|
6299 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6300 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6301 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6302 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6303 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
|
6304 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6305 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
|
6306 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
|
6307 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
|
6308 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
|
6309 |
|
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 (_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
|
6311 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6312 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
|
6313 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6314 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
|
6315 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6316 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6317 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6318 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
|
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 (_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
|
6322 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6323 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
|
6324 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6325 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
|
6326 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6327 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6328 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6329 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
|
6330 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
|
6331 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6332 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
|
6333 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6334 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
|
6335 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
|
6336 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
|
6337 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6338 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
|
6339 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
|
6340 goto failed; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6341 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6342 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
|
6343 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
|
6344 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
|
6345 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
|
6346 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
|
6347 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
|
6348 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
|
6349 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
|
6350 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6351 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6352 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6353 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
|
6354 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
|
6355 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6356 *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
|
6357 return 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6358 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
|
6359 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
|
6360 return 1; |
|
46208
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 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6363 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6364 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
|
6365 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6366 int isinstance; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6367 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6368 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
|
6369 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
|
6370 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
|
6371 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6372 if (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
|
6373 *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
|
6374 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6375 } |
|
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 (_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
|
6377 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6378 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
|
6379 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6380 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
|
6381 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6382 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6383 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6384 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
|
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 (_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
|
6388 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6389 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
|
6390 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6391 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
|
6392 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6393 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6394 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6395 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
|
6396 return 1; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6397 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6398 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
|
6399 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
|
6400 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
|
6401 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6402 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
|
6403 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
|
6404 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
|
6405 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
|
6406 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6407 if (_PyObject_HasAttrId(obj, &PyId_type)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6408 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6409 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
|
6410 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6411 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
|
6412 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6413 Py_CLEAR(tmp); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6414 } 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
|
6415 type = NULL; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6416 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6417 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
|
6418 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6419 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
|
6420 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6421 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
|
6422 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6423 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6424 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6425 name = NULL; |
|
46231
81ee270a6eb5
Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46229
diff
changeset
|
6426 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6427 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
|
6428 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6429 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
|
6430 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
|
6431 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
|
6432 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6433 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
|
6434 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
|
6435 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6436 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6437 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
|
6438 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
|
6439 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
|
6440 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
|
6441 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
|
6442 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
|
6443 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
|
6444 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
|
6445 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6446 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6447 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6448 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
|
6449 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
|
6450 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6451 *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
|
6452 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
|
6453 return 0; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6454 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6455 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6456 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
|
6457 failed: |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6458 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
|
6459 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6460 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6461 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6462 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6463 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
|
6464 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6465 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
|
6466 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
|
6467 identifier vararg; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6468 expr_ty varargannotation; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6469 asdl_seq* kwonlyargs; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6470 identifier kwarg; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6471 expr_ty kwargannotation; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6472 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
|
6473 asdl_seq* kw_defaults; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6474 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6475 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
|
6476 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6477 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
|
6478 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
|
6479 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
|
6480 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6481 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
|
6482 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
|
6483 goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6484 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6485 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
|
6486 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
|
6487 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
|
6488 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
|
6489 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
|
6490 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
|
6491 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
|
6492 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
|
6493 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6494 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6495 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6496 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
|
6497 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
|
6498 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6499 if (_PyObject_HasAttrId(obj, &PyId_vararg)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6500 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6501 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
|
6502 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6503 res = obj2ast_identifier(tmp, &vararg, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6504 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6505 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6506 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6507 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
|
6508 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6509 if (_PyObject_HasAttrId(obj, &PyId_varargannotation)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6510 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6511 tmp = _PyObject_GetAttrId(obj, &PyId_varargannotation); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6512 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6513 res = obj2ast_expr(tmp, &varargannotation, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6514 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6515 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6516 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6517 varargannotation = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6518 } |
|
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 (_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
|
6520 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6521 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
|
6522 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
|
6523 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
|
6524 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6525 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
|
6526 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
|
6527 goto failed; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6528 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6529 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
|
6530 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
|
6531 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
|
6532 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
|
6533 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
|
6534 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
|
6535 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
|
6536 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
|
6537 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6538 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6539 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6540 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
|
6541 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
|
6542 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6543 if (_PyObject_HasAttrId(obj, &PyId_kwarg)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6544 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6545 tmp = _PyObject_GetAttrId(obj, &PyId_kwarg); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6546 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6547 res = obj2ast_identifier(tmp, &kwarg, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6548 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6549 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6550 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6551 kwarg = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6552 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6553 if (_PyObject_HasAttrId(obj, &PyId_kwargannotation)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6554 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6555 tmp = _PyObject_GetAttrId(obj, &PyId_kwargannotation); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6556 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6557 res = obj2ast_expr(tmp, &kwargannotation, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6558 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6559 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6560 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6561 kwargannotation = NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
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 if (_PyObject_HasAttrId(obj, &PyId_defaults)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6564 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6565 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
|
6566 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
|
6567 tmp = _PyObject_GetAttrId(obj, &PyId_defaults); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6568 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6569 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
|
6570 PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6571 goto failed; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6572 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6573 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
|
6574 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
|
6575 if (defaults == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6576 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
|
6577 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
|
6578 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
|
6579 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
|
6580 asdl_seq_SET(defaults, i, value); |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6581 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6582 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6583 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6584 PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments"); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6585 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
|
6586 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6587 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
|
6588 int res; |
|
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_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
|
6590 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
|
6591 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
|
6592 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6593 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
|
6594 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
|
6595 goto failed; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6596 } |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6597 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
|
6598 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
|
6599 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
|
6600 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
|
6601 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
|
6602 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
|
6603 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
|
6604 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
|
6605 } |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6606 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6607 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6608 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
|
6609 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
|
6610 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6611 *out = arguments(args, vararg, varargannotation, kwonlyargs, kwarg, |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6612 kwargannotation, defaults, kw_defaults, arena); |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6613 return 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6614 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
|
6615 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
|
6616 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6617 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6618 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6619 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6620 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
|
6621 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6622 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
|
6623 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
|
6624 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
|
6625 |
|
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_arg)) { |
|
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 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
|
6629 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6630 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
|
6631 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6632 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6633 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6634 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
|
6635 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
|
6636 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6637 if (_PyObject_HasAttrId(obj, &PyId_annotation)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6638 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6639 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
|
6640 if (tmp == NULL) goto failed; |
|
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_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
|
6642 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6643 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6644 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6645 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
|
6646 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6647 *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
|
6648 return 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6649 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
|
6650 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
|
6651 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6652 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6653 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6654 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6655 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
|
6656 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6657 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
|
6658 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
|
6659 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
|
6660 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6661 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
|
6662 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6663 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
|
6664 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6665 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
|
6666 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6667 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6668 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6669 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
|
6670 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
|
6671 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6672 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
|
6673 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6674 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
|
6675 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6676 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
|
6677 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6678 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6679 } else { |
|
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_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
|
6681 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
|
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 *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
|
6684 return 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6685 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
|
6686 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
|
6687 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6688 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6689 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6690 int |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6691 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
|
6692 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6693 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
|
6694 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
|
6695 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
|
6696 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6697 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
|
6698 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6699 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
|
6700 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6701 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
|
6702 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6703 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6704 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6705 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
|
6706 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
|
6707 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6708 if (_PyObject_HasAttrId(obj, &PyId_asname)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6709 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6710 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
|
6711 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6712 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
|
6713 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6714 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6715 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6716 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
|
6717 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6718 *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
|
6719 return 0; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6720 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
|
6721 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
|
6722 return 1; |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6723 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6724 |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
6725 int |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
6726 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
|
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 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
|
6729 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
|
6730 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
|
6731 |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6732 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
|
6733 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6734 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
|
6735 if (tmp == NULL) goto failed; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6736 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
|
6737 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6738 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6739 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6740 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
|
6741 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
|
6742 } |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6743 if (_PyObject_HasAttrId(obj, &PyId_optional_vars)) { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6744 int res; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6745 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
|
6746 if (tmp == NULL) goto 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 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
|
6748 if (res != 0) goto failed; |
|
84852
d14f40c87438
Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents:
84850
diff
changeset
|
6749 Py_CLEAR(tmp); |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6750 } else { |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6751 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
|
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 *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
|
6754 return 0; |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
6755 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
|
6756 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
|
6757 return 1; |
|
70438
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
6758 } |
|
9b11cc4e2918
reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents:
68428
diff
changeset
|
6759 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6760 |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
47301
diff
changeset
|
6761 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
|
6762 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
|
6763 }; |
| 36669 | 6764 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
|
6765 PyInit__ast(void) |
| 36669 | 6766 { |
|
84850
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6767 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
|
6768 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
|
6769 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
|
6770 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
|
6771 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
|
6772 if (PyDict_SetItemString(d, "AST", (PyObject*)&AST_type) < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6773 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6774 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6775 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
|
6776 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
|
6777 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6778 if (PyDict_SetItemString(d, "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
|
6779 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
|
6780 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
|
6781 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6782 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
|
6783 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6784 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
|
6785 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
|
6786 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
|
6787 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
|
6788 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6789 if (PyDict_SetItemString(d, "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
|
6790 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6791 if (PyDict_SetItemString(d, "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
|
6792 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6793 if (PyDict_SetItemString(d, "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
|
6794 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6795 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
|
6796 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6797 if (PyDict_SetItemString(d, "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
|
6798 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
|
6799 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6800 if (PyDict_SetItemString(d, "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
|
6801 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
|
6802 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
|
6803 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6804 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
|
6805 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
|
6806 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6807 if (PyDict_SetItemString(d, "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
|
6808 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6809 if (PyDict_SetItemString(d, "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
|
6810 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6811 if (PyDict_SetItemString(d, "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
|
6812 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6813 if (PyDict_SetItemString(d, "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
|
6814 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6815 if (PyDict_SetItemString(d, "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
|
6816 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
|
6817 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
|
6818 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6819 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
|
6820 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6821 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
|
6822 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
|
6823 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6824 if (PyDict_SetItemString(d, "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
|
6825 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6826 if (PyDict_SetItemString(d, "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
|
6827 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6828 if (PyDict_SetItemString(d, "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
|
6829 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6830 if (PyDict_SetItemString(d, "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
|
6831 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6832 if (PyDict_SetItemString(d, "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
|
6833 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
|
6834 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
|
6835 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6836 if (PyDict_SetItemString(d, "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
|
6837 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6838 if (PyDict_SetItemString(d, "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
|
6839 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6840 if (PyDict_SetItemString(d, "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
|
6841 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
|
6842 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
|
6843 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6844 if (PyDict_SetItemString(d, "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
|
6845 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6846 if (PyDict_SetItemString(d, "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
|
6847 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6848 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
|
6849 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
|
6850 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
|
6851 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
|
6852 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6853 if (PyDict_SetItemString(d, "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
|
6854 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6855 if (PyDict_SetItemString(d, "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
|
6856 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6857 if (PyDict_SetItemString(d, "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
|
6858 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6859 if (PyDict_SetItemString(d, "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
|
6860 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6861 if (PyDict_SetItemString(d, "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
|
6862 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
|
6863 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
|
6864 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6865 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
|
6866 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6867 if (PyDict_SetItemString(d, "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
|
6868 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
|
6869 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6870 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
|
6871 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
|
6872 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6873 if (PyDict_SetItemString(d, "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
|
6874 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6875 if (PyDict_SetItemString(d, "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
|
6876 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6877 if (PyDict_SetItemString(d, "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
|
6878 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6879 if (PyDict_SetItemString(d, "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
|
6880 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6881 if (PyDict_SetItemString(d, "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
|
6882 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6883 if (PyDict_SetItemString(d, "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
|
6884 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6885 if (PyDict_SetItemString(d, "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
|
6886 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6887 if (PyDict_SetItemString(d, "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
|
6888 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
|
6889 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
|
6890 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6891 if (PyDict_SetItemString(d, "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
|
6892 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
|
6893 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
|
6894 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
|
6895 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
|
6896 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
|
6897 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
|
6898 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6899 if (PyDict_SetItemString(d, "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
|
6900 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6901 if (PyDict_SetItemString(d, "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
|
6902 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6903 if (PyDict_SetItemString(d, "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
|
6904 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6905 if (PyDict_SetItemString(d, "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
|
6906 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6907 if (PyDict_SetItemString(d, "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
|
6908 return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6909 if (PyDict_SetItemString(d, "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
|
6910 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6911 if (PyDict_SetItemString(d, "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
|
6912 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6913 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
|
6914 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
|
6915 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
|
6916 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
|
6917 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6918 if (PyDict_SetItemString(d, "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
|
6919 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
|
6920 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6921 if (PyDict_SetItemString(d, "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
|
6922 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
|
6923 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
|
6924 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
|
6925 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
|
6926 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
|
6927 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6928 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
|
6929 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
|
6930 NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6931 if (PyDict_SetItemString(d, "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
|
6932 < 0) return NULL; |
|
f2d557484906
According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents:
80589
diff
changeset
|
6933 if (PyDict_SetItemString(d, "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
|
6934 < 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
|
6935 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
|
6936 < 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
|
6937 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
|
6938 return NULL; |
|
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 (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
|
6940 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
|
6941 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 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
|
6943 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 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
|
6945 return NULL; |
|
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 m; |
| 36669 | 6947 } |
| 6948 | |
| 35742 | 6949 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
6950 PyObject* PyAST_mod2obj(mod_ty t) |
| 35742 | 6951 { |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
6952 init_types(); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
6953 return ast2obj_mod(t); |
| 35742 | 6954 } |
|
42013
cd125fe83051
Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents:
41825
diff
changeset
|
6955 |
|
46227
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6956 /* 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
|
6957 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
|
6958 { |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6959 mod_ty res; |
|
46227
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6960 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
|
6961 (PyObject*)Interactive_type}; |
|
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6962 char *req_name[] = {"Module", "Expression", "Interactive"}; |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6963 int isinstance; |
|
46227
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6964 assert(0 <= mode && mode <= 2); |
|
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6965 |
|
46208
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6966 init_types(); |
|
46227
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6967 |
|
57677
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6968 isinstance = PyObject_IsInstance(ast, req_type[mode]); |
|
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6969 if (isinstance == -1) |
|
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6970 return NULL; |
|
1558dc69aacf
Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
51270
diff
changeset
|
6971 if (!isinstance) { |
|
46227
b2d93a960b98
Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46215
diff
changeset
|
6972 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
|
6973 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
|
6974 return NULL; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6975 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6976 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
|
6977 return NULL; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6978 else |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6979 return res; |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6980 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6981 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6982 int PyAST_Check(PyObject* obj) |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6983 { |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6984 init_types(); |
|
46229
07b36d2b7534
Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents:
46227
diff
changeset
|
6985 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
|
6986 } |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6987 |
|
ea75b12fe8e7
Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
45495
diff
changeset
|
6988 |
