Mercurial > cpython-lru_cache-weakref
annotate Python/Python-ast.c @ 46193:b0bf06d49647 legacy-trunk
Properly check for consistency with the third argument of
compile() when compiling an AST node.
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Sat, 29 Mar 2008 13:24:23 +0000 |
| parents | 1b5b6abb1f2e |
| children | 2ff88ae9850c |
| rev | line source |
|---|---|
|
40824
180d4e899683
Modify Parser/asdl_c.py so that the __version__ number for Python/Python-ast.c
Brett Cannon <bcannon@gmail.com>
parents:
40817
diff
changeset
|
1 /* File automatically generated by Parser/asdl_c.py. */ |
|
180d4e899683
Modify Parser/asdl_c.py so that the __version__ number for Python/Python-ast.c
Brett Cannon <bcannon@gmail.com>
parents:
40817
diff
changeset
|
2 |
|
180d4e899683
Modify Parser/asdl_c.py so that the __version__ number for Python/Python-ast.c
Brett Cannon <bcannon@gmail.com>
parents:
40817
diff
changeset
|
3 |
|
180d4e899683
Modify Parser/asdl_c.py so that the __version__ number for Python/Python-ast.c
Brett Cannon <bcannon@gmail.com>
parents:
40817
diff
changeset
|
4 /* |
|
45470
3915d5f650fa
Issue #2051 and patch from Alexander Belopolsky:
Christian Heimes <christian@cheimes.de>
parents:
45447
diff
changeset
|
5 __version__ 60978. |
|
40824
180d4e899683
Modify Parser/asdl_c.py so that the __version__ number for Python/Python-ast.c
Brett Cannon <bcannon@gmail.com>
parents:
40817
diff
changeset
|
6 |
|
180d4e899683
Modify Parser/asdl_c.py so that the __version__ number for Python/Python-ast.c
Brett Cannon <bcannon@gmail.com>
parents:
40817
diff
changeset
|
7 This module must be committed separately after each AST grammar change; |
|
180d4e899683
Modify Parser/asdl_c.py so that the __version__ number for Python/Python-ast.c
Brett Cannon <bcannon@gmail.com>
parents:
40817
diff
changeset
|
8 The __version__ number is set to the revision number of the commit |
|
180d4e899683
Modify Parser/asdl_c.py so that the __version__ number for Python/Python-ast.c
Brett Cannon <bcannon@gmail.com>
parents:
40817
diff
changeset
|
9 containing the grammar change. |
|
180d4e899683
Modify Parser/asdl_c.py so that the __version__ number for Python/Python-ast.c
Brett Cannon <bcannon@gmail.com>
parents:
40817
diff
changeset
|
10 */ |
| 35742 | 11 |
| 12 #include "Python.h" | |
| 13 #include "Python-ast.h" | |
| 14 | |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
15 static PyTypeObject* AST_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
|
16 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
|
17 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
|
18 static PyTypeObject *Module_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
|
19 static char *Module_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
20 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
21 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
22 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
|
23 static char *Interactive_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
24 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
25 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
26 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
|
27 static char *Expression_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
28 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
29 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
30 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
|
31 static char *Suite_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
32 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
33 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
34 static PyTypeObject *stmt_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
|
35 static char *stmt_attributes[] = { |
| 36669 | 36 "lineno", |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
37 "col_offset", |
| 36669 | 38 }; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
39 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
|
40 static PyTypeObject *FunctionDef_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
|
41 static char *FunctionDef_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
42 "name", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
43 "args", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
44 "body", |
|
45447
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
45 "decorator_list", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
46 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
47 static PyTypeObject *ClassDef_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
|
48 static char *ClassDef_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
49 "name", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
50 "bases", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
51 "body", |
|
45447
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
52 "decorator_list", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
53 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
54 static PyTypeObject *Return_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
|
55 static char *Return_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
56 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
57 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
58 static PyTypeObject *Delete_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
|
59 static char *Delete_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
60 "targets", |
|
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 *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
|
63 static char *Assign_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
64 "targets", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
65 "value", |
|
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 *AugAssign_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
|
68 static char *AugAssign_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
69 "target", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
70 "op", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
71 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
72 }; |
|
36743
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 PyTypeObject *Print_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
|
74 static char *Print_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
75 "dest", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
76 "values", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
77 "nl", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
78 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
79 static PyTypeObject *For_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
|
80 static char *For_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
81 "target", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
82 "iter", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
83 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
84 "orelse", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
85 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
86 static PyTypeObject *While_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
|
87 static char *While_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
88 "test", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
89 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
90 "orelse", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
91 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
92 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
|
93 static char *If_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
94 "test", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
95 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
96 "orelse", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
97 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
98 static PyTypeObject *With_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
|
99 static char *With_fields[]={ |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
100 "context_expr", |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
101 "optional_vars", |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
102 "body", |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
103 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
104 static PyTypeObject *Raise_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
|
105 static char *Raise_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
106 "type", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
107 "inst", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
108 "tback", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
109 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
110 static PyTypeObject *TryExcept_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
|
111 static char *TryExcept_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
112 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
113 "handlers", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
114 "orelse", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
115 }; |
|
36743
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 PyTypeObject *TryFinally_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
|
117 static char *TryFinally_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
118 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
119 "finalbody", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
120 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
121 static PyTypeObject *Assert_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
|
122 static char *Assert_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
123 "test", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
124 "msg", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
125 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
126 static PyTypeObject *Import_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
|
127 static char *Import_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
128 "names", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
129 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
130 static PyTypeObject *ImportFrom_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
|
131 static char *ImportFrom_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
132 "module", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
133 "names", |
|
36712
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
134 "level", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
135 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
136 static PyTypeObject *Exec_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
|
137 static char *Exec_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
138 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
139 "globals", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
140 "locals", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
141 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
142 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
|
143 static char *Global_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
144 "names", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
145 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
146 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
|
147 static char *Expr_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
148 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
149 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
150 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
|
151 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
|
152 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
|
153 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
|
154 static char *expr_attributes[] = { |
| 36669 | 155 "lineno", |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
156 "col_offset", |
| 36669 | 157 }; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
158 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
|
159 static PyTypeObject *BoolOp_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
|
160 static char *BoolOp_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
161 "op", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
162 "values", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
163 }; |
|
36743
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 PyTypeObject *BinOp_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
|
165 static char *BinOp_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
166 "left", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
167 "op", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
168 "right", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
169 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
170 static PyTypeObject *UnaryOp_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
|
171 static char *UnaryOp_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
172 "op", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
173 "operand", |
|
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 *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
|
176 static char *Lambda_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
177 "args", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
178 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
179 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
180 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
|
181 static char *IfExp_fields[]={ |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
182 "test", |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
183 "body", |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
184 "orelse", |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
185 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
186 static PyTypeObject *Dict_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
|
187 static char *Dict_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
188 "keys", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
189 "values", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
190 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
191 static PyTypeObject *ListComp_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
|
192 static char *ListComp_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
193 "elt", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
194 "generators", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
195 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
196 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
|
197 static char *GeneratorExp_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
198 "elt", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
199 "generators", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
200 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
201 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
|
202 static char *Yield_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
203 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
204 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
205 static PyTypeObject *Compare_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
|
206 static char *Compare_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
207 "left", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
208 "ops", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
209 "comparators", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
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 *Call_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
|
212 static char *Call_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
213 "func", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
214 "args", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
215 "keywords", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
216 "starargs", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
217 "kwargs", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
218 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
219 static PyTypeObject *Repr_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
|
220 static char *Repr_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
221 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
222 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
223 static PyTypeObject *Num_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
|
224 static char *Num_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
225 "n", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
226 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
227 static PyTypeObject *Str_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
|
228 static char *Str_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
229 "s", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
230 }; |
|
36743
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 PyTypeObject *Attribute_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
|
232 static char *Attribute_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
233 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
234 "attr", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
235 "ctx", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
236 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
237 static PyTypeObject *Subscript_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
|
238 static char *Subscript_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
239 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
240 "slice", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
241 "ctx", |
|
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 *Name_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
|
244 static char *Name_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
245 "id", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
246 "ctx", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
247 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
248 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
|
249 static char *List_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
250 "elts", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
251 "ctx", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
252 }; |
|
36743
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 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
|
254 static char *Tuple_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
255 "elts", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
256 "ctx", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
257 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
258 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
|
259 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
|
260 *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
|
261 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
|
262 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
|
263 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
|
264 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
|
265 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
|
266 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
|
267 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
|
268 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
|
269 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
|
270 static PyTypeObject *Ellipsis_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
|
271 static PyTypeObject *Slice_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
|
272 static char *Slice_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
273 "lower", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
274 "upper", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
275 "step", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
276 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
277 static PyTypeObject *ExtSlice_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
|
278 static char *ExtSlice_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
279 "dims", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
280 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
281 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
|
282 static char *Index_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
283 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
284 }; |
|
36743
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 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
|
286 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
|
287 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
|
288 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
|
289 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
|
290 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
|
291 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
|
292 *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
|
293 *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
|
294 *FloorDiv_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
295 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
|
296 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
|
297 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
|
298 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
|
299 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
|
300 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
|
301 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
|
302 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
|
303 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
|
304 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
|
305 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
|
306 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
|
307 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
|
308 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
|
309 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
|
310 *USub_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
311 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
|
312 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
|
313 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
|
314 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
|
315 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
|
316 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
|
317 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
|
318 *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
|
319 *NotIn_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
320 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
|
321 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
|
322 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
|
323 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
|
324 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
|
325 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
|
326 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
|
327 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
|
328 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
|
329 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
|
330 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
|
331 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
|
332 static PyObject* ast2obj_comprehension(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
|
333 static char *comprehension_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
334 "target", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
335 "iter", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
336 "ifs", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
337 }; |
|
36743
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 PyTypeObject *excepthandler_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
339 static PyObject* ast2obj_excepthandler(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
|
340 static char *excepthandler_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
341 "type", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
342 "name", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
343 "body", |
|
37453
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
344 "lineno", |
|
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
345 "col_offset", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
346 }; |
|
36743
dbf9cc6c36eb
Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36726
diff
changeset
|
347 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
|
348 static PyObject* ast2obj_arguments(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
|
349 static char *arguments_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
350 "args", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
351 "vararg", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
352 "kwarg", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
353 "defaults", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
354 }; |
|
36743
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 *keyword_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
356 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
|
357 static char *keyword_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
358 "arg", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
359 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
360 }; |
|
36743
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 *alias_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
362 static PyObject* ast2obj_alias(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
|
363 static char *alias_fields[]={ |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
364 "name", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
365 "asname", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
366 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
367 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
368 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
369 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
|
370 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
371 PyObject *fnames, *result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
372 int i; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
373 if (num_fields) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
374 fnames = PyTuple_New(num_fields); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
375 if (!fnames) return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
376 } else { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
377 fnames = Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
378 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
379 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
380 for(i=0; i < num_fields; i++) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
381 PyObject *field = PyString_FromString(fields[i]); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
382 if (!field) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
383 Py_DECREF(fnames); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
384 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
385 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
386 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
|
387 } |
|
36726
bbf16fd024df
from __future__ import with_statement addon for 'with', mostly written by
Thomas Wouters <thomas@python.org>
parents:
36712
diff
changeset
|
388 result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}", |
| 36669 | 389 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
|
390 Py_DECREF(fnames); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
391 return (PyTypeObject*)result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
392 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
393 |
| 36669 | 394 static int add_attributes(PyTypeObject* type, char**attrs, int num_fields) |
| 395 { | |
|
37412
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
396 int i, result; |
| 36669 | 397 PyObject *s, *l = PyList_New(num_fields); |
| 398 if (!l) return 0; | |
|
37412
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
399 for(i = 0; i < num_fields; i++) { |
| 36669 | 400 s = PyString_FromString(attrs[i]); |
| 401 if (!s) { | |
| 402 Py_DECREF(l); | |
| 403 return 0; | |
| 404 } | |
| 405 PyList_SET_ITEM(l, i, s); | |
| 406 } | |
|
37412
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
407 result = PyObject_SetAttrString((PyObject*)type, "_attributes", l) >= 0; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
408 Py_DECREF(l); |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
409 return result; |
| 36669 | 410 } |
| 411 | |
|
46162
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
412 /* Conversion AST -> Python */ |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
413 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
414 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
|
415 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
416 int i, n = asdl_seq_LEN(seq); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
417 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
|
418 PyObject *value; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
419 if (!result) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
420 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
421 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
|
422 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
|
423 if (!value) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
424 Py_DECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
425 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
426 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
427 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
|
428 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
429 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
430 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
431 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
432 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
|
433 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
434 if (!o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
435 o = Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
436 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
|
437 return (PyObject*)o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
438 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
439 #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
|
440 #define ast2obj_string ast2obj_object |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
441 static PyObject* ast2obj_bool(bool b) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
442 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
443 return PyBool_FromLong(b); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
444 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
445 |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
446 static PyObject* ast2obj_int(long b) |
| 36669 | 447 { |
| 448 return PyInt_FromLong(b); | |
| 449 } | |
| 450 | |
|
46162
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
451 /* Conversion Python -> AST */ |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
452 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
453 static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
454 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
455 if (obj == Py_None) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
456 obj = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
457 if (obj) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
458 PyArena_AddPyObject(arena, obj); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
459 Py_XINCREF(obj); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
460 *out = obj; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
461 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
462 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
463 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
464 #define obj2ast_identifier obj2ast_object |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
465 #define obj2ast_string obj2ast_object |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
466 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
467 static int obj2ast_int(PyObject* obj, int* out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
468 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
469 int i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
470 if (!PyInt_Check(obj) && !PyLong_Check(obj)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
471 PyObject *s = PyObject_Repr(obj); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
472 if (s == NULL) return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
473 PyErr_Format(PyExc_ValueError, "invalid integer value: %.400s", |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
474 PyString_AS_STRING(s)); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
475 Py_DECREF(s); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
476 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
477 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
478 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
479 i = (int)PyLong_AsLong(obj); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
480 if (i == -1 && PyErr_Occurred()) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
481 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
482 *out = i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
483 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
484 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
485 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
486 static int obj2ast_bool(PyObject* obj, bool* out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
487 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
488 if (!PyBool_Check(obj)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
489 PyObject *s = PyObject_Repr(obj); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
490 if (s == NULL) return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
491 PyErr_Format(PyExc_ValueError, "invalid boolean value: %.400s", |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
492 PyString_AS_STRING(s)); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
493 Py_DECREF(s); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
494 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
495 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
496 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
497 *out = (obj == Py_True); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
498 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
499 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
500 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
501 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
502 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
|
503 { |
|
37412
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
504 static int initialized; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
505 if (initialized) return 1; |
| 36669 | 506 AST_type = make_type("AST", &PyBaseObject_Type, NULL, 0); |
| 507 mod_type = make_type("mod", AST_type, NULL, 0); | |
| 508 if (!mod_type) return 0; | |
| 509 if (!add_attributes(mod_type, NULL, 0)) return 0; | |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
510 Module_type = make_type("Module", mod_type, Module_fields, 1); |
| 36669 | 511 if (!Module_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
512 Interactive_type = make_type("Interactive", mod_type, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
513 Interactive_fields, 1); |
| 36669 | 514 if (!Interactive_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
515 Expression_type = make_type("Expression", mod_type, Expression_fields, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
516 1); |
| 36669 | 517 if (!Expression_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
518 Suite_type = make_type("Suite", mod_type, Suite_fields, 1); |
| 36669 | 519 if (!Suite_type) return 0; |
| 520 stmt_type = make_type("stmt", AST_type, NULL, 0); | |
| 521 if (!stmt_type) return 0; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
522 if (!add_attributes(stmt_type, stmt_attributes, 2)) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
523 FunctionDef_type = make_type("FunctionDef", stmt_type, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
524 FunctionDef_fields, 4); |
| 36669 | 525 if (!FunctionDef_type) return 0; |
|
45447
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
526 ClassDef_type = make_type("ClassDef", stmt_type, ClassDef_fields, 4); |
| 36669 | 527 if (!ClassDef_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
528 Return_type = make_type("Return", stmt_type, Return_fields, 1); |
| 36669 | 529 if (!Return_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
530 Delete_type = make_type("Delete", stmt_type, Delete_fields, 1); |
| 36669 | 531 if (!Delete_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
532 Assign_type = make_type("Assign", stmt_type, Assign_fields, 2); |
| 36669 | 533 if (!Assign_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
534 AugAssign_type = make_type("AugAssign", stmt_type, AugAssign_fields, 3); |
| 36669 | 535 if (!AugAssign_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
536 Print_type = make_type("Print", stmt_type, Print_fields, 3); |
| 36669 | 537 if (!Print_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
538 For_type = make_type("For", stmt_type, For_fields, 4); |
| 36669 | 539 if (!For_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
540 While_type = make_type("While", stmt_type, While_fields, 3); |
| 36669 | 541 if (!While_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
542 If_type = make_type("If", stmt_type, If_fields, 3); |
| 36669 | 543 if (!If_type) return 0; |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
544 With_type = make_type("With", stmt_type, With_fields, 3); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
545 if (!With_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
546 Raise_type = make_type("Raise", stmt_type, Raise_fields, 3); |
| 36669 | 547 if (!Raise_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
548 TryExcept_type = make_type("TryExcept", stmt_type, TryExcept_fields, 3); |
| 36669 | 549 if (!TryExcept_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
550 TryFinally_type = make_type("TryFinally", stmt_type, TryFinally_fields, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
551 2); |
| 36669 | 552 if (!TryFinally_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
553 Assert_type = make_type("Assert", stmt_type, Assert_fields, 2); |
| 36669 | 554 if (!Assert_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
555 Import_type = make_type("Import", stmt_type, Import_fields, 1); |
| 36669 | 556 if (!Import_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
557 ImportFrom_type = make_type("ImportFrom", stmt_type, ImportFrom_fields, |
|
36712
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
558 3); |
| 36669 | 559 if (!ImportFrom_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
560 Exec_type = make_type("Exec", stmt_type, Exec_fields, 3); |
| 36669 | 561 if (!Exec_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
562 Global_type = make_type("Global", stmt_type, Global_fields, 1); |
| 36669 | 563 if (!Global_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
564 Expr_type = make_type("Expr", stmt_type, Expr_fields, 1); |
| 36669 | 565 if (!Expr_type) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
566 Pass_type = make_type("Pass", stmt_type, NULL, 0); |
| 36669 | 567 if (!Pass_type) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
568 Break_type = make_type("Break", stmt_type, NULL, 0); |
| 36669 | 569 if (!Break_type) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
570 Continue_type = make_type("Continue", stmt_type, NULL, 0); |
| 36669 | 571 if (!Continue_type) return 0; |
| 572 expr_type = make_type("expr", AST_type, NULL, 0); | |
| 573 if (!expr_type) return 0; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
574 if (!add_attributes(expr_type, expr_attributes, 2)) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
575 BoolOp_type = make_type("BoolOp", expr_type, BoolOp_fields, 2); |
| 36669 | 576 if (!BoolOp_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
577 BinOp_type = make_type("BinOp", expr_type, BinOp_fields, 3); |
| 36669 | 578 if (!BinOp_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
579 UnaryOp_type = make_type("UnaryOp", expr_type, UnaryOp_fields, 2); |
| 36669 | 580 if (!UnaryOp_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
581 Lambda_type = make_type("Lambda", expr_type, Lambda_fields, 2); |
| 36669 | 582 if (!Lambda_type) return 0; |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
583 IfExp_type = make_type("IfExp", expr_type, IfExp_fields, 3); |
| 36669 | 584 if (!IfExp_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
585 Dict_type = make_type("Dict", expr_type, Dict_fields, 2); |
| 36669 | 586 if (!Dict_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
587 ListComp_type = make_type("ListComp", expr_type, ListComp_fields, 2); |
| 36669 | 588 if (!ListComp_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
589 GeneratorExp_type = make_type("GeneratorExp", expr_type, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
590 GeneratorExp_fields, 2); |
| 36669 | 591 if (!GeneratorExp_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
592 Yield_type = make_type("Yield", expr_type, Yield_fields, 1); |
| 36669 | 593 if (!Yield_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
594 Compare_type = make_type("Compare", expr_type, Compare_fields, 3); |
| 36669 | 595 if (!Compare_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
596 Call_type = make_type("Call", expr_type, Call_fields, 5); |
| 36669 | 597 if (!Call_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
598 Repr_type = make_type("Repr", expr_type, Repr_fields, 1); |
| 36669 | 599 if (!Repr_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
600 Num_type = make_type("Num", expr_type, Num_fields, 1); |
| 36669 | 601 if (!Num_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
602 Str_type = make_type("Str", expr_type, Str_fields, 1); |
| 36669 | 603 if (!Str_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
604 Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3); |
| 36669 | 605 if (!Attribute_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
606 Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3); |
| 36669 | 607 if (!Subscript_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
608 Name_type = make_type("Name", expr_type, Name_fields, 2); |
| 36669 | 609 if (!Name_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
610 List_type = make_type("List", expr_type, List_fields, 2); |
| 36669 | 611 if (!List_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
612 Tuple_type = make_type("Tuple", expr_type, Tuple_fields, 2); |
| 36669 | 613 if (!Tuple_type) return 0; |
| 614 expr_context_type = make_type("expr_context", AST_type, NULL, 0); | |
| 615 if (!expr_context_type) return 0; | |
| 616 if (!add_attributes(expr_context_type, NULL, 0)) return 0; | |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
617 Load_type = make_type("Load", expr_context_type, NULL, 0); |
| 36669 | 618 if (!Load_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
619 Load_singleton = PyType_GenericNew(Load_type, NULL, NULL); |
| 36669 | 620 if (!Load_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
621 Store_type = make_type("Store", expr_context_type, NULL, 0); |
| 36669 | 622 if (!Store_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
623 Store_singleton = PyType_GenericNew(Store_type, NULL, NULL); |
| 36669 | 624 if (!Store_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
625 Del_type = make_type("Del", expr_context_type, NULL, 0); |
| 36669 | 626 if (!Del_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
627 Del_singleton = PyType_GenericNew(Del_type, NULL, NULL); |
| 36669 | 628 if (!Del_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
629 AugLoad_type = make_type("AugLoad", expr_context_type, NULL, 0); |
| 36669 | 630 if (!AugLoad_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
631 AugLoad_singleton = PyType_GenericNew(AugLoad_type, NULL, NULL); |
| 36669 | 632 if (!AugLoad_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
633 AugStore_type = make_type("AugStore", expr_context_type, NULL, 0); |
| 36669 | 634 if (!AugStore_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
635 AugStore_singleton = PyType_GenericNew(AugStore_type, NULL, NULL); |
| 36669 | 636 if (!AugStore_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
637 Param_type = make_type("Param", expr_context_type, NULL, 0); |
| 36669 | 638 if (!Param_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
639 Param_singleton = PyType_GenericNew(Param_type, NULL, NULL); |
| 36669 | 640 if (!Param_singleton) return 0; |
| 641 slice_type = make_type("slice", AST_type, NULL, 0); | |
| 642 if (!slice_type) return 0; | |
| 643 if (!add_attributes(slice_type, NULL, 0)) return 0; | |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
644 Ellipsis_type = make_type("Ellipsis", slice_type, NULL, 0); |
| 36669 | 645 if (!Ellipsis_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
646 Slice_type = make_type("Slice", slice_type, Slice_fields, 3); |
| 36669 | 647 if (!Slice_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
648 ExtSlice_type = make_type("ExtSlice", slice_type, ExtSlice_fields, 1); |
| 36669 | 649 if (!ExtSlice_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
650 Index_type = make_type("Index", slice_type, Index_fields, 1); |
| 36669 | 651 if (!Index_type) return 0; |
| 652 boolop_type = make_type("boolop", AST_type, NULL, 0); | |
| 653 if (!boolop_type) return 0; | |
| 654 if (!add_attributes(boolop_type, NULL, 0)) return 0; | |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
655 And_type = make_type("And", boolop_type, NULL, 0); |
| 36669 | 656 if (!And_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
657 And_singleton = PyType_GenericNew(And_type, NULL, NULL); |
| 36669 | 658 if (!And_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
659 Or_type = make_type("Or", boolop_type, NULL, 0); |
| 36669 | 660 if (!Or_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
661 Or_singleton = PyType_GenericNew(Or_type, NULL, NULL); |
| 36669 | 662 if (!Or_singleton) return 0; |
| 663 operator_type = make_type("operator", AST_type, NULL, 0); | |
| 664 if (!operator_type) return 0; | |
| 665 if (!add_attributes(operator_type, NULL, 0)) return 0; | |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
666 Add_type = make_type("Add", operator_type, NULL, 0); |
| 36669 | 667 if (!Add_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
668 Add_singleton = PyType_GenericNew(Add_type, NULL, NULL); |
| 36669 | 669 if (!Add_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
670 Sub_type = make_type("Sub", operator_type, NULL, 0); |
| 36669 | 671 if (!Sub_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
672 Sub_singleton = PyType_GenericNew(Sub_type, NULL, NULL); |
| 36669 | 673 if (!Sub_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
674 Mult_type = make_type("Mult", operator_type, NULL, 0); |
| 36669 | 675 if (!Mult_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
676 Mult_singleton = PyType_GenericNew(Mult_type, NULL, NULL); |
| 36669 | 677 if (!Mult_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
678 Div_type = make_type("Div", operator_type, NULL, 0); |
| 36669 | 679 if (!Div_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
680 Div_singleton = PyType_GenericNew(Div_type, NULL, NULL); |
| 36669 | 681 if (!Div_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
682 Mod_type = make_type("Mod", operator_type, NULL, 0); |
| 36669 | 683 if (!Mod_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
684 Mod_singleton = PyType_GenericNew(Mod_type, NULL, NULL); |
| 36669 | 685 if (!Mod_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
686 Pow_type = make_type("Pow", operator_type, NULL, 0); |
| 36669 | 687 if (!Pow_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
688 Pow_singleton = PyType_GenericNew(Pow_type, NULL, NULL); |
| 36669 | 689 if (!Pow_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
690 LShift_type = make_type("LShift", operator_type, NULL, 0); |
| 36669 | 691 if (!LShift_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
692 LShift_singleton = PyType_GenericNew(LShift_type, NULL, NULL); |
| 36669 | 693 if (!LShift_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
694 RShift_type = make_type("RShift", operator_type, NULL, 0); |
| 36669 | 695 if (!RShift_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
696 RShift_singleton = PyType_GenericNew(RShift_type, NULL, NULL); |
| 36669 | 697 if (!RShift_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
698 BitOr_type = make_type("BitOr", operator_type, NULL, 0); |
| 36669 | 699 if (!BitOr_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
700 BitOr_singleton = PyType_GenericNew(BitOr_type, NULL, NULL); |
| 36669 | 701 if (!BitOr_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
702 BitXor_type = make_type("BitXor", operator_type, NULL, 0); |
| 36669 | 703 if (!BitXor_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
704 BitXor_singleton = PyType_GenericNew(BitXor_type, NULL, NULL); |
| 36669 | 705 if (!BitXor_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
706 BitAnd_type = make_type("BitAnd", operator_type, NULL, 0); |
| 36669 | 707 if (!BitAnd_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
708 BitAnd_singleton = PyType_GenericNew(BitAnd_type, NULL, NULL); |
| 36669 | 709 if (!BitAnd_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
710 FloorDiv_type = make_type("FloorDiv", operator_type, NULL, 0); |
| 36669 | 711 if (!FloorDiv_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
712 FloorDiv_singleton = PyType_GenericNew(FloorDiv_type, NULL, NULL); |
| 36669 | 713 if (!FloorDiv_singleton) return 0; |
| 714 unaryop_type = make_type("unaryop", AST_type, NULL, 0); | |
| 715 if (!unaryop_type) return 0; | |
| 716 if (!add_attributes(unaryop_type, NULL, 0)) return 0; | |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
717 Invert_type = make_type("Invert", unaryop_type, NULL, 0); |
| 36669 | 718 if (!Invert_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
719 Invert_singleton = PyType_GenericNew(Invert_type, NULL, NULL); |
| 36669 | 720 if (!Invert_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
721 Not_type = make_type("Not", unaryop_type, NULL, 0); |
| 36669 | 722 if (!Not_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
723 Not_singleton = PyType_GenericNew(Not_type, NULL, NULL); |
| 36669 | 724 if (!Not_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
725 UAdd_type = make_type("UAdd", unaryop_type, NULL, 0); |
| 36669 | 726 if (!UAdd_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
727 UAdd_singleton = PyType_GenericNew(UAdd_type, NULL, NULL); |
| 36669 | 728 if (!UAdd_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
729 USub_type = make_type("USub", unaryop_type, NULL, 0); |
| 36669 | 730 if (!USub_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
731 USub_singleton = PyType_GenericNew(USub_type, NULL, NULL); |
| 36669 | 732 if (!USub_singleton) return 0; |
| 733 cmpop_type = make_type("cmpop", AST_type, NULL, 0); | |
| 734 if (!cmpop_type) return 0; | |
| 735 if (!add_attributes(cmpop_type, NULL, 0)) return 0; | |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
736 Eq_type = make_type("Eq", cmpop_type, NULL, 0); |
| 36669 | 737 if (!Eq_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
738 Eq_singleton = PyType_GenericNew(Eq_type, NULL, NULL); |
| 36669 | 739 if (!Eq_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
740 NotEq_type = make_type("NotEq", cmpop_type, NULL, 0); |
| 36669 | 741 if (!NotEq_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
742 NotEq_singleton = PyType_GenericNew(NotEq_type, NULL, NULL); |
| 36669 | 743 if (!NotEq_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
744 Lt_type = make_type("Lt", cmpop_type, NULL, 0); |
| 36669 | 745 if (!Lt_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
746 Lt_singleton = PyType_GenericNew(Lt_type, NULL, NULL); |
| 36669 | 747 if (!Lt_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
748 LtE_type = make_type("LtE", cmpop_type, NULL, 0); |
| 36669 | 749 if (!LtE_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
750 LtE_singleton = PyType_GenericNew(LtE_type, NULL, NULL); |
| 36669 | 751 if (!LtE_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
752 Gt_type = make_type("Gt", cmpop_type, NULL, 0); |
| 36669 | 753 if (!Gt_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
754 Gt_singleton = PyType_GenericNew(Gt_type, NULL, NULL); |
| 36669 | 755 if (!Gt_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
756 GtE_type = make_type("GtE", cmpop_type, NULL, 0); |
| 36669 | 757 if (!GtE_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
758 GtE_singleton = PyType_GenericNew(GtE_type, NULL, NULL); |
| 36669 | 759 if (!GtE_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
760 Is_type = make_type("Is", cmpop_type, NULL, 0); |
| 36669 | 761 if (!Is_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
762 Is_singleton = PyType_GenericNew(Is_type, NULL, NULL); |
| 36669 | 763 if (!Is_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
764 IsNot_type = make_type("IsNot", cmpop_type, NULL, 0); |
| 36669 | 765 if (!IsNot_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
766 IsNot_singleton = PyType_GenericNew(IsNot_type, NULL, NULL); |
| 36669 | 767 if (!IsNot_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
768 In_type = make_type("In", cmpop_type, NULL, 0); |
| 36669 | 769 if (!In_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
770 In_singleton = PyType_GenericNew(In_type, NULL, NULL); |
| 36669 | 771 if (!In_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
772 NotIn_type = make_type("NotIn", cmpop_type, NULL, 0); |
| 36669 | 773 if (!NotIn_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
774 NotIn_singleton = PyType_GenericNew(NotIn_type, NULL, NULL); |
| 36669 | 775 if (!NotIn_singleton) return 0; |
| 776 comprehension_type = make_type("comprehension", AST_type, | |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
777 comprehension_fields, 3); |
| 36669 | 778 if (!comprehension_type) return 0; |
| 779 excepthandler_type = make_type("excepthandler", AST_type, | |
|
37453
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
780 excepthandler_fields, 5); |
| 36669 | 781 if (!excepthandler_type) return 0; |
| 782 arguments_type = make_type("arguments", AST_type, arguments_fields, 4); | |
| 783 if (!arguments_type) return 0; | |
| 784 keyword_type = make_type("keyword", AST_type, keyword_fields, 2); | |
| 785 if (!keyword_type) return 0; | |
| 786 alias_type = make_type("alias", AST_type, alias_fields, 2); | |
| 787 if (!alias_type) return 0; | |
| 788 initialized = 1; | |
| 789 return 1; | |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
790 } |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
791 |
|
46162
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
792 static int obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
793 static int obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
794 static int obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
795 static int obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
796 arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
797 static int obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
798 static int obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
799 static int obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
800 static int obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
801 static int obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
802 static int obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena* |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
803 arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
804 static int obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
805 arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
806 static int obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
807 static int obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
808 static int obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
809 |
| 35742 | 810 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
|
811 Module(asdl_seq * body, PyArena *arena) |
| 35742 | 812 { |
| 813 mod_ty p; | |
|
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
|
814 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
815 if (!p) |
| 35742 | 816 return NULL; |
| 817 p->kind = Module_kind; | |
| 818 p->v.Module.body = body; | |
| 819 return p; | |
| 820 } | |
| 821 | |
| 822 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
|
823 Interactive(asdl_seq * body, PyArena *arena) |
| 35742 | 824 { |
| 825 mod_ty p; | |
|
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
|
826 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
827 if (!p) |
| 35742 | 828 return NULL; |
| 829 p->kind = Interactive_kind; | |
| 830 p->v.Interactive.body = body; | |
| 831 return p; | |
| 832 } | |
| 833 | |
| 834 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
|
835 Expression(expr_ty body, PyArena *arena) |
| 35742 | 836 { |
| 837 mod_ty p; | |
| 838 if (!body) { | |
| 839 PyErr_SetString(PyExc_ValueError, | |
| 840 "field body is required for Expression"); | |
| 841 return NULL; | |
| 842 } | |
|
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
|
843 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
844 if (!p) |
| 35742 | 845 return NULL; |
| 846 p->kind = Expression_kind; | |
| 847 p->v.Expression.body = body; | |
| 848 return p; | |
| 849 } | |
| 850 | |
| 851 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
|
852 Suite(asdl_seq * body, PyArena *arena) |
| 35742 | 853 { |
| 854 mod_ty p; | |
|
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
|
855 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
856 if (!p) |
| 35742 | 857 return NULL; |
| 858 p->kind = Suite_kind; | |
| 859 p->v.Suite.body = body; | |
| 860 return p; | |
| 861 } | |
| 862 | |
| 863 stmt_ty | |
| 864 FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq * | |
|
45447
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
865 decorator_list, int lineno, int col_offset, PyArena *arena) |
| 35742 | 866 { |
| 867 stmt_ty p; | |
| 868 if (!name) { | |
| 869 PyErr_SetString(PyExc_ValueError, | |
| 870 "field name is required for FunctionDef"); | |
| 871 return NULL; | |
| 872 } | |
| 873 if (!args) { | |
| 874 PyErr_SetString(PyExc_ValueError, | |
| 875 "field args is required for FunctionDef"); | |
| 876 return NULL; | |
| 877 } | |
|
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
|
878 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
879 if (!p) |
| 35742 | 880 return NULL; |
| 881 p->kind = FunctionDef_kind; | |
| 882 p->v.FunctionDef.name = name; | |
| 883 p->v.FunctionDef.args = args; | |
| 884 p->v.FunctionDef.body = body; | |
|
45447
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
885 p->v.FunctionDef.decorator_list = decorator_list; |
| 35742 | 886 p->lineno = lineno; |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
887 p->col_offset = col_offset; |
| 35742 | 888 return p; |
| 889 } | |
| 890 | |
| 891 stmt_ty | |
|
45447
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
892 ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, asdl_seq * |
|
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
893 decorator_list, int lineno, int col_offset, PyArena *arena) |
| 35742 | 894 { |
| 895 stmt_ty p; | |
| 896 if (!name) { | |
| 897 PyErr_SetString(PyExc_ValueError, | |
| 898 "field name is required for ClassDef"); | |
| 899 return NULL; | |
| 900 } | |
|
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
|
901 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
902 if (!p) |
| 35742 | 903 return NULL; |
| 904 p->kind = ClassDef_kind; | |
| 905 p->v.ClassDef.name = name; | |
| 906 p->v.ClassDef.bases = bases; | |
| 907 p->v.ClassDef.body = body; | |
|
45447
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
908 p->v.ClassDef.decorator_list = decorator_list; |
| 35742 | 909 p->lineno = lineno; |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
910 p->col_offset = col_offset; |
| 35742 | 911 return p; |
| 912 } | |
| 913 | |
| 914 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
|
915 Return(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 35742 | 916 { |
| 917 stmt_ty p; | |
|
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
|
918 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
919 if (!p) |
| 35742 | 920 return NULL; |
| 921 p->kind = Return_kind; | |
| 922 p->v.Return.value = value; | |
| 923 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
924 p->col_offset = col_offset; |
| 35742 | 925 return p; |
| 926 } | |
| 927 | |
| 928 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
|
929 Delete(asdl_seq * targets, int lineno, int col_offset, PyArena *arena) |
| 35742 | 930 { |
| 931 stmt_ty p; | |
|
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
|
932 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
933 if (!p) |
| 35742 | 934 return NULL; |
| 935 p->kind = Delete_kind; | |
| 936 p->v.Delete.targets = targets; | |
| 937 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
938 p->col_offset = col_offset; |
| 35742 | 939 return p; |
| 940 } | |
| 941 | |
| 942 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
|
943 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
|
944 *arena) |
| 35742 | 945 { |
| 946 stmt_ty p; | |
| 947 if (!value) { | |
| 948 PyErr_SetString(PyExc_ValueError, | |
| 949 "field value is required for Assign"); | |
| 950 return NULL; | |
| 951 } | |
|
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
|
952 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
953 if (!p) |
| 35742 | 954 return NULL; |
| 955 p->kind = Assign_kind; | |
| 956 p->v.Assign.targets = targets; | |
| 957 p->v.Assign.value = value; | |
| 958 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
959 p->col_offset = col_offset; |
| 35742 | 960 return p; |
| 961 } | |
| 962 | |
| 963 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
|
964 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
|
965 col_offset, PyArena *arena) |
| 35742 | 966 { |
| 967 stmt_ty p; | |
| 968 if (!target) { | |
| 969 PyErr_SetString(PyExc_ValueError, | |
| 970 "field target is required for AugAssign"); | |
| 971 return NULL; | |
| 972 } | |
| 973 if (!op) { | |
| 974 PyErr_SetString(PyExc_ValueError, | |
| 975 "field op is required for AugAssign"); | |
| 976 return NULL; | |
| 977 } | |
| 978 if (!value) { | |
| 979 PyErr_SetString(PyExc_ValueError, | |
| 980 "field value is required for AugAssign"); | |
| 981 return NULL; | |
| 982 } | |
|
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
|
983 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
984 if (!p) |
| 35742 | 985 return NULL; |
| 986 p->kind = AugAssign_kind; | |
| 987 p->v.AugAssign.target = target; | |
| 988 p->v.AugAssign.op = op; | |
| 989 p->v.AugAssign.value = value; | |
| 990 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
991 p->col_offset = col_offset; |
| 35742 | 992 return p; |
| 993 } | |
| 994 | |
| 995 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
|
996 Print(expr_ty dest, asdl_seq * values, bool nl, 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
|
997 PyArena *arena) |
| 35742 | 998 { |
| 999 stmt_ty p; | |
|
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
|
1000 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1001 if (!p) |
| 35742 | 1002 return NULL; |
| 1003 p->kind = Print_kind; | |
| 1004 p->v.Print.dest = dest; | |
| 1005 p->v.Print.values = values; | |
| 1006 p->v.Print.nl = nl; | |
| 1007 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1008 p->col_offset = col_offset; |
| 35742 | 1009 return p; |
| 1010 } | |
| 1011 | |
| 1012 stmt_ty | |
| 1013 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
|
1014 lineno, int col_offset, PyArena *arena) |
| 35742 | 1015 { |
| 1016 stmt_ty p; | |
| 1017 if (!target) { | |
| 1018 PyErr_SetString(PyExc_ValueError, | |
| 1019 "field target is required for For"); | |
| 1020 return NULL; | |
| 1021 } | |
| 1022 if (!iter) { | |
| 1023 PyErr_SetString(PyExc_ValueError, | |
| 1024 "field iter is required for For"); | |
| 1025 return NULL; | |
| 1026 } | |
|
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
|
1027 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1028 if (!p) |
| 35742 | 1029 return NULL; |
| 1030 p->kind = For_kind; | |
| 1031 p->v.For.target = target; | |
| 1032 p->v.For.iter = iter; | |
| 1033 p->v.For.body = body; | |
| 1034 p->v.For.orelse = orelse; | |
| 1035 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1036 p->col_offset = col_offset; |
| 35742 | 1037 return p; |
| 1038 } | |
| 1039 | |
| 1040 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
|
1041 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
|
1042 col_offset, PyArena *arena) |
| 35742 | 1043 { |
| 1044 stmt_ty p; | |
| 1045 if (!test) { | |
| 1046 PyErr_SetString(PyExc_ValueError, | |
| 1047 "field test is required for While"); | |
| 1048 return NULL; | |
| 1049 } | |
|
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
|
1050 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1051 if (!p) |
| 35742 | 1052 return NULL; |
| 1053 p->kind = While_kind; | |
| 1054 p->v.While.test = test; | |
| 1055 p->v.While.body = body; | |
| 1056 p->v.While.orelse = orelse; | |
| 1057 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1058 p->col_offset = col_offset; |
| 35742 | 1059 return p; |
| 1060 } | |
| 1061 | |
| 1062 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
|
1063 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
|
1064 col_offset, PyArena *arena) |
| 35742 | 1065 { |
| 1066 stmt_ty p; | |
| 1067 if (!test) { | |
| 1068 PyErr_SetString(PyExc_ValueError, | |
| 1069 "field test is required for If"); | |
| 1070 return NULL; | |
| 1071 } | |
|
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
|
1072 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1073 if (!p) |
| 35742 | 1074 return NULL; |
| 1075 p->kind = If_kind; | |
| 1076 p->v.If.test = test; | |
| 1077 p->v.If.body = body; | |
| 1078 p->v.If.orelse = orelse; | |
| 1079 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1080 p->col_offset = col_offset; |
| 35742 | 1081 return p; |
| 1082 } | |
| 1083 | |
| 1084 stmt_ty | |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1085 With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body, int lineno, |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1086 int col_offset, PyArena *arena) |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1087 { |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1088 stmt_ty p; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1089 if (!context_expr) { |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1090 PyErr_SetString(PyExc_ValueError, |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1091 "field context_expr is required for With"); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1092 return NULL; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1093 } |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1094 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1095 if (!p) |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1096 return NULL; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1097 p->kind = With_kind; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1098 p->v.With.context_expr = context_expr; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1099 p->v.With.optional_vars = optional_vars; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1100 p->v.With.body = body; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1101 p->lineno = lineno; |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1102 p->col_offset = col_offset; |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1103 return p; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1104 } |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1105 |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1106 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
|
1107 Raise(expr_ty type, expr_ty inst, expr_ty tback, 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
|
1108 PyArena *arena) |
| 35742 | 1109 { |
| 1110 stmt_ty p; | |
|
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
|
1111 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1112 if (!p) |
| 35742 | 1113 return NULL; |
| 1114 p->kind = Raise_kind; | |
| 1115 p->v.Raise.type = type; | |
| 1116 p->v.Raise.inst = inst; | |
| 1117 p->v.Raise.tback = tback; | |
| 1118 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1119 p->col_offset = col_offset; |
| 35742 | 1120 return p; |
| 1121 } | |
| 1122 | |
| 1123 stmt_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
|
1124 TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, int lineno, |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1125 int col_offset, PyArena *arena) |
| 35742 | 1126 { |
| 1127 stmt_ty p; | |
|
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
|
1128 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1129 if (!p) |
| 35742 | 1130 return NULL; |
| 1131 p->kind = TryExcept_kind; | |
| 1132 p->v.TryExcept.body = body; | |
| 1133 p->v.TryExcept.handlers = handlers; | |
| 1134 p->v.TryExcept.orelse = orelse; | |
| 1135 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1136 p->col_offset = col_offset; |
| 35742 | 1137 return p; |
| 1138 } | |
| 1139 | |
| 1140 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
|
1141 TryFinally(asdl_seq * body, asdl_seq * finalbody, 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
|
1142 PyArena *arena) |
| 35742 | 1143 { |
| 1144 stmt_ty p; | |
|
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
|
1145 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1146 if (!p) |
| 35742 | 1147 return NULL; |
| 1148 p->kind = TryFinally_kind; | |
| 1149 p->v.TryFinally.body = body; | |
| 1150 p->v.TryFinally.finalbody = finalbody; | |
| 1151 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1152 p->col_offset = col_offset; |
| 35742 | 1153 return p; |
| 1154 } | |
| 1155 | |
| 1156 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
|
1157 Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1158 { |
| 1159 stmt_ty p; | |
| 1160 if (!test) { | |
| 1161 PyErr_SetString(PyExc_ValueError, | |
| 1162 "field test is required for Assert"); | |
| 1163 return NULL; | |
| 1164 } | |
|
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
|
1165 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1166 if (!p) |
| 35742 | 1167 return NULL; |
| 1168 p->kind = Assert_kind; | |
| 1169 p->v.Assert.test = test; | |
| 1170 p->v.Assert.msg = msg; | |
| 1171 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1172 p->col_offset = col_offset; |
| 35742 | 1173 return p; |
| 1174 } | |
| 1175 | |
| 1176 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
|
1177 Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1178 { |
| 1179 stmt_ty p; | |
|
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
|
1180 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1181 if (!p) |
| 35742 | 1182 return NULL; |
| 1183 p->kind = Import_kind; | |
| 1184 p->v.Import.names = names; | |
| 1185 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1186 p->col_offset = col_offset; |
| 35742 | 1187 return p; |
| 1188 } | |
| 1189 | |
| 1190 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
|
1191 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
|
1192 col_offset, PyArena *arena) |
| 35742 | 1193 { |
| 1194 stmt_ty p; | |
| 1195 if (!module) { | |
| 1196 PyErr_SetString(PyExc_ValueError, | |
| 1197 "field module is required for ImportFrom"); | |
| 1198 return NULL; | |
| 1199 } | |
|
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
|
1200 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1201 if (!p) |
| 35742 | 1202 return NULL; |
| 1203 p->kind = ImportFrom_kind; | |
| 1204 p->v.ImportFrom.module = module; | |
| 1205 p->v.ImportFrom.names = names; | |
|
36712
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
1206 p->v.ImportFrom.level = level; |
| 35742 | 1207 p->lineno = lineno; |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1208 p->col_offset = col_offset; |
| 35742 | 1209 return p; |
| 1210 } | |
| 1211 | |
| 1212 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
|
1213 Exec(expr_ty body, expr_ty globals, expr_ty locals, 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
|
1214 PyArena *arena) |
| 35742 | 1215 { |
| 1216 stmt_ty p; | |
| 1217 if (!body) { | |
| 1218 PyErr_SetString(PyExc_ValueError, | |
| 1219 "field body is required for Exec"); | |
| 1220 return NULL; | |
| 1221 } | |
|
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
|
1222 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1223 if (!p) |
| 35742 | 1224 return NULL; |
| 1225 p->kind = Exec_kind; | |
| 1226 p->v.Exec.body = body; | |
| 1227 p->v.Exec.globals = globals; | |
| 1228 p->v.Exec.locals = locals; | |
| 1229 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1230 p->col_offset = col_offset; |
| 35742 | 1231 return p; |
| 1232 } | |
| 1233 | |
| 1234 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
|
1235 Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1236 { |
| 1237 stmt_ty p; | |
|
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
|
1238 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1239 if (!p) |
| 35742 | 1240 return NULL; |
| 1241 p->kind = Global_kind; | |
| 1242 p->v.Global.names = names; | |
| 1243 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1244 p->col_offset = col_offset; |
| 35742 | 1245 return p; |
| 1246 } | |
| 1247 | |
| 1248 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
|
1249 Expr(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1250 { |
| 1251 stmt_ty p; | |
| 1252 if (!value) { | |
| 1253 PyErr_SetString(PyExc_ValueError, | |
| 1254 "field value is required for Expr"); | |
| 1255 return NULL; | |
| 1256 } | |
|
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
|
1257 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1258 if (!p) |
| 35742 | 1259 return NULL; |
| 1260 p->kind = Expr_kind; | |
| 1261 p->v.Expr.value = value; | |
| 1262 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1263 p->col_offset = col_offset; |
| 35742 | 1264 return p; |
| 1265 } | |
| 1266 | |
| 1267 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
|
1268 Pass(int lineno, int col_offset, PyArena *arena) |
| 35742 | 1269 { |
| 1270 stmt_ty p; | |
|
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
|
1271 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1272 if (!p) |
| 35742 | 1273 return NULL; |
| 1274 p->kind = Pass_kind; | |
| 1275 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1276 p->col_offset = col_offset; |
| 35742 | 1277 return p; |
| 1278 } | |
| 1279 | |
| 1280 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
|
1281 Break(int lineno, int col_offset, PyArena *arena) |
| 35742 | 1282 { |
| 1283 stmt_ty p; | |
|
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
|
1284 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1285 if (!p) |
| 35742 | 1286 return NULL; |
| 1287 p->kind = Break_kind; | |
| 1288 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1289 p->col_offset = col_offset; |
| 35742 | 1290 return p; |
| 1291 } | |
| 1292 | |
| 1293 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
|
1294 Continue(int lineno, int col_offset, PyArena *arena) |
| 35742 | 1295 { |
| 1296 stmt_ty p; | |
|
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
|
1297 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1298 if (!p) |
| 35742 | 1299 return NULL; |
| 1300 p->kind = Continue_kind; | |
| 1301 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1302 p->col_offset = col_offset; |
| 35742 | 1303 return p; |
| 1304 } | |
| 1305 | |
| 1306 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
|
1307 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
|
1308 *arena) |
| 35742 | 1309 { |
| 1310 expr_ty p; | |
| 1311 if (!op) { | |
| 1312 PyErr_SetString(PyExc_ValueError, | |
| 1313 "field op is required for BoolOp"); | |
| 1314 return NULL; | |
| 1315 } | |
|
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
|
1316 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1317 if (!p) |
| 35742 | 1318 return NULL; |
| 1319 p->kind = BoolOp_kind; | |
| 1320 p->v.BoolOp.op = op; | |
| 1321 p->v.BoolOp.values = values; | |
| 1322 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1323 p->col_offset = col_offset; |
| 35742 | 1324 return p; |
| 1325 } | |
| 1326 | |
| 1327 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
|
1328 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
|
1329 PyArena *arena) |
| 35742 | 1330 { |
| 1331 expr_ty p; | |
| 1332 if (!left) { | |
| 1333 PyErr_SetString(PyExc_ValueError, | |
| 1334 "field left is required for BinOp"); | |
| 1335 return NULL; | |
| 1336 } | |
| 1337 if (!op) { | |
| 1338 PyErr_SetString(PyExc_ValueError, | |
| 1339 "field op is required for BinOp"); | |
| 1340 return NULL; | |
| 1341 } | |
| 1342 if (!right) { | |
| 1343 PyErr_SetString(PyExc_ValueError, | |
| 1344 "field right is required for BinOp"); | |
| 1345 return NULL; | |
| 1346 } | |
|
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
|
1347 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1348 if (!p) |
| 35742 | 1349 return NULL; |
| 1350 p->kind = BinOp_kind; | |
| 1351 p->v.BinOp.left = left; | |
| 1352 p->v.BinOp.op = op; | |
| 1353 p->v.BinOp.right = right; | |
| 1354 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1355 p->col_offset = col_offset; |
| 35742 | 1356 return p; |
| 1357 } | |
| 1358 | |
| 1359 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
|
1360 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
|
1361 *arena) |
| 35742 | 1362 { |
| 1363 expr_ty p; | |
| 1364 if (!op) { | |
| 1365 PyErr_SetString(PyExc_ValueError, | |
| 1366 "field op is required for UnaryOp"); | |
| 1367 return NULL; | |
| 1368 } | |
| 1369 if (!operand) { | |
| 1370 PyErr_SetString(PyExc_ValueError, | |
| 1371 "field operand is required for UnaryOp"); | |
| 1372 return NULL; | |
| 1373 } | |
|
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
|
1374 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1375 if (!p) |
| 35742 | 1376 return NULL; |
| 1377 p->kind = UnaryOp_kind; | |
| 1378 p->v.UnaryOp.op = op; | |
| 1379 p->v.UnaryOp.operand = operand; | |
| 1380 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1381 p->col_offset = col_offset; |
| 35742 | 1382 return p; |
| 1383 } | |
| 1384 | |
| 1385 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
|
1386 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
|
1387 *arena) |
| 35742 | 1388 { |
| 1389 expr_ty p; | |
| 1390 if (!args) { | |
| 1391 PyErr_SetString(PyExc_ValueError, | |
| 1392 "field args is required for Lambda"); | |
| 1393 return NULL; | |
| 1394 } | |
| 1395 if (!body) { | |
| 1396 PyErr_SetString(PyExc_ValueError, | |
| 1397 "field body is required for Lambda"); | |
| 1398 return NULL; | |
| 1399 } | |
|
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
|
1400 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1401 if (!p) |
| 35742 | 1402 return NULL; |
| 1403 p->kind = Lambda_kind; | |
| 1404 p->v.Lambda.args = args; | |
| 1405 p->v.Lambda.body = body; | |
| 1406 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1407 p->col_offset = col_offset; |
| 35742 | 1408 return p; |
| 1409 } | |
| 1410 | |
| 1411 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
|
1412 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
|
1413 PyArena *arena) |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1414 { |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1415 expr_ty p; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1416 if (!test) { |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1417 PyErr_SetString(PyExc_ValueError, |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1418 "field test is required for IfExp"); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1419 return NULL; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1420 } |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1421 if (!body) { |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1422 PyErr_SetString(PyExc_ValueError, |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1423 "field body is required for IfExp"); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1424 return NULL; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1425 } |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1426 if (!orelse) { |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1427 PyErr_SetString(PyExc_ValueError, |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1428 "field orelse is required for IfExp"); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1429 return NULL; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1430 } |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1431 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1432 if (!p) |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1433 return NULL; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1434 p->kind = IfExp_kind; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1435 p->v.IfExp.test = test; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1436 p->v.IfExp.body = body; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1437 p->v.IfExp.orelse = orelse; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1438 p->lineno = lineno; |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1439 p->col_offset = col_offset; |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1440 return p; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1441 } |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1442 |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1443 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
|
1444 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
|
1445 *arena) |
| 35742 | 1446 { |
| 1447 expr_ty p; | |
|
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
|
1448 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1449 if (!p) |
| 35742 | 1450 return NULL; |
| 1451 p->kind = Dict_kind; | |
| 1452 p->v.Dict.keys = keys; | |
| 1453 p->v.Dict.values = values; | |
| 1454 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1455 p->col_offset = col_offset; |
| 35742 | 1456 return p; |
| 1457 } | |
| 1458 | |
| 1459 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
|
1460 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
|
1461 PyArena *arena) |
| 35742 | 1462 { |
| 1463 expr_ty p; | |
| 1464 if (!elt) { | |
| 1465 PyErr_SetString(PyExc_ValueError, | |
| 1466 "field elt is required for ListComp"); | |
| 1467 return NULL; | |
| 1468 } | |
|
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
|
1469 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1470 if (!p) |
| 35742 | 1471 return NULL; |
| 1472 p->kind = ListComp_kind; | |
| 1473 p->v.ListComp.elt = elt; | |
| 1474 p->v.ListComp.generators = generators; | |
| 1475 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1476 p->col_offset = col_offset; |
| 35742 | 1477 return p; |
| 1478 } | |
| 1479 | |
| 1480 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
|
1481 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
|
1482 PyArena *arena) |
| 35742 | 1483 { |
| 1484 expr_ty p; | |
| 1485 if (!elt) { | |
| 1486 PyErr_SetString(PyExc_ValueError, | |
| 1487 "field elt is required for GeneratorExp"); | |
| 1488 return NULL; | |
| 1489 } | |
|
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
|
1490 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1491 if (!p) |
| 35742 | 1492 return NULL; |
| 1493 p->kind = GeneratorExp_kind; | |
| 1494 p->v.GeneratorExp.elt = elt; | |
| 1495 p->v.GeneratorExp.generators = generators; | |
| 1496 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1497 p->col_offset = col_offset; |
| 35742 | 1498 return p; |
| 1499 } | |
| 1500 | |
| 1501 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
|
1502 Yield(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1503 { |
| 1504 expr_ty p; | |
|
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
|
1505 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1506 if (!p) |
| 35742 | 1507 return NULL; |
| 1508 p->kind = Yield_kind; | |
| 1509 p->v.Yield.value = value; | |
| 1510 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1511 p->col_offset = col_offset; |
| 35742 | 1512 return p; |
| 1513 } | |
| 1514 | |
| 1515 expr_ty | |
|
37685
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
37601
diff
changeset
|
1516 Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int lineno, |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
37601
diff
changeset
|
1517 int col_offset, PyArena *arena) |
| 35742 | 1518 { |
| 1519 expr_ty p; | |
| 1520 if (!left) { | |
| 1521 PyErr_SetString(PyExc_ValueError, | |
| 1522 "field left is required for Compare"); | |
| 1523 return NULL; | |
| 1524 } | |
|
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
|
1525 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1526 if (!p) |
| 35742 | 1527 return NULL; |
| 1528 p->kind = Compare_kind; | |
| 1529 p->v.Compare.left = left; | |
| 1530 p->v.Compare.ops = ops; | |
| 1531 p->v.Compare.comparators = comparators; | |
| 1532 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1533 p->col_offset = col_offset; |
| 35742 | 1534 return p; |
| 1535 } | |
| 1536 | |
| 1537 expr_ty | |
| 1538 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
|
1539 expr_ty kwargs, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1540 { |
| 1541 expr_ty p; | |
| 1542 if (!func) { | |
| 1543 PyErr_SetString(PyExc_ValueError, | |
| 1544 "field func is required for Call"); | |
| 1545 return NULL; | |
| 1546 } | |
|
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
|
1547 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1548 if (!p) |
| 35742 | 1549 return NULL; |
| 1550 p->kind = Call_kind; | |
| 1551 p->v.Call.func = func; | |
| 1552 p->v.Call.args = args; | |
| 1553 p->v.Call.keywords = keywords; | |
| 1554 p->v.Call.starargs = starargs; | |
| 1555 p->v.Call.kwargs = kwargs; | |
| 1556 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1557 p->col_offset = col_offset; |
| 35742 | 1558 return p; |
| 1559 } | |
| 1560 | |
| 1561 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
|
1562 Repr(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1563 { |
| 1564 expr_ty p; | |
| 1565 if (!value) { | |
| 1566 PyErr_SetString(PyExc_ValueError, | |
| 1567 "field value is required for Repr"); | |
| 1568 return NULL; | |
| 1569 } | |
|
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
|
1570 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1571 if (!p) |
| 35742 | 1572 return NULL; |
| 1573 p->kind = Repr_kind; | |
| 1574 p->v.Repr.value = value; | |
| 1575 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1576 p->col_offset = col_offset; |
| 35742 | 1577 return p; |
| 1578 } | |
| 1579 | |
| 1580 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
|
1581 Num(object n, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1582 { |
| 1583 expr_ty p; | |
| 1584 if (!n) { | |
| 1585 PyErr_SetString(PyExc_ValueError, | |
| 1586 "field n is required for Num"); | |
| 1587 return NULL; | |
| 1588 } | |
|
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
|
1589 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1590 if (!p) |
| 35742 | 1591 return NULL; |
| 1592 p->kind = Num_kind; | |
| 1593 p->v.Num.n = n; | |
| 1594 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1595 p->col_offset = col_offset; |
| 35742 | 1596 return p; |
| 1597 } | |
| 1598 | |
| 1599 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
|
1600 Str(string s, int lineno, int col_offset, PyArena *arena) |
| 35742 | 1601 { |
| 1602 expr_ty p; | |
| 1603 if (!s) { | |
| 1604 PyErr_SetString(PyExc_ValueError, | |
| 1605 "field s is required for Str"); | |
| 1606 return NULL; | |
| 1607 } | |
|
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
|
1608 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1609 if (!p) |
| 35742 | 1610 return NULL; |
| 1611 p->kind = Str_kind; | |
| 1612 p->v.Str.s = s; | |
| 1613 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1614 p->col_offset = col_offset; |
| 35742 | 1615 return p; |
| 1616 } | |
| 1617 | |
| 1618 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
|
1619 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
|
1620 col_offset, PyArena *arena) |
| 35742 | 1621 { |
| 1622 expr_ty p; | |
| 1623 if (!value) { | |
| 1624 PyErr_SetString(PyExc_ValueError, | |
| 1625 "field value is required for Attribute"); | |
| 1626 return NULL; | |
| 1627 } | |
| 1628 if (!attr) { | |
| 1629 PyErr_SetString(PyExc_ValueError, | |
| 1630 "field attr is required for Attribute"); | |
| 1631 return NULL; | |
| 1632 } | |
| 1633 if (!ctx) { | |
| 1634 PyErr_SetString(PyExc_ValueError, | |
| 1635 "field ctx is required for Attribute"); | |
| 1636 return NULL; | |
| 1637 } | |
|
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
|
1638 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1639 if (!p) |
| 35742 | 1640 return NULL; |
| 1641 p->kind = Attribute_kind; | |
| 1642 p->v.Attribute.value = value; | |
| 1643 p->v.Attribute.attr = attr; | |
| 1644 p->v.Attribute.ctx = ctx; | |
| 1645 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1646 p->col_offset = col_offset; |
| 35742 | 1647 return p; |
| 1648 } | |
| 1649 | |
| 1650 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
|
1651 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
|
1652 col_offset, PyArena *arena) |
| 35742 | 1653 { |
| 1654 expr_ty p; | |
| 1655 if (!value) { | |
| 1656 PyErr_SetString(PyExc_ValueError, | |
| 1657 "field value is required for Subscript"); | |
| 1658 return NULL; | |
| 1659 } | |
| 1660 if (!slice) { | |
| 1661 PyErr_SetString(PyExc_ValueError, | |
| 1662 "field slice is required for Subscript"); | |
| 1663 return NULL; | |
| 1664 } | |
| 1665 if (!ctx) { | |
| 1666 PyErr_SetString(PyExc_ValueError, | |
| 1667 "field ctx is required for Subscript"); | |
| 1668 return NULL; | |
| 1669 } | |
|
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
|
1670 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1671 if (!p) |
| 35742 | 1672 return NULL; |
| 1673 p->kind = Subscript_kind; | |
| 1674 p->v.Subscript.value = value; | |
| 1675 p->v.Subscript.slice = slice; | |
| 1676 p->v.Subscript.ctx = ctx; | |
| 1677 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1678 p->col_offset = col_offset; |
| 35742 | 1679 return p; |
| 1680 } | |
| 1681 | |
| 1682 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
|
1683 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
|
1684 *arena) |
| 35742 | 1685 { |
| 1686 expr_ty p; | |
| 1687 if (!id) { | |
| 1688 PyErr_SetString(PyExc_ValueError, | |
| 1689 "field id is required for Name"); | |
| 1690 return NULL; | |
| 1691 } | |
| 1692 if (!ctx) { | |
| 1693 PyErr_SetString(PyExc_ValueError, | |
| 1694 "field ctx is required for Name"); | |
| 1695 return NULL; | |
| 1696 } | |
|
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
|
1697 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1698 if (!p) |
| 35742 | 1699 return NULL; |
| 1700 p->kind = Name_kind; | |
| 1701 p->v.Name.id = id; | |
| 1702 p->v.Name.ctx = ctx; | |
| 1703 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1704 p->col_offset = col_offset; |
| 35742 | 1705 return p; |
| 1706 } | |
| 1707 | |
| 1708 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
|
1709 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
|
1710 *arena) |
| 35742 | 1711 { |
| 1712 expr_ty p; | |
| 1713 if (!ctx) { | |
| 1714 PyErr_SetString(PyExc_ValueError, | |
| 1715 "field ctx is required for List"); | |
| 1716 return NULL; | |
| 1717 } | |
|
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
|
1718 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1719 if (!p) |
| 35742 | 1720 return NULL; |
| 1721 p->kind = List_kind; | |
| 1722 p->v.List.elts = elts; | |
| 1723 p->v.List.ctx = ctx; | |
| 1724 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1725 p->col_offset = col_offset; |
| 35742 | 1726 return p; |
| 1727 } | |
| 1728 | |
| 1729 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
|
1730 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
|
1731 *arena) |
| 35742 | 1732 { |
| 1733 expr_ty p; | |
| 1734 if (!ctx) { | |
| 1735 PyErr_SetString(PyExc_ValueError, | |
| 1736 "field ctx is required for Tuple"); | |
| 1737 return NULL; | |
| 1738 } | |
|
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
|
1739 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1740 if (!p) |
| 35742 | 1741 return NULL; |
| 1742 p->kind = Tuple_kind; | |
| 1743 p->v.Tuple.elts = elts; | |
| 1744 p->v.Tuple.ctx = ctx; | |
| 1745 p->lineno = lineno; | |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
1746 p->col_offset = col_offset; |
| 35742 | 1747 return p; |
| 1748 } | |
| 1749 | |
| 1750 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
|
1751 Ellipsis(PyArena *arena) |
| 35742 | 1752 { |
| 1753 slice_ty p; | |
|
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
|
1754 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1755 if (!p) |
| 35742 | 1756 return NULL; |
| 1757 p->kind = Ellipsis_kind; | |
| 1758 return p; | |
| 1759 } | |
| 1760 | |
| 1761 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
|
1762 Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena) |
| 35742 | 1763 { |
| 1764 slice_ty p; | |
|
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
|
1765 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1766 if (!p) |
| 35742 | 1767 return NULL; |
| 1768 p->kind = Slice_kind; | |
| 1769 p->v.Slice.lower = lower; | |
| 1770 p->v.Slice.upper = upper; | |
| 1771 p->v.Slice.step = step; | |
| 1772 return p; | |
| 1773 } | |
| 1774 | |
| 1775 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
|
1776 ExtSlice(asdl_seq * dims, PyArena *arena) |
| 35742 | 1777 { |
| 1778 slice_ty p; | |
|
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
|
1779 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1780 if (!p) |
| 35742 | 1781 return NULL; |
| 1782 p->kind = ExtSlice_kind; | |
| 1783 p->v.ExtSlice.dims = dims; | |
| 1784 return p; | |
| 1785 } | |
| 1786 | |
| 1787 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
|
1788 Index(expr_ty value, PyArena *arena) |
| 35742 | 1789 { |
| 1790 slice_ty p; | |
| 1791 if (!value) { | |
| 1792 PyErr_SetString(PyExc_ValueError, | |
| 1793 "field value is required for Index"); | |
| 1794 return NULL; | |
| 1795 } | |
|
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
|
1796 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1797 if (!p) |
| 35742 | 1798 return NULL; |
| 1799 p->kind = Index_kind; | |
| 1800 p->v.Index.value = value; | |
| 1801 return p; | |
| 1802 } | |
| 1803 | |
| 1804 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
|
1805 comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena) |
| 35742 | 1806 { |
| 1807 comprehension_ty p; | |
| 1808 if (!target) { | |
| 1809 PyErr_SetString(PyExc_ValueError, | |
| 1810 "field target is required for comprehension"); | |
| 1811 return NULL; | |
| 1812 } | |
| 1813 if (!iter) { | |
| 1814 PyErr_SetString(PyExc_ValueError, | |
| 1815 "field iter is required for comprehension"); | |
| 1816 return NULL; | |
| 1817 } | |
|
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
|
1818 p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1819 if (!p) |
| 35742 | 1820 return NULL; |
| 1821 p->target = target; | |
| 1822 p->iter = iter; | |
| 1823 p->ifs = ifs; | |
| 1824 return p; | |
| 1825 } | |
| 1826 | |
| 1827 excepthandler_ty | |
|
37453
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
1828 excepthandler(expr_ty type, expr_ty name, asdl_seq * body, int lineno, int |
|
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
1829 col_offset, PyArena *arena) |
| 35742 | 1830 { |
| 1831 excepthandler_ty p; | |
|
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
|
1832 p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1833 if (!p) |
| 35742 | 1834 return NULL; |
| 1835 p->type = type; | |
| 1836 p->name = name; | |
| 1837 p->body = body; | |
|
37453
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
1838 p->lineno = lineno; |
|
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
1839 p->col_offset = col_offset; |
| 35742 | 1840 return p; |
| 1841 } | |
| 1842 | |
| 1843 arguments_ty | |
| 1844 arguments(asdl_seq * args, identifier vararg, identifier kwarg, asdl_seq * | |
|
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
|
1845 defaults, PyArena *arena) |
| 35742 | 1846 { |
| 1847 arguments_ty p; | |
|
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
|
1848 p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1849 if (!p) |
| 35742 | 1850 return NULL; |
| 1851 p->args = args; | |
| 1852 p->vararg = vararg; | |
| 1853 p->kwarg = kwarg; | |
| 1854 p->defaults = defaults; | |
| 1855 return p; | |
| 1856 } | |
| 1857 | |
| 1858 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
|
1859 keyword(identifier arg, expr_ty value, PyArena *arena) |
| 35742 | 1860 { |
| 1861 keyword_ty p; | |
| 1862 if (!arg) { | |
| 1863 PyErr_SetString(PyExc_ValueError, | |
| 1864 "field arg is required for keyword"); | |
| 1865 return NULL; | |
| 1866 } | |
| 1867 if (!value) { | |
| 1868 PyErr_SetString(PyExc_ValueError, | |
| 1869 "field value is required for keyword"); | |
| 1870 return NULL; | |
| 1871 } | |
|
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
|
1872 p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1873 if (!p) |
| 35742 | 1874 return NULL; |
| 1875 p->arg = arg; | |
| 1876 p->value = value; | |
| 1877 return p; | |
| 1878 } | |
| 1879 | |
| 1880 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
|
1881 alias(identifier name, identifier asname, PyArena *arena) |
| 35742 | 1882 { |
| 1883 alias_ty p; | |
| 1884 if (!name) { | |
| 1885 PyErr_SetString(PyExc_ValueError, | |
| 1886 "field name is required for alias"); | |
| 1887 return NULL; | |
| 1888 } | |
|
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
|
1889 p = (alias_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
40936
0376f13a1af9
Fix a couple of problems in generating the AST code:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40824
diff
changeset
|
1890 if (!p) |
| 35742 | 1891 return NULL; |
| 1892 p->name = name; | |
| 1893 p->asname = asname; | |
| 1894 return p; | |
| 1895 } | |
| 1896 | |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1897 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1898 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1899 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
|
1900 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1901 mod_ty o = (mod_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1902 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1903 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1904 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1905 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1906 } |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1907 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1908 switch (o->kind) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1909 case Module_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1910 result = PyType_GenericNew(Module_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1911 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1912 value = ast2obj_list(o->v.Module.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1913 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1914 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1915 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1916 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1917 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1918 case Interactive_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1919 result = PyType_GenericNew(Interactive_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1920 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1921 value = ast2obj_list(o->v.Interactive.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1922 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1923 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1924 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1925 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1926 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1927 case Expression_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1928 result = PyType_GenericNew(Expression_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1929 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1930 value = ast2obj_expr(o->v.Expression.body); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1931 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1932 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1933 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1934 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1935 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1936 case Suite_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1937 result = PyType_GenericNew(Suite_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1938 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1939 value = ast2obj_list(o->v.Suite.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1940 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1941 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1942 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1943 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1944 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1945 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1946 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1947 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1948 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1949 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1950 return NULL; |
| 36174 | 1951 } |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1952 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1953 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1954 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
|
1955 { |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1956 stmt_ty o = (stmt_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1957 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1958 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1959 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1960 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1961 } |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1962 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1963 switch (o->kind) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1964 case FunctionDef_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1965 result = PyType_GenericNew(FunctionDef_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1966 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1967 value = ast2obj_identifier(o->v.FunctionDef.name); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1968 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1969 if (PyObject_SetAttrString(result, "name", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1970 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1971 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1972 value = ast2obj_arguments(o->v.FunctionDef.args); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1973 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1974 if (PyObject_SetAttrString(result, "args", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1975 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1976 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1977 value = ast2obj_list(o->v.FunctionDef.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1978 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1979 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1980 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1981 Py_DECREF(value); |
|
45447
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
1982 value = ast2obj_list(o->v.FunctionDef.decorator_list, |
|
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
1983 ast2obj_expr); |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1984 if (!value) goto failed; |
|
45447
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
1985 if (PyObject_SetAttrString(result, "decorator_list", value) == |
|
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
1986 -1) |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1987 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1988 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1989 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1990 case ClassDef_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1991 result = PyType_GenericNew(ClassDef_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1992 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1993 value = ast2obj_identifier(o->v.ClassDef.name); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1994 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1995 if (PyObject_SetAttrString(result, "name", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1996 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1997 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1998 value = ast2obj_list(o->v.ClassDef.bases, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1999 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2000 if (PyObject_SetAttrString(result, "bases", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2001 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2002 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2003 value = ast2obj_list(o->v.ClassDef.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2004 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2005 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2006 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2007 Py_DECREF(value); |
|
45447
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
2008 value = ast2obj_list(o->v.ClassDef.decorator_list, |
|
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
2009 ast2obj_expr); |
|
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
2010 if (!value) goto failed; |
|
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
2011 if (PyObject_SetAttrString(result, "decorator_list", value) == |
|
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
2012 -1) |
|
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
2013 goto failed; |
|
393822f2ef90
Patch #1759: Backport of PEP 3129 class decorators
Christian Heimes <christian@cheimes.de>
parents:
40936
diff
changeset
|
2014 Py_DECREF(value); |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2015 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2016 case Return_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2017 result = PyType_GenericNew(Return_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2018 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2019 value = ast2obj_expr(o->v.Return.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2020 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2021 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2022 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2023 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2024 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2025 case Delete_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2026 result = PyType_GenericNew(Delete_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2027 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2028 value = ast2obj_list(o->v.Delete.targets, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2029 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2030 if (PyObject_SetAttrString(result, "targets", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2031 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2032 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2033 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2034 case Assign_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2035 result = PyType_GenericNew(Assign_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2036 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2037 value = ast2obj_list(o->v.Assign.targets, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2038 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2039 if (PyObject_SetAttrString(result, "targets", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2040 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2041 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2042 value = ast2obj_expr(o->v.Assign.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2043 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2044 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2045 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2046 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2047 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2048 case AugAssign_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2049 result = PyType_GenericNew(AugAssign_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2050 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2051 value = ast2obj_expr(o->v.AugAssign.target); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2052 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2053 if (PyObject_SetAttrString(result, "target", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2054 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2055 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2056 value = ast2obj_operator(o->v.AugAssign.op); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2057 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2058 if (PyObject_SetAttrString(result, "op", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2059 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2060 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2061 value = ast2obj_expr(o->v.AugAssign.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2062 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2063 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2064 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2065 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2066 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2067 case Print_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2068 result = PyType_GenericNew(Print_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2069 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2070 value = ast2obj_expr(o->v.Print.dest); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2071 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2072 if (PyObject_SetAttrString(result, "dest", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2073 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2074 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2075 value = ast2obj_list(o->v.Print.values, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2076 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2077 if (PyObject_SetAttrString(result, "values", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2078 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2079 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2080 value = ast2obj_bool(o->v.Print.nl); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2081 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2082 if (PyObject_SetAttrString(result, "nl", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2083 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2084 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2085 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2086 case For_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2087 result = PyType_GenericNew(For_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2088 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2089 value = ast2obj_expr(o->v.For.target); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2090 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2091 if (PyObject_SetAttrString(result, "target", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2092 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2093 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2094 value = ast2obj_expr(o->v.For.iter); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2095 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2096 if (PyObject_SetAttrString(result, "iter", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2097 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2098 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2099 value = ast2obj_list(o->v.For.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2100 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2101 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2102 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2103 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2104 value = ast2obj_list(o->v.For.orelse, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2105 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2106 if (PyObject_SetAttrString(result, "orelse", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2107 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2108 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2109 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2110 case While_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2111 result = PyType_GenericNew(While_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2112 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2113 value = ast2obj_expr(o->v.While.test); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2114 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2115 if (PyObject_SetAttrString(result, "test", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2116 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2117 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2118 value = ast2obj_list(o->v.While.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2119 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2120 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2121 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2122 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2123 value = ast2obj_list(o->v.While.orelse, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2124 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2125 if (PyObject_SetAttrString(result, "orelse", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2126 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2127 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2128 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2129 case If_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2130 result = PyType_GenericNew(If_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2131 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2132 value = ast2obj_expr(o->v.If.test); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2133 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2134 if (PyObject_SetAttrString(result, "test", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2135 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2136 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2137 value = ast2obj_list(o->v.If.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2138 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2139 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2140 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2141 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2142 value = ast2obj_list(o->v.If.orelse, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2143 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2144 if (PyObject_SetAttrString(result, "orelse", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2145 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2146 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2147 break; |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2148 case With_kind: |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2149 result = PyType_GenericNew(With_type, NULL, NULL); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2150 if (!result) goto failed; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2151 value = ast2obj_expr(o->v.With.context_expr); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2152 if (!value) goto failed; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2153 if (PyObject_SetAttrString(result, "context_expr", value) == -1) |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2154 goto failed; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2155 Py_DECREF(value); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2156 value = ast2obj_expr(o->v.With.optional_vars); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2157 if (!value) goto failed; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2158 if (PyObject_SetAttrString(result, "optional_vars", value) == |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2159 -1) |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2160 goto failed; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2161 Py_DECREF(value); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2162 value = ast2obj_list(o->v.With.body, ast2obj_stmt); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2163 if (!value) goto failed; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2164 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2165 goto failed; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2166 Py_DECREF(value); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2167 break; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2168 case Raise_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2169 result = PyType_GenericNew(Raise_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2170 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2171 value = ast2obj_expr(o->v.Raise.type); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2172 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2173 if (PyObject_SetAttrString(result, "type", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2174 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2175 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2176 value = ast2obj_expr(o->v.Raise.inst); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2177 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2178 if (PyObject_SetAttrString(result, "inst", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2179 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2180 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2181 value = ast2obj_expr(o->v.Raise.tback); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2182 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2183 if (PyObject_SetAttrString(result, "tback", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2184 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2185 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2186 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2187 case TryExcept_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2188 result = PyType_GenericNew(TryExcept_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2189 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2190 value = ast2obj_list(o->v.TryExcept.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2191 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2192 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2193 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2194 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2195 value = ast2obj_list(o->v.TryExcept.handlers, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2196 ast2obj_excepthandler); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2197 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2198 if (PyObject_SetAttrString(result, "handlers", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2199 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2200 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2201 value = ast2obj_list(o->v.TryExcept.orelse, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2202 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2203 if (PyObject_SetAttrString(result, "orelse", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2204 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2205 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2206 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2207 case TryFinally_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2208 result = PyType_GenericNew(TryFinally_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2209 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2210 value = ast2obj_list(o->v.TryFinally.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2211 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2212 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2213 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2214 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2215 value = ast2obj_list(o->v.TryFinally.finalbody, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2216 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2217 if (PyObject_SetAttrString(result, "finalbody", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2218 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2219 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2220 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2221 case Assert_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2222 result = PyType_GenericNew(Assert_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2223 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2224 value = ast2obj_expr(o->v.Assert.test); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2225 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2226 if (PyObject_SetAttrString(result, "test", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2227 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2228 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2229 value = ast2obj_expr(o->v.Assert.msg); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2230 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2231 if (PyObject_SetAttrString(result, "msg", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2232 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2233 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2234 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2235 case Import_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2236 result = PyType_GenericNew(Import_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2237 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2238 value = ast2obj_list(o->v.Import.names, ast2obj_alias); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2239 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2240 if (PyObject_SetAttrString(result, "names", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2241 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2242 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2243 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2244 case ImportFrom_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2245 result = PyType_GenericNew(ImportFrom_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2246 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2247 value = ast2obj_identifier(o->v.ImportFrom.module); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2248 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2249 if (PyObject_SetAttrString(result, "module", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2250 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2251 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2252 value = ast2obj_list(o->v.ImportFrom.names, ast2obj_alias); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2253 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2254 if (PyObject_SetAttrString(result, "names", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2255 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2256 Py_DECREF(value); |
|
36712
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
2257 value = ast2obj_int(o->v.ImportFrom.level); |
|
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
2258 if (!value) goto failed; |
|
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
2259 if (PyObject_SetAttrString(result, "level", value) == -1) |
|
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
2260 goto failed; |
|
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
2261 Py_DECREF(value); |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2262 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2263 case Exec_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2264 result = PyType_GenericNew(Exec_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2265 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2266 value = ast2obj_expr(o->v.Exec.body); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2267 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2268 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2269 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2270 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2271 value = ast2obj_expr(o->v.Exec.globals); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2272 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2273 if (PyObject_SetAttrString(result, "globals", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2274 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2275 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2276 value = ast2obj_expr(o->v.Exec.locals); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2277 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2278 if (PyObject_SetAttrString(result, "locals", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2279 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2280 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2281 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2282 case Global_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2283 result = PyType_GenericNew(Global_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2284 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2285 value = ast2obj_list(o->v.Global.names, ast2obj_identifier); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2286 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2287 if (PyObject_SetAttrString(result, "names", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2288 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2289 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2290 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2291 case Expr_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2292 result = PyType_GenericNew(Expr_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2293 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2294 value = ast2obj_expr(o->v.Expr.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2295 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2296 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2297 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2298 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2299 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2300 case Pass_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2301 result = PyType_GenericNew(Pass_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2302 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2303 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2304 case Break_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2305 result = PyType_GenericNew(Break_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2306 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2307 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2308 case Continue_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2309 result = PyType_GenericNew(Continue_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2310 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2311 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2312 } |
| 36669 | 2313 value = ast2obj_int(o->lineno); |
| 2314 if (!value) goto failed; | |
|
36794
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2315 if (PyObject_SetAttrString(result, "lineno", value) < 0) |
|
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2316 goto failed; |
|
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2317 Py_DECREF(value); |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
2318 value = ast2obj_int(o->col_offset); |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
2319 if (!value) goto failed; |
|
36794
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2320 if (PyObject_SetAttrString(result, "col_offset", value) < 0) |
|
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2321 goto failed; |
|
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2322 Py_DECREF(value); |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2323 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2324 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2325 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2326 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2327 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2328 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2329 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2330 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2331 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
|
2332 { |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2333 expr_ty o = (expr_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2334 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2335 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2336 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2337 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2338 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2339 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2340 switch (o->kind) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2341 case BoolOp_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2342 result = PyType_GenericNew(BoolOp_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2343 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2344 value = ast2obj_boolop(o->v.BoolOp.op); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2345 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2346 if (PyObject_SetAttrString(result, "op", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2347 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2348 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2349 value = ast2obj_list(o->v.BoolOp.values, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2350 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2351 if (PyObject_SetAttrString(result, "values", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2352 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2353 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2354 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2355 case BinOp_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2356 result = PyType_GenericNew(BinOp_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2357 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2358 value = ast2obj_expr(o->v.BinOp.left); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2359 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2360 if (PyObject_SetAttrString(result, "left", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2361 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2362 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2363 value = ast2obj_operator(o->v.BinOp.op); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2364 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2365 if (PyObject_SetAttrString(result, "op", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2366 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2367 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2368 value = ast2obj_expr(o->v.BinOp.right); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2369 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2370 if (PyObject_SetAttrString(result, "right", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2371 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2372 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2373 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2374 case UnaryOp_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2375 result = PyType_GenericNew(UnaryOp_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2376 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2377 value = ast2obj_unaryop(o->v.UnaryOp.op); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2378 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2379 if (PyObject_SetAttrString(result, "op", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2380 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2381 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2382 value = ast2obj_expr(o->v.UnaryOp.operand); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2383 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2384 if (PyObject_SetAttrString(result, "operand", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2385 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2386 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2387 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2388 case Lambda_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2389 result = PyType_GenericNew(Lambda_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2390 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2391 value = ast2obj_arguments(o->v.Lambda.args); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2392 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2393 if (PyObject_SetAttrString(result, "args", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2394 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2395 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2396 value = ast2obj_expr(o->v.Lambda.body); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2397 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2398 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2399 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2400 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2401 break; |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2402 case IfExp_kind: |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2403 result = PyType_GenericNew(IfExp_type, NULL, NULL); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2404 if (!result) goto failed; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2405 value = ast2obj_expr(o->v.IfExp.test); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2406 if (!value) goto failed; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2407 if (PyObject_SetAttrString(result, "test", value) == -1) |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2408 goto failed; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2409 Py_DECREF(value); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2410 value = ast2obj_expr(o->v.IfExp.body); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2411 if (!value) goto failed; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2412 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2413 goto failed; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2414 Py_DECREF(value); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2415 value = ast2obj_expr(o->v.IfExp.orelse); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2416 if (!value) goto failed; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2417 if (PyObject_SetAttrString(result, "orelse", value) == -1) |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2418 goto failed; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2419 Py_DECREF(value); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2420 break; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2421 case Dict_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2422 result = PyType_GenericNew(Dict_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2423 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2424 value = ast2obj_list(o->v.Dict.keys, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2425 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2426 if (PyObject_SetAttrString(result, "keys", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2427 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2428 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2429 value = ast2obj_list(o->v.Dict.values, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2430 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2431 if (PyObject_SetAttrString(result, "values", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2432 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2433 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2434 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2435 case ListComp_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2436 result = PyType_GenericNew(ListComp_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2437 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2438 value = ast2obj_expr(o->v.ListComp.elt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2439 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2440 if (PyObject_SetAttrString(result, "elt", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2441 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2442 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2443 value = ast2obj_list(o->v.ListComp.generators, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2444 ast2obj_comprehension); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2445 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2446 if (PyObject_SetAttrString(result, "generators", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2447 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2448 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2449 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2450 case GeneratorExp_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2451 result = PyType_GenericNew(GeneratorExp_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2452 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2453 value = ast2obj_expr(o->v.GeneratorExp.elt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2454 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2455 if (PyObject_SetAttrString(result, "elt", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2456 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2457 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2458 value = ast2obj_list(o->v.GeneratorExp.generators, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2459 ast2obj_comprehension); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2460 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2461 if (PyObject_SetAttrString(result, "generators", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2462 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2463 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2464 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2465 case Yield_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2466 result = PyType_GenericNew(Yield_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2467 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2468 value = ast2obj_expr(o->v.Yield.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2469 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2470 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2471 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2472 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2473 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2474 case Compare_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2475 result = PyType_GenericNew(Compare_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2476 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2477 value = ast2obj_expr(o->v.Compare.left); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2478 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2479 if (PyObject_SetAttrString(result, "left", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2480 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2481 Py_DECREF(value); |
|
36661
710cbdd478a8
Fix iterating over cmpop_ty lists.
Martin v. Löwis <martin@v.loewis.de>
parents:
36660
diff
changeset
|
2482 { |
|
710cbdd478a8
Fix iterating over cmpop_ty lists.
Martin v. Löwis <martin@v.loewis.de>
parents:
36660
diff
changeset
|
2483 int i, n = asdl_seq_LEN(o->v.Compare.ops); |
|
710cbdd478a8
Fix iterating over cmpop_ty lists.
Martin v. Löwis <martin@v.loewis.de>
parents:
36660
diff
changeset
|
2484 value = PyList_New(n); |
|
710cbdd478a8
Fix iterating over cmpop_ty lists.
Martin v. Löwis <martin@v.loewis.de>
parents:
36660
diff
changeset
|
2485 if (!value) goto failed; |
|
710cbdd478a8
Fix iterating over cmpop_ty lists.
Martin v. Löwis <martin@v.loewis.de>
parents:
36660
diff
changeset
|
2486 for(i = 0; i < n; i++) |
|
37685
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
37601
diff
changeset
|
2487 PyList_SET_ITEM(value, i, ast2obj_cmpop((cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i))); |
|
36661
710cbdd478a8
Fix iterating over cmpop_ty lists.
Martin v. Löwis <martin@v.loewis.de>
parents:
36660
diff
changeset
|
2488 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2489 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2490 if (PyObject_SetAttrString(result, "ops", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2491 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2492 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2493 value = ast2obj_list(o->v.Compare.comparators, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2494 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2495 if (PyObject_SetAttrString(result, "comparators", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2496 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2497 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2498 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2499 case Call_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2500 result = PyType_GenericNew(Call_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2501 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2502 value = ast2obj_expr(o->v.Call.func); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2503 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2504 if (PyObject_SetAttrString(result, "func", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2505 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2506 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2507 value = ast2obj_list(o->v.Call.args, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2508 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2509 if (PyObject_SetAttrString(result, "args", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2510 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2511 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2512 value = ast2obj_list(o->v.Call.keywords, ast2obj_keyword); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2513 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2514 if (PyObject_SetAttrString(result, "keywords", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2515 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2516 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2517 value = ast2obj_expr(o->v.Call.starargs); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2518 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2519 if (PyObject_SetAttrString(result, "starargs", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2520 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2521 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2522 value = ast2obj_expr(o->v.Call.kwargs); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2523 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2524 if (PyObject_SetAttrString(result, "kwargs", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2525 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2526 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2527 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2528 case Repr_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2529 result = PyType_GenericNew(Repr_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2530 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2531 value = ast2obj_expr(o->v.Repr.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2532 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2533 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2534 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2535 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2536 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2537 case Num_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2538 result = PyType_GenericNew(Num_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2539 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2540 value = ast2obj_object(o->v.Num.n); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2541 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2542 if (PyObject_SetAttrString(result, "n", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2543 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2544 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2545 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2546 case Str_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2547 result = PyType_GenericNew(Str_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2548 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2549 value = ast2obj_string(o->v.Str.s); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2550 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2551 if (PyObject_SetAttrString(result, "s", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2552 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2553 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2554 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2555 case Attribute_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2556 result = PyType_GenericNew(Attribute_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2557 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2558 value = ast2obj_expr(o->v.Attribute.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2559 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2560 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2561 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2562 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2563 value = ast2obj_identifier(o->v.Attribute.attr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2564 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2565 if (PyObject_SetAttrString(result, "attr", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2566 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2567 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2568 value = ast2obj_expr_context(o->v.Attribute.ctx); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2569 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2570 if (PyObject_SetAttrString(result, "ctx", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2571 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2572 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2573 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2574 case Subscript_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2575 result = PyType_GenericNew(Subscript_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2576 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2577 value = ast2obj_expr(o->v.Subscript.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2578 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2579 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2580 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2581 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2582 value = ast2obj_slice(o->v.Subscript.slice); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2583 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2584 if (PyObject_SetAttrString(result, "slice", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2585 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2586 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2587 value = ast2obj_expr_context(o->v.Subscript.ctx); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2588 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2589 if (PyObject_SetAttrString(result, "ctx", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2590 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2591 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2592 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2593 case Name_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2594 result = PyType_GenericNew(Name_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2595 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2596 value = ast2obj_identifier(o->v.Name.id); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2597 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2598 if (PyObject_SetAttrString(result, "id", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2599 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2600 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2601 value = ast2obj_expr_context(o->v.Name.ctx); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2602 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2603 if (PyObject_SetAttrString(result, "ctx", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2604 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2605 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2606 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2607 case List_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2608 result = PyType_GenericNew(List_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2609 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2610 value = ast2obj_list(o->v.List.elts, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2611 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2612 if (PyObject_SetAttrString(result, "elts", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2613 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2614 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2615 value = ast2obj_expr_context(o->v.List.ctx); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2616 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2617 if (PyObject_SetAttrString(result, "ctx", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2618 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2619 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2620 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2621 case Tuple_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2622 result = PyType_GenericNew(Tuple_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2623 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2624 value = ast2obj_list(o->v.Tuple.elts, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2625 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2626 if (PyObject_SetAttrString(result, "elts", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2627 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2628 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2629 value = ast2obj_expr_context(o->v.Tuple.ctx); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2630 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2631 if (PyObject_SetAttrString(result, "ctx", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2632 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2633 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2634 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2635 } |
| 36669 | 2636 value = ast2obj_int(o->lineno); |
| 2637 if (!value) goto failed; | |
|
36794
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2638 if (PyObject_SetAttrString(result, "lineno", value) < 0) |
|
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2639 goto failed; |
|
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2640 Py_DECREF(value); |
|
36786
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
2641 value = ast2obj_int(o->col_offset); |
|
57322cb2ca11
Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36743
diff
changeset
|
2642 if (!value) goto failed; |
|
36794
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2643 if (PyObject_SetAttrString(result, "col_offset", value) < 0) |
|
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2644 goto failed; |
|
df843b07f5fe
Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents:
36786
diff
changeset
|
2645 Py_DECREF(value); |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2646 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2647 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2648 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2649 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2650 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2651 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2652 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2653 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
|
2654 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2655 switch(o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2656 case Load: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2657 Py_INCREF(Load_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2658 return Load_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2659 case Store: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2660 Py_INCREF(Store_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2661 return Store_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2662 case Del: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2663 Py_INCREF(Del_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2664 return Del_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2665 case AugLoad: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2666 Py_INCREF(AugLoad_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2667 return AugLoad_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2668 case AugStore: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2669 Py_INCREF(AugStore_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2670 return AugStore_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2671 case Param: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2672 Py_INCREF(Param_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2673 return Param_singleton; |
|
46162
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2674 default: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2675 /* should never happen, but just in case ... */ |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2676 PyErr_Format(PyExc_SystemError, "unknown expr_context found"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2677 return NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2678 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2679 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2680 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2681 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
|
2682 { |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2683 slice_ty o = (slice_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2684 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2685 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2686 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2687 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2688 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2689 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2690 switch (o->kind) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2691 case Ellipsis_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2692 result = PyType_GenericNew(Ellipsis_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2693 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2694 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2695 case Slice_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2696 result = PyType_GenericNew(Slice_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2697 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2698 value = ast2obj_expr(o->v.Slice.lower); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2699 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2700 if (PyObject_SetAttrString(result, "lower", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2701 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2702 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2703 value = ast2obj_expr(o->v.Slice.upper); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2704 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2705 if (PyObject_SetAttrString(result, "upper", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2706 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2707 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2708 value = ast2obj_expr(o->v.Slice.step); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2709 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2710 if (PyObject_SetAttrString(result, "step", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2711 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2712 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2713 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2714 case ExtSlice_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2715 result = PyType_GenericNew(ExtSlice_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2716 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2717 value = ast2obj_list(o->v.ExtSlice.dims, ast2obj_slice); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2718 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2719 if (PyObject_SetAttrString(result, "dims", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2720 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2721 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2722 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2723 case Index_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2724 result = PyType_GenericNew(Index_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2725 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2726 value = ast2obj_expr(o->v.Index.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2727 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2728 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2729 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2730 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2731 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2732 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2733 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2734 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2735 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2736 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2737 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2738 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2739 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2740 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
|
2741 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2742 switch(o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2743 case And: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2744 Py_INCREF(And_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2745 return And_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2746 case Or: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2747 Py_INCREF(Or_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2748 return Or_singleton; |
|
46162
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2749 default: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2750 /* should never happen, but just in case ... */ |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2751 PyErr_Format(PyExc_SystemError, "unknown boolop found"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2752 return NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2753 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2754 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2755 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
|
2756 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2757 switch(o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2758 case Add: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2759 Py_INCREF(Add_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2760 return Add_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2761 case Sub: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2762 Py_INCREF(Sub_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2763 return Sub_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2764 case Mult: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2765 Py_INCREF(Mult_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2766 return Mult_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2767 case Div: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2768 Py_INCREF(Div_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2769 return Div_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2770 case Mod: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2771 Py_INCREF(Mod_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2772 return Mod_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2773 case Pow: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2774 Py_INCREF(Pow_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2775 return Pow_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2776 case LShift: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2777 Py_INCREF(LShift_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2778 return LShift_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2779 case RShift: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2780 Py_INCREF(RShift_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2781 return RShift_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2782 case BitOr: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2783 Py_INCREF(BitOr_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2784 return BitOr_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2785 case BitXor: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2786 Py_INCREF(BitXor_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2787 return BitXor_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2788 case BitAnd: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2789 Py_INCREF(BitAnd_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2790 return BitAnd_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2791 case FloorDiv: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2792 Py_INCREF(FloorDiv_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2793 return FloorDiv_singleton; |
|
46162
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2794 default: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2795 /* should never happen, but just in case ... */ |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2796 PyErr_Format(PyExc_SystemError, "unknown operator found"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2797 return NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2798 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2799 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2800 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
|
2801 { |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2802 switch(o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2803 case Invert: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2804 Py_INCREF(Invert_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2805 return Invert_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2806 case Not: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2807 Py_INCREF(Not_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2808 return Not_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2809 case UAdd: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2810 Py_INCREF(UAdd_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2811 return UAdd_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2812 case USub: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2813 Py_INCREF(USub_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2814 return USub_singleton; |
|
46162
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2815 default: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2816 /* should never happen, but just in case ... */ |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2817 PyErr_Format(PyExc_SystemError, "unknown unaryop found"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2818 return NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2819 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2820 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2821 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
|
2822 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2823 switch(o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2824 case Eq: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2825 Py_INCREF(Eq_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2826 return Eq_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2827 case NotEq: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2828 Py_INCREF(NotEq_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2829 return NotEq_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2830 case Lt: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2831 Py_INCREF(Lt_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2832 return Lt_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2833 case LtE: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2834 Py_INCREF(LtE_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2835 return LtE_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2836 case Gt: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2837 Py_INCREF(Gt_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2838 return Gt_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2839 case GtE: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2840 Py_INCREF(GtE_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2841 return GtE_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2842 case Is: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2843 Py_INCREF(Is_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2844 return Is_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2845 case IsNot: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2846 Py_INCREF(IsNot_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2847 return IsNot_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2848 case In: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2849 Py_INCREF(In_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2850 return In_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2851 case NotIn: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2852 Py_INCREF(NotIn_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2853 return NotIn_singleton; |
|
46162
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2854 default: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2855 /* should never happen, but just in case ... */ |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2856 PyErr_Format(PyExc_SystemError, "unknown cmpop found"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2857 return NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
2858 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2859 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2860 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2861 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
|
2862 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2863 comprehension_ty o = (comprehension_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2864 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2865 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2866 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2867 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2868 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2869 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2870 result = PyType_GenericNew(comprehension_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2871 if (!result) return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2872 value = ast2obj_expr(o->target); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2873 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2874 if (PyObject_SetAttrString(result, "target", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2875 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2876 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2877 value = ast2obj_expr(o->iter); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2878 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2879 if (PyObject_SetAttrString(result, "iter", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2880 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2881 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2882 value = ast2obj_list(o->ifs, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2883 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2884 if (PyObject_SetAttrString(result, "ifs", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2885 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2886 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2887 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2888 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2889 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2890 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2891 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2892 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2893 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2894 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2895 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
|
2896 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2897 excepthandler_ty o = (excepthandler_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2898 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2899 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2900 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2901 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2902 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2903 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2904 result = PyType_GenericNew(excepthandler_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2905 if (!result) return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2906 value = ast2obj_expr(o->type); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2907 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2908 if (PyObject_SetAttrString(result, "type", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2909 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2910 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2911 value = ast2obj_expr(o->name); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2912 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2913 if (PyObject_SetAttrString(result, "name", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2914 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2915 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2916 value = ast2obj_list(o->body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2917 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2918 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2919 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2920 Py_DECREF(value); |
|
37453
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
2921 value = ast2obj_int(o->lineno); |
|
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
2922 if (!value) goto failed; |
|
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
2923 if (PyObject_SetAttrString(result, "lineno", value) == -1) |
|
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
2924 goto failed; |
|
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
2925 Py_DECREF(value); |
|
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
2926 value = ast2obj_int(o->col_offset); |
|
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
2927 if (!value) goto failed; |
|
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
2928 if (PyObject_SetAttrString(result, "col_offset", value) == -1) |
|
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
2929 goto failed; |
|
16a64e394602
Add lineno, col_offset to excephandler to enable future fix for
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
37412
diff
changeset
|
2930 Py_DECREF(value); |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2931 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2932 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2933 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2934 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2935 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2936 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2937 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2938 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2939 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
|
2940 { |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2941 arguments_ty o = (arguments_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2942 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2943 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2944 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2945 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2946 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2947 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2948 result = PyType_GenericNew(arguments_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2949 if (!result) return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2950 value = ast2obj_list(o->args, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2951 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2952 if (PyObject_SetAttrString(result, "args", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2953 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2954 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2955 value = ast2obj_identifier(o->vararg); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2956 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2957 if (PyObject_SetAttrString(result, "vararg", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2958 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2959 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2960 value = ast2obj_identifier(o->kwarg); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2961 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2962 if (PyObject_SetAttrString(result, "kwarg", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2963 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2964 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2965 value = ast2obj_list(o->defaults, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2966 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2967 if (PyObject_SetAttrString(result, "defaults", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2968 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2969 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2970 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2971 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2972 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2973 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2974 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2975 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2976 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2977 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2978 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
|
2979 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2980 keyword_ty o = (keyword_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2981 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2982 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2983 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2984 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2985 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2986 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2987 result = PyType_GenericNew(keyword_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2988 if (!result) return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2989 value = ast2obj_identifier(o->arg); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2990 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2991 if (PyObject_SetAttrString(result, "arg", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2992 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2993 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2994 value = ast2obj_expr(o->value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2995 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2996 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2997 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2998 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2999 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3000 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3001 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3002 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3003 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3004 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3005 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3006 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3007 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
|
3008 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3009 alias_ty o = (alias_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3010 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3011 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3012 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3013 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3014 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3015 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3016 result = PyType_GenericNew(alias_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3017 if (!result) return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3018 value = ast2obj_identifier(o->name); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3019 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3020 if (PyObject_SetAttrString(result, "name", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3021 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3022 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3023 value = ast2obj_identifier(o->asname); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3024 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3025 if (PyObject_SetAttrString(result, "asname", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3026 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3027 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3028 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3029 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3030 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3031 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3032 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3033 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3034 |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3035 |
|
46162
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3036 int |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3037 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3038 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3039 PyObject* tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3040 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3041 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3042 if (obj == Py_None) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3043 *out = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3044 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3045 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3046 if (PyObject_IsInstance(obj, (PyObject*)Module_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3047 asdl_seq* body; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3048 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3049 if (PyObject_HasAttrString(obj, "body")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3050 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3051 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3052 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3053 tmp = PyObject_GetAttrString(obj, "body"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3054 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3055 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3056 PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3057 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3058 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3059 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3060 body = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3061 if (body == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3062 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3063 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3064 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3065 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3066 asdl_seq_SET(body, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3067 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3068 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3069 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3070 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3071 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Module"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3072 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3073 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3074 *out = Module(body, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3075 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3076 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3077 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3078 if (PyObject_IsInstance(obj, (PyObject*)Interactive_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3079 asdl_seq* body; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3080 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3081 if (PyObject_HasAttrString(obj, "body")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3082 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3083 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3084 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3085 tmp = PyObject_GetAttrString(obj, "body"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3086 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3087 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3088 PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3089 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3090 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3091 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3092 body = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3093 if (body == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3094 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3095 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3096 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3097 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3098 asdl_seq_SET(body, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3099 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3100 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3101 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3102 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3103 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Interactive"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3104 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3105 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3106 *out = Interactive(body, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3107 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3108 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3109 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3110 if (PyObject_IsInstance(obj, (PyObject*)Expression_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3111 expr_ty body; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3112 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3113 if (PyObject_HasAttrString(obj, "body")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3114 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3115 tmp = PyObject_GetAttrString(obj, "body"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3116 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3117 res = obj2ast_expr(tmp, &body, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3118 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3119 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3120 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3121 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3122 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3123 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3124 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3125 *out = Expression(body, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3126 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3127 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3128 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3129 if (PyObject_IsInstance(obj, (PyObject*)Suite_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3130 asdl_seq* body; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3131 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3132 if (PyObject_HasAttrString(obj, "body")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3133 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3134 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3135 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3136 tmp = PyObject_GetAttrString(obj, "body"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3137 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3138 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3139 PyErr_Format(PyExc_TypeError, "Suite field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3140 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3141 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3142 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3143 body = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3144 if (body == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3145 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3146 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3147 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3148 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3149 asdl_seq_SET(body, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3150 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3151 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3152 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3153 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3154 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Suite"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3155 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3156 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3157 *out = Suite(body, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3158 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3159 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3160 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3161 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3162 tmp = PyObject_Repr(obj); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3163 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3164 PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %.400s", PyString_AS_STRING(tmp)); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3165 failed: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3166 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3167 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3168 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3169 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3170 int |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3171 obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3172 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3173 PyObject* tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3174 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3175 int lineno; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3176 int col_offset; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3177 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3178 if (obj == Py_None) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3179 *out = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3180 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3181 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3182 if (PyObject_HasAttrString(obj, "lineno")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3183 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3184 tmp = PyObject_GetAttrString(obj, "lineno"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3185 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3186 res = obj2ast_int(tmp, &lineno, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3187 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3188 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3189 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3190 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3191 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3192 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3193 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3194 if (PyObject_HasAttrString(obj, "col_offset")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3195 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3196 tmp = PyObject_GetAttrString(obj, "col_offset"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3197 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3198 res = obj2ast_int(tmp, &col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3199 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3200 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3201 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3202 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3203 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3204 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3205 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3206 if (PyObject_IsInstance(obj, (PyObject*)FunctionDef_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3207 identifier name; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3208 arguments_ty args; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3209 asdl_seq* body; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3210 asdl_seq* decorator_list; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3211 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3212 if (PyObject_HasAttrString(obj, "name")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3213 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3214 tmp = PyObject_GetAttrString(obj, "name"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3215 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3216 res = obj2ast_identifier(tmp, &name, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3217 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3218 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3219 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3220 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3221 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3222 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3223 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3224 if (PyObject_HasAttrString(obj, "args")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3225 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3226 tmp = PyObject_GetAttrString(obj, "args"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3227 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3228 res = obj2ast_arguments(tmp, &args, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3229 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3230 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3231 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3232 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3233 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3234 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3235 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3236 if (PyObject_HasAttrString(obj, "body")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3237 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3238 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3239 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3240 tmp = PyObject_GetAttrString(obj, "body"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3241 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3242 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3243 PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3244 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3245 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3246 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3247 body = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3248 if (body == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3249 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3250 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3251 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3252 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3253 asdl_seq_SET(body, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3254 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3255 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3256 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3257 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3258 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from FunctionDef"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3259 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3260 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3261 if (PyObject_HasAttrString(obj, "decorator_list")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3262 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3263 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3264 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3265 tmp = PyObject_GetAttrString(obj, "decorator_list"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3266 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3267 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3268 PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3269 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3270 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3271 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3272 decorator_list = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3273 if (decorator_list == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3274 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3275 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3276 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3277 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3278 asdl_seq_SET(decorator_list, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3279 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3280 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3281 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3282 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3283 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from FunctionDef"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3284 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3285 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3286 *out = FunctionDef(name, args, body, decorator_list, lineno, |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3287 col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3288 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3289 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3290 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3291 if (PyObject_IsInstance(obj, (PyObject*)ClassDef_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3292 identifier name; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3293 asdl_seq* bases; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3294 asdl_seq* body; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3295 asdl_seq* decorator_list; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3296 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3297 if (PyObject_HasAttrString(obj, "name")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3298 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3299 tmp = PyObject_GetAttrString(obj, "name"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3300 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3301 res = obj2ast_identifier(tmp, &name, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3302 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3303 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3304 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3305 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3306 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3307 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3308 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3309 if (PyObject_HasAttrString(obj, "bases")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3310 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3311 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3312 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3313 tmp = PyObject_GetAttrString(obj, "bases"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3314 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3315 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3316 PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3317 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3318 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3319 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3320 bases = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3321 if (bases == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3322 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3323 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3324 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3325 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3326 asdl_seq_SET(bases, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3327 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3328 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3329 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3330 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3331 PyErr_SetString(PyExc_TypeError, "required field \"bases\" missing from ClassDef"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3332 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3333 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3334 if (PyObject_HasAttrString(obj, "body")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3335 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3336 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3337 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3338 tmp = PyObject_GetAttrString(obj, "body"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3339 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3340 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3341 PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3342 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3343 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3344 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3345 body = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3346 if (body == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3347 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3348 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3349 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3350 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3351 asdl_seq_SET(body, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3352 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3353 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3354 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3355 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3356 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ClassDef"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3357 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3358 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3359 if (PyObject_HasAttrString(obj, "decorator_list")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3360 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3361 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3362 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3363 tmp = PyObject_GetAttrString(obj, "decorator_list"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3364 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3365 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3366 PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3367 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3368 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3369 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3370 decorator_list = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3371 if (decorator_list == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3372 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3373 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3374 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3375 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3376 asdl_seq_SET(decorator_list, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3377 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3378 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3379 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3380 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3381 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from ClassDef"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3382 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3383 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3384 *out = ClassDef(name, bases, body, decorator_list, lineno, |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3385 col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3386 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3387 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3388 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3389 if (PyObject_IsInstance(obj, (PyObject*)Return_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3390 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3391 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3392 if (PyObject_HasAttrString(obj, "value")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3393 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3394 tmp = PyObject_GetAttrString(obj, "value"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3395 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3396 res = obj2ast_expr(tmp, &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3397 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3398 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3399 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3400 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3401 value = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3402 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3403 *out = Return(value, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3404 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3405 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3406 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3407 if (PyObject_IsInstance(obj, (PyObject*)Delete_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3408 asdl_seq* targets; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3409 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3410 if (PyObject_HasAttrString(obj, "targets")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3411 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3412 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3413 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3414 tmp = PyObject_GetAttrString(obj, "targets"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3415 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3416 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3417 PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3418 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3419 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3420 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3421 targets = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3422 if (targets == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3423 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3424 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3425 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3426 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3427 asdl_seq_SET(targets, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3428 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3429 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3430 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3431 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3432 PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Delete"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3433 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3434 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3435 *out = Delete(targets, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3436 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3437 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3438 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3439 if (PyObject_IsInstance(obj, (PyObject*)Assign_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3440 asdl_seq* targets; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3441 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3442 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3443 if (PyObject_HasAttrString(obj, "targets")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3444 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3445 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3446 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3447 tmp = PyObject_GetAttrString(obj, "targets"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3448 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3449 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3450 PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3451 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3452 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3453 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3454 targets = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3455 if (targets == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3456 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3457 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3458 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3459 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3460 asdl_seq_SET(targets, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3461 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3462 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3463 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3464 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3465 PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Assign"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3466 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3467 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3468 if (PyObject_HasAttrString(obj, "value")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3469 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3470 tmp = PyObject_GetAttrString(obj, "value"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3471 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3472 res = obj2ast_expr(tmp, &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3473 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3474 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3475 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3476 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3477 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3478 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3479 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3480 *out = Assign(targets, value, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3481 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3482 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3483 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3484 if (PyObject_IsInstance(obj, (PyObject*)AugAssign_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3485 expr_ty target; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3486 operator_ty op; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3487 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3488 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3489 if (PyObject_HasAttrString(obj, "target")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3490 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3491 tmp = PyObject_GetAttrString(obj, "target"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3492 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3493 res = obj2ast_expr(tmp, &target, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3494 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3495 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3496 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3497 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3498 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3499 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3500 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3501 if (PyObject_HasAttrString(obj, "op")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3502 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3503 tmp = PyObject_GetAttrString(obj, "op"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3504 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3505 res = obj2ast_operator(tmp, &op, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3506 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3507 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3508 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3509 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3510 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3511 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3512 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3513 if (PyObject_HasAttrString(obj, "value")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3514 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3515 tmp = PyObject_GetAttrString(obj, "value"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3516 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3517 res = obj2ast_expr(tmp, &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3518 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3519 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3520 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3521 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3522 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3523 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3524 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3525 *out = AugAssign(target, op, value, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3526 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3527 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3528 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3529 if (PyObject_IsInstance(obj, (PyObject*)Print_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3530 expr_ty dest; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3531 asdl_seq* values; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3532 bool nl; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3533 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3534 if (PyObject_HasAttrString(obj, "dest")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3535 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3536 tmp = PyObject_GetAttrString(obj, "dest"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3537 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3538 res = obj2ast_expr(tmp, &dest, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3539 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3540 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3541 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3542 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3543 dest = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3544 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3545 if (PyObject_HasAttrString(obj, "values")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3546 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3547 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3548 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3549 tmp = PyObject_GetAttrString(obj, "values"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3550 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3551 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3552 PyErr_Format(PyExc_TypeError, "Print field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3553 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3554 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3555 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3556 values = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3557 if (values == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3558 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3559 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3560 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3561 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3562 asdl_seq_SET(values, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3563 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3564 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3565 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3566 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3567 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Print"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3568 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3569 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3570 if (PyObject_HasAttrString(obj, "nl")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3571 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3572 tmp = PyObject_GetAttrString(obj, "nl"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3573 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3574 res = obj2ast_bool(tmp, &nl, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3575 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3576 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3577 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3578 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3579 PyErr_SetString(PyExc_TypeError, "required field \"nl\" missing from Print"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3580 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3581 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3582 *out = Print(dest, values, nl, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3583 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3584 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3585 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3586 if (PyObject_IsInstance(obj, (PyObject*)For_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3587 expr_ty target; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3588 expr_ty iter; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3589 asdl_seq* body; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3590 asdl_seq* orelse; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3591 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3592 if (PyObject_HasAttrString(obj, "target")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3593 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3594 tmp = PyObject_GetAttrString(obj, "target"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3595 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3596 res = obj2ast_expr(tmp, &target, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3597 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3598 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3599 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3600 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3601 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3602 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3603 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3604 if (PyObject_HasAttrString(obj, "iter")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3605 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3606 tmp = PyObject_GetAttrString(obj, "iter"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3607 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3608 res = obj2ast_expr(tmp, &iter, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3609 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3610 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3611 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3612 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3613 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3614 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3615 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3616 if (PyObject_HasAttrString(obj, "body")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3617 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3618 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3619 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3620 tmp = PyObject_GetAttrString(obj, "body"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3621 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3622 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3623 PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3624 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3625 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3626 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3627 body = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3628 if (body == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3629 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3630 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3631 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3632 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3633 asdl_seq_SET(body, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3634 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3635 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3636 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3637 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3638 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from For"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3639 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3640 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3641 if (PyObject_HasAttrString(obj, "orelse")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3642 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3643 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3644 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3645 tmp = PyObject_GetAttrString(obj, "orelse"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3646 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3647 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3648 PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3649 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3650 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3651 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3652 orelse = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3653 if (orelse == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3654 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3655 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3656 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3657 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3658 asdl_seq_SET(orelse, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3659 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3660 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3661 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3662 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3663 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from For"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3664 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3665 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3666 *out = For(target, iter, body, orelse, lineno, col_offset, |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3667 arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3668 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3669 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3670 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3671 if (PyObject_IsInstance(obj, (PyObject*)While_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3672 expr_ty test; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3673 asdl_seq* body; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3674 asdl_seq* orelse; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3675 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3676 if (PyObject_HasAttrString(obj, "test")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3677 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3678 tmp = PyObject_GetAttrString(obj, "test"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3679 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3680 res = obj2ast_expr(tmp, &test, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3681 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3682 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3683 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3684 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3685 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3686 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3687 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3688 if (PyObject_HasAttrString(obj, "body")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3689 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3690 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3691 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3692 tmp = PyObject_GetAttrString(obj, "body"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3693 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3694 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3695 PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3696 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3697 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3698 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3699 body = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3700 if (body == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3701 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3702 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3703 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3704 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3705 asdl_seq_SET(body, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3706 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3707 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3708 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3709 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3710 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from While"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3711 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3712 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3713 if (PyObject_HasAttrString(obj, "orelse")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3714 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3715 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3716 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3717 tmp = PyObject_GetAttrString(obj, "orelse"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3718 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3719 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3720 PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3721 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3722 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3723 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3724 orelse = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3725 if (orelse == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3726 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3727 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3728 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3729 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3730 asdl_seq_SET(orelse, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3731 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3732 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3733 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3734 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3735 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from While"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3736 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3737 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3738 *out = While(test, body, orelse, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3739 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3740 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3741 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3742 if (PyObject_IsInstance(obj, (PyObject*)If_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3743 expr_ty test; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3744 asdl_seq* body; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3745 asdl_seq* orelse; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3746 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3747 if (PyObject_HasAttrString(obj, "test")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3748 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3749 tmp = PyObject_GetAttrString(obj, "test"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3750 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3751 res = obj2ast_expr(tmp, &test, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3752 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3753 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3754 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3755 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3756 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3757 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3758 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3759 if (PyObject_HasAttrString(obj, "body")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3760 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3761 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3762 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3763 tmp = PyObject_GetAttrString(obj, "body"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3764 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3765 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3766 PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3767 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3768 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3769 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3770 body = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3771 if (body == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3772 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3773 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3774 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3775 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3776 asdl_seq_SET(body, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3777 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3778 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3779 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3780 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3781 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from If"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3782 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3783 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3784 if (PyObject_HasAttrString(obj, "orelse")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3785 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3786 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3787 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3788 tmp = PyObject_GetAttrString(obj, "orelse"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3789 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3790 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3791 PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3792 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3793 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3794 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3795 orelse = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3796 if (orelse == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3797 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3798 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3799 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3800 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3801 asdl_seq_SET(orelse, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3802 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3803 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3804 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3805 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3806 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from If"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3807 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3808 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3809 *out = If(test, body, orelse, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3810 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3811 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3812 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3813 if (PyObject_IsInstance(obj, (PyObject*)With_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3814 expr_ty context_expr; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3815 expr_ty optional_vars; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3816 asdl_seq* body; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3817 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3818 if (PyObject_HasAttrString(obj, "context_expr")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3819 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3820 tmp = PyObject_GetAttrString(obj, "context_expr"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3821 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3822 res = obj2ast_expr(tmp, &context_expr, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3823 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3824 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3825 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3826 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3827 PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from With"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3828 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3829 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3830 if (PyObject_HasAttrString(obj, "optional_vars")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3831 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3832 tmp = PyObject_GetAttrString(obj, "optional_vars"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3833 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3834 res = obj2ast_expr(tmp, &optional_vars, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3835 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3836 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3837 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3838 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3839 optional_vars = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3840 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3841 if (PyObject_HasAttrString(obj, "body")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3842 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3843 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3844 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3845 tmp = PyObject_GetAttrString(obj, "body"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3846 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3847 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3848 PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3849 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3850 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3851 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3852 body = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3853 if (body == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3854 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3855 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3856 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3857 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3858 asdl_seq_SET(body, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3859 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3860 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3861 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3862 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3863 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from With"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3864 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3865 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3866 *out = With(context_expr, optional_vars, body, lineno, |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3867 col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3868 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3869 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3870 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3871 if (PyObject_IsInstance(obj, (PyObject*)Raise_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3872 expr_ty type; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3873 expr_ty inst; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3874 expr_ty tback; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3875 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3876 if (PyObject_HasAttrString(obj, "type")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3877 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3878 tmp = PyObject_GetAttrString(obj, "type"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3879 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3880 res = obj2ast_expr(tmp, &type, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3881 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3882 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3883 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3884 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3885 type = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3886 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3887 if (PyObject_HasAttrString(obj, "inst")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3888 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3889 tmp = PyObject_GetAttrString(obj, "inst"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3890 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3891 res = obj2ast_expr(tmp, &inst, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3892 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3893 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3894 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3895 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3896 inst = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3897 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3898 if (PyObject_HasAttrString(obj, "tback")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3899 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3900 tmp = PyObject_GetAttrString(obj, "tback"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3901 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3902 res = obj2ast_expr(tmp, &tback, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3903 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3904 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3905 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3906 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3907 tback = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3908 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3909 *out = Raise(type, inst, tback, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3910 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3911 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3912 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3913 if (PyObject_IsInstance(obj, (PyObject*)TryExcept_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3914 asdl_seq* body; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3915 asdl_seq* handlers; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3916 asdl_seq* orelse; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3917 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3918 if (PyObject_HasAttrString(obj, "body")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3919 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3920 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3921 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3922 tmp = PyObject_GetAttrString(obj, "body"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3923 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3924 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3925 PyErr_Format(PyExc_TypeError, "TryExcept field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3926 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3927 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3928 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3929 body = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3930 if (body == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3931 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3932 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3933 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3934 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3935 asdl_seq_SET(body, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3936 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3937 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3938 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3939 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3940 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from TryExcept"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3941 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3942 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3943 if (PyObject_HasAttrString(obj, "handlers")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3944 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3945 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3946 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3947 tmp = PyObject_GetAttrString(obj, "handlers"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3948 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3949 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3950 PyErr_Format(PyExc_TypeError, "TryExcept field \"handlers\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3951 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3952 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3953 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3954 handlers = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3955 if (handlers == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3956 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3957 excepthandler_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3958 res = obj2ast_excepthandler(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3959 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3960 asdl_seq_SET(handlers, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3961 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3962 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3963 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3964 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3965 PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from TryExcept"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3966 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3967 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3968 if (PyObject_HasAttrString(obj, "orelse")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3969 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3970 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3971 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3972 tmp = PyObject_GetAttrString(obj, "orelse"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3973 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3974 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3975 PyErr_Format(PyExc_TypeError, "TryExcept field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3976 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3977 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3978 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3979 orelse = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3980 if (orelse == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3981 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3982 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3983 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3984 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3985 asdl_seq_SET(orelse, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3986 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3987 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3988 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3989 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3990 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from TryExcept"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3991 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3992 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3993 *out = TryExcept(body, handlers, orelse, lineno, col_offset, |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3994 arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3995 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3996 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3997 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3998 if (PyObject_IsInstance(obj, (PyObject*)TryFinally_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
3999 asdl_seq* body; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4000 asdl_seq* finalbody; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4001 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4002 if (PyObject_HasAttrString(obj, "body")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4003 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4004 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4005 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4006 tmp = PyObject_GetAttrString(obj, "body"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4007 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4008 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4009 PyErr_Format(PyExc_TypeError, "TryFinally field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4010 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4011 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4012 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4013 body = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4014 if (body == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4015 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4016 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4017 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4018 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4019 asdl_seq_SET(body, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4020 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4021 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4022 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4023 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4024 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from TryFinally"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4025 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4026 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4027 if (PyObject_HasAttrString(obj, "finalbody")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4028 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4029 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4030 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4031 tmp = PyObject_GetAttrString(obj, "finalbody"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4032 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4033 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4034 PyErr_Format(PyExc_TypeError, "TryFinally field \"finalbody\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4035 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4036 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4037 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4038 finalbody = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4039 if (finalbody == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4040 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4041 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4042 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4043 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4044 asdl_seq_SET(finalbody, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4045 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4046 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4047 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4048 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4049 PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from TryFinally"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4050 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4051 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4052 *out = TryFinally(body, finalbody, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4053 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4054 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4055 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4056 if (PyObject_IsInstance(obj, (PyObject*)Assert_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4057 expr_ty test; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4058 expr_ty msg; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4059 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4060 if (PyObject_HasAttrString(obj, "test")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4061 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4062 tmp = PyObject_GetAttrString(obj, "test"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4063 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4064 res = obj2ast_expr(tmp, &test, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4065 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4066 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4067 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4068 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4069 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4070 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4071 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4072 if (PyObject_HasAttrString(obj, "msg")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4073 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4074 tmp = PyObject_GetAttrString(obj, "msg"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4075 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4076 res = obj2ast_expr(tmp, &msg, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4077 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4078 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4079 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4080 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4081 msg = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4082 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4083 *out = Assert(test, msg, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4084 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4085 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4086 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4087 if (PyObject_IsInstance(obj, (PyObject*)Import_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4088 asdl_seq* names; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4089 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4090 if (PyObject_HasAttrString(obj, "names")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4091 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4092 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4093 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4094 tmp = PyObject_GetAttrString(obj, "names"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4095 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4096 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4097 PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4098 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4099 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4100 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4101 names = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4102 if (names == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4103 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4104 alias_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4105 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4106 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4107 asdl_seq_SET(names, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4108 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4109 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4110 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4111 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4112 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Import"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4113 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4114 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4115 *out = Import(names, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4116 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4117 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4118 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4119 if (PyObject_IsInstance(obj, (PyObject*)ImportFrom_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4120 identifier module; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4121 asdl_seq* names; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4122 int level; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4123 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4124 if (PyObject_HasAttrString(obj, "module")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4125 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4126 tmp = PyObject_GetAttrString(obj, "module"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4127 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4128 res = obj2ast_identifier(tmp, &module, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4129 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4130 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4131 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4132 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4133 PyErr_SetString(PyExc_TypeError, "required field \"module\" missing from ImportFrom"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4134 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4135 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4136 if (PyObject_HasAttrString(obj, "names")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4137 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4138 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4139 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4140 tmp = PyObject_GetAttrString(obj, "names"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4141 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4142 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4143 PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4144 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4145 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4146 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4147 names = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4148 if (names == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4149 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4150 alias_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4151 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4152 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4153 asdl_seq_SET(names, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4154 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4155 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4156 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4157 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4158 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from ImportFrom"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4159 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4160 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4161 if (PyObject_HasAttrString(obj, "level")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4162 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4163 tmp = PyObject_GetAttrString(obj, "level"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4164 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4165 res = obj2ast_int(tmp, &level, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4166 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4167 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4168 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4169 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4170 level = 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4171 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4172 *out = ImportFrom(module, names, level, lineno, col_offset, |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4173 arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4174 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4175 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4176 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4177 if (PyObject_IsInstance(obj, (PyObject*)Exec_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4178 expr_ty body; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4179 expr_ty globals; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4180 expr_ty locals; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4181 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4182 if (PyObject_HasAttrString(obj, "body")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4183 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4184 tmp = PyObject_GetAttrString(obj, "body"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4185 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4186 res = obj2ast_expr(tmp, &body, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4187 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4188 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4189 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4190 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4191 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Exec"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4192 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4193 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4194 if (PyObject_HasAttrString(obj, "globals")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4195 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4196 tmp = PyObject_GetAttrString(obj, "globals"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4197 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4198 res = obj2ast_expr(tmp, &globals, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4199 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4200 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4201 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4202 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4203 globals = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4204 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4205 if (PyObject_HasAttrString(obj, "locals")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4206 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4207 tmp = PyObject_GetAttrString(obj, "locals"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4208 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4209 res = obj2ast_expr(tmp, &locals, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4210 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4211 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4212 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4213 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4214 locals = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4215 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4216 *out = Exec(body, globals, locals, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4217 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4218 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4219 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4220 if (PyObject_IsInstance(obj, (PyObject*)Global_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4221 asdl_seq* names; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4222 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4223 if (PyObject_HasAttrString(obj, "names")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4224 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4225 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4226 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4227 tmp = PyObject_GetAttrString(obj, "names"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4228 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4229 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4230 PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4231 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4232 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4233 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4234 names = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4235 if (names == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4236 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4237 identifier value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4238 res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4239 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4240 asdl_seq_SET(names, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4241 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4242 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4243 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4244 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4245 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Global"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4246 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4247 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4248 *out = Global(names, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4249 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4250 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4251 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4252 if (PyObject_IsInstance(obj, (PyObject*)Expr_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4253 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4254 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4255 if (PyObject_HasAttrString(obj, "value")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4256 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4257 tmp = PyObject_GetAttrString(obj, "value"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4258 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4259 res = obj2ast_expr(tmp, &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4260 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4261 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4262 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4263 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4264 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4265 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4266 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4267 *out = Expr(value, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4268 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4269 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4270 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4271 if (PyObject_IsInstance(obj, (PyObject*)Pass_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4272 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4273 *out = Pass(lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4274 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4275 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4276 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4277 if (PyObject_IsInstance(obj, (PyObject*)Break_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4278 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4279 *out = Break(lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4280 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4281 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4282 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4283 if (PyObject_IsInstance(obj, (PyObject*)Continue_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4284 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4285 *out = Continue(lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4286 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4287 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4288 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4289 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4290 tmp = PyObject_Repr(obj); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4291 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4292 PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %.400s", PyString_AS_STRING(tmp)); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4293 failed: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4294 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4295 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4296 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4297 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4298 int |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4299 obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4300 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4301 PyObject* tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4302 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4303 int lineno; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4304 int col_offset; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4305 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4306 if (obj == Py_None) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4307 *out = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4308 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4309 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4310 if (PyObject_HasAttrString(obj, "lineno")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4311 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4312 tmp = PyObject_GetAttrString(obj, "lineno"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4313 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4314 res = obj2ast_int(tmp, &lineno, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4315 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4316 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4317 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4318 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4319 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4320 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4321 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4322 if (PyObject_HasAttrString(obj, "col_offset")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4323 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4324 tmp = PyObject_GetAttrString(obj, "col_offset"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4325 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4326 res = obj2ast_int(tmp, &col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4327 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4328 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4329 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4330 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4331 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4332 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4333 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4334 if (PyObject_IsInstance(obj, (PyObject*)BoolOp_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4335 boolop_ty op; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4336 asdl_seq* values; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4337 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4338 if (PyObject_HasAttrString(obj, "op")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4339 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4340 tmp = PyObject_GetAttrString(obj, "op"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4341 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4342 res = obj2ast_boolop(tmp, &op, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4343 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4344 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4345 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4346 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4347 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4348 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4349 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4350 if (PyObject_HasAttrString(obj, "values")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4351 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4352 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4353 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4354 tmp = PyObject_GetAttrString(obj, "values"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4355 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4356 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4357 PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4358 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4359 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4360 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4361 values = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4362 if (values == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4363 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4364 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4365 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4366 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4367 asdl_seq_SET(values, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4368 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4369 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4370 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4371 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4372 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from BoolOp"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4373 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4374 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4375 *out = BoolOp(op, values, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4376 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4377 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4378 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4379 if (PyObject_IsInstance(obj, (PyObject*)BinOp_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4380 expr_ty left; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4381 operator_ty op; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4382 expr_ty right; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4383 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4384 if (PyObject_HasAttrString(obj, "left")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4385 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4386 tmp = PyObject_GetAttrString(obj, "left"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4387 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4388 res = obj2ast_expr(tmp, &left, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4389 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4390 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4391 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4392 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4393 PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4394 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4395 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4396 if (PyObject_HasAttrString(obj, "op")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4397 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4398 tmp = PyObject_GetAttrString(obj, "op"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4399 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4400 res = obj2ast_operator(tmp, &op, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4401 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4402 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4403 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4404 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4405 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4406 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4407 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4408 if (PyObject_HasAttrString(obj, "right")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4409 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4410 tmp = PyObject_GetAttrString(obj, "right"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4411 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4412 res = obj2ast_expr(tmp, &right, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4413 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4414 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4415 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4416 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4417 PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4418 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4419 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4420 *out = BinOp(left, op, right, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4421 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4422 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4423 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4424 if (PyObject_IsInstance(obj, (PyObject*)UnaryOp_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4425 unaryop_ty op; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4426 expr_ty operand; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4427 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4428 if (PyObject_HasAttrString(obj, "op")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4429 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4430 tmp = PyObject_GetAttrString(obj, "op"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4431 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4432 res = obj2ast_unaryop(tmp, &op, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4433 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4434 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4435 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4436 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4437 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4438 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4439 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4440 if (PyObject_HasAttrString(obj, "operand")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4441 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4442 tmp = PyObject_GetAttrString(obj, "operand"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4443 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4444 res = obj2ast_expr(tmp, &operand, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4445 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4446 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4447 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4448 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4449 PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4450 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4451 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4452 *out = UnaryOp(op, operand, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4453 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4454 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4455 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4456 if (PyObject_IsInstance(obj, (PyObject*)Lambda_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4457 arguments_ty args; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4458 expr_ty body; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4459 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4460 if (PyObject_HasAttrString(obj, "args")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4461 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4462 tmp = PyObject_GetAttrString(obj, "args"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4463 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4464 res = obj2ast_arguments(tmp, &args, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4465 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4466 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4467 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4468 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4469 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4470 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4471 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4472 if (PyObject_HasAttrString(obj, "body")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4473 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4474 tmp = PyObject_GetAttrString(obj, "body"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4475 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4476 res = obj2ast_expr(tmp, &body, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4477 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4478 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4479 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4480 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4481 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4482 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4483 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4484 *out = Lambda(args, body, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4485 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4486 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4487 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4488 if (PyObject_IsInstance(obj, (PyObject*)IfExp_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4489 expr_ty test; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4490 expr_ty body; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4491 expr_ty orelse; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4492 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4493 if (PyObject_HasAttrString(obj, "test")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4494 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4495 tmp = PyObject_GetAttrString(obj, "test"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4496 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4497 res = obj2ast_expr(tmp, &test, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4498 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4499 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4500 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4501 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4502 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4503 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4504 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4505 if (PyObject_HasAttrString(obj, "body")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4506 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4507 tmp = PyObject_GetAttrString(obj, "body"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4508 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4509 res = obj2ast_expr(tmp, &body, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4510 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4511 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4512 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4513 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4514 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4515 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4516 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4517 if (PyObject_HasAttrString(obj, "orelse")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4518 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4519 tmp = PyObject_GetAttrString(obj, "orelse"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4520 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4521 res = obj2ast_expr(tmp, &orelse, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4522 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4523 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4524 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4525 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4526 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4527 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4528 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4529 *out = IfExp(test, body, orelse, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4530 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4531 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4532 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4533 if (PyObject_IsInstance(obj, (PyObject*)Dict_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4534 asdl_seq* keys; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4535 asdl_seq* values; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4536 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4537 if (PyObject_HasAttrString(obj, "keys")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4538 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4539 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4540 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4541 tmp = PyObject_GetAttrString(obj, "keys"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4542 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4543 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4544 PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4545 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4546 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4547 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4548 keys = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4549 if (keys == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4550 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4551 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4552 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4553 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4554 asdl_seq_SET(keys, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4555 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4556 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4557 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4558 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4559 PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from Dict"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4560 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4561 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4562 if (PyObject_HasAttrString(obj, "values")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4563 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4564 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4565 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4566 tmp = PyObject_GetAttrString(obj, "values"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4567 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4568 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4569 PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4570 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4571 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4572 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4573 values = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4574 if (values == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4575 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4576 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4577 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4578 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4579 asdl_seq_SET(values, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4580 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4581 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4582 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4583 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4584 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Dict"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4585 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4586 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4587 *out = Dict(keys, values, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4588 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4589 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4590 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4591 if (PyObject_IsInstance(obj, (PyObject*)ListComp_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4592 expr_ty elt; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4593 asdl_seq* generators; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4594 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4595 if (PyObject_HasAttrString(obj, "elt")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4596 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4597 tmp = PyObject_GetAttrString(obj, "elt"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4598 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4599 res = obj2ast_expr(tmp, &elt, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4600 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4601 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4602 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4603 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4604 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4605 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4606 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4607 if (PyObject_HasAttrString(obj, "generators")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4608 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4609 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4610 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4611 tmp = PyObject_GetAttrString(obj, "generators"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4612 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4613 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4614 PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4615 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4616 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4617 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4618 generators = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4619 if (generators == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4620 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4621 comprehension_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4622 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4623 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4624 asdl_seq_SET(generators, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4625 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4626 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4627 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4628 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4629 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from ListComp"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4630 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4631 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4632 *out = ListComp(elt, generators, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4633 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4634 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4635 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4636 if (PyObject_IsInstance(obj, (PyObject*)GeneratorExp_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4637 expr_ty elt; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4638 asdl_seq* generators; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4639 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4640 if (PyObject_HasAttrString(obj, "elt")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4641 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4642 tmp = PyObject_GetAttrString(obj, "elt"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4643 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4644 res = obj2ast_expr(tmp, &elt, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4645 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4646 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4647 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4648 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4649 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4650 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4651 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4652 if (PyObject_HasAttrString(obj, "generators")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4653 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4654 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4655 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4656 tmp = PyObject_GetAttrString(obj, "generators"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4657 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4658 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4659 PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4660 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4661 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4662 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4663 generators = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4664 if (generators == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4665 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4666 comprehension_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4667 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4668 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4669 asdl_seq_SET(generators, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4670 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4671 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4672 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4673 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4674 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from GeneratorExp"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4675 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4676 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4677 *out = GeneratorExp(elt, generators, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4678 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4679 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4680 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4681 if (PyObject_IsInstance(obj, (PyObject*)Yield_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4682 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4683 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4684 if (PyObject_HasAttrString(obj, "value")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4685 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4686 tmp = PyObject_GetAttrString(obj, "value"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4687 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4688 res = obj2ast_expr(tmp, &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4689 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4690 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4691 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4692 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4693 value = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4694 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4695 *out = Yield(value, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4696 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4697 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4698 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4699 if (PyObject_IsInstance(obj, (PyObject*)Compare_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4700 expr_ty left; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4701 asdl_int_seq* ops; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4702 asdl_seq* comparators; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4703 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4704 if (PyObject_HasAttrString(obj, "left")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4705 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4706 tmp = PyObject_GetAttrString(obj, "left"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4707 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4708 res = obj2ast_expr(tmp, &left, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4709 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4710 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4711 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4712 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4713 PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4714 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4715 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4716 if (PyObject_HasAttrString(obj, "ops")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4717 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4718 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4719 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4720 tmp = PyObject_GetAttrString(obj, "ops"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4721 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4722 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4723 PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4724 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4725 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4726 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4727 ops = asdl_int_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4728 if (ops == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4729 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4730 cmpop_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4731 res = obj2ast_cmpop(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4732 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4733 asdl_seq_SET(ops, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4734 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4735 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4736 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4737 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4738 PyErr_SetString(PyExc_TypeError, "required field \"ops\" missing from Compare"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4739 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4740 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4741 if (PyObject_HasAttrString(obj, "comparators")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4742 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4743 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4744 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4745 tmp = PyObject_GetAttrString(obj, "comparators"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4746 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4747 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4748 PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4749 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4750 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4751 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4752 comparators = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4753 if (comparators == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4754 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4755 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4756 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4757 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4758 asdl_seq_SET(comparators, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4759 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4760 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4761 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4762 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4763 PyErr_SetString(PyExc_TypeError, "required field \"comparators\" missing from Compare"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4764 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4765 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4766 *out = Compare(left, ops, comparators, lineno, col_offset, |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4767 arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4768 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4769 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4770 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4771 if (PyObject_IsInstance(obj, (PyObject*)Call_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4772 expr_ty func; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4773 asdl_seq* args; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4774 asdl_seq* keywords; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4775 expr_ty starargs; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4776 expr_ty kwargs; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4777 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4778 if (PyObject_HasAttrString(obj, "func")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4779 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4780 tmp = PyObject_GetAttrString(obj, "func"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4781 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4782 res = obj2ast_expr(tmp, &func, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4783 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4784 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4785 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4786 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4787 PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4788 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4789 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4790 if (PyObject_HasAttrString(obj, "args")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4791 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4792 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4793 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4794 tmp = PyObject_GetAttrString(obj, "args"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4795 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4796 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4797 PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4798 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4799 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4800 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4801 args = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4802 if (args == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4803 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4804 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4805 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4806 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4807 asdl_seq_SET(args, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4808 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4809 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4810 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4811 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4812 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Call"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4813 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4814 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4815 if (PyObject_HasAttrString(obj, "keywords")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4816 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4817 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4818 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4819 tmp = PyObject_GetAttrString(obj, "keywords"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4820 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4821 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4822 PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4823 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4824 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4825 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4826 keywords = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4827 if (keywords == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4828 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4829 keyword_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4830 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4831 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4832 asdl_seq_SET(keywords, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4833 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4834 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4835 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4836 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4837 PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from Call"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4838 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4839 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4840 if (PyObject_HasAttrString(obj, "starargs")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4841 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4842 tmp = PyObject_GetAttrString(obj, "starargs"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4843 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4844 res = obj2ast_expr(tmp, &starargs, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4845 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4846 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4847 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4848 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4849 starargs = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4850 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4851 if (PyObject_HasAttrString(obj, "kwargs")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4852 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4853 tmp = PyObject_GetAttrString(obj, "kwargs"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4854 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4855 res = obj2ast_expr(tmp, &kwargs, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4856 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4857 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4858 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4859 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4860 kwargs = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4861 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4862 *out = Call(func, args, keywords, starargs, kwargs, lineno, |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4863 col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4864 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4865 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4866 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4867 if (PyObject_IsInstance(obj, (PyObject*)Repr_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4868 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4869 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4870 if (PyObject_HasAttrString(obj, "value")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4871 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4872 tmp = PyObject_GetAttrString(obj, "value"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4873 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4874 res = obj2ast_expr(tmp, &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4875 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4876 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4877 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4878 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4879 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Repr"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4880 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4881 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4882 *out = Repr(value, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4883 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4884 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4885 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4886 if (PyObject_IsInstance(obj, (PyObject*)Num_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4887 object n; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4888 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4889 if (PyObject_HasAttrString(obj, "n")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4890 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4891 tmp = PyObject_GetAttrString(obj, "n"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4892 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4893 res = obj2ast_object(tmp, &n, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4894 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4895 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4896 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4897 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4898 PyErr_SetString(PyExc_TypeError, "required field \"n\" missing from Num"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4899 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4900 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4901 *out = Num(n, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4902 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4903 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4904 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4905 if (PyObject_IsInstance(obj, (PyObject*)Str_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4906 string s; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4907 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4908 if (PyObject_HasAttrString(obj, "s")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4909 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4910 tmp = PyObject_GetAttrString(obj, "s"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4911 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4912 res = obj2ast_string(tmp, &s, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4913 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4914 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4915 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4916 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4917 PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Str"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4918 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4919 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4920 *out = Str(s, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4921 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4922 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4923 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4924 if (PyObject_IsInstance(obj, (PyObject*)Attribute_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4925 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4926 identifier attr; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4927 expr_context_ty ctx; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4928 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4929 if (PyObject_HasAttrString(obj, "value")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4930 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4931 tmp = PyObject_GetAttrString(obj, "value"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4932 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4933 res = obj2ast_expr(tmp, &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4934 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4935 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4936 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4937 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4938 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4939 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4940 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4941 if (PyObject_HasAttrString(obj, "attr")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4942 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4943 tmp = PyObject_GetAttrString(obj, "attr"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4944 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4945 res = obj2ast_identifier(tmp, &attr, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4946 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4947 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4948 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4949 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4950 PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4951 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4952 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4953 if (PyObject_HasAttrString(obj, "ctx")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4954 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4955 tmp = PyObject_GetAttrString(obj, "ctx"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4956 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4957 res = obj2ast_expr_context(tmp, &ctx, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4958 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4959 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4960 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4961 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4962 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4963 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4964 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4965 *out = Attribute(value, attr, ctx, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4966 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4967 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4968 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4969 if (PyObject_IsInstance(obj, (PyObject*)Subscript_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4970 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4971 slice_ty slice; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4972 expr_context_ty ctx; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4973 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4974 if (PyObject_HasAttrString(obj, "value")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4975 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4976 tmp = PyObject_GetAttrString(obj, "value"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4977 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4978 res = obj2ast_expr(tmp, &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4979 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4980 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4981 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4982 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4983 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4984 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4985 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4986 if (PyObject_HasAttrString(obj, "slice")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4987 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4988 tmp = PyObject_GetAttrString(obj, "slice"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4989 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4990 res = obj2ast_slice(tmp, &slice, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4991 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4992 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4993 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4994 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4995 PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4996 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4997 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4998 if (PyObject_HasAttrString(obj, "ctx")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
4999 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5000 tmp = PyObject_GetAttrString(obj, "ctx"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5001 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5002 res = obj2ast_expr_context(tmp, &ctx, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5003 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5004 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5005 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5006 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5007 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5008 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5009 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5010 *out = Subscript(value, slice, ctx, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5011 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5012 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5013 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5014 if (PyObject_IsInstance(obj, (PyObject*)Name_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5015 identifier id; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5016 expr_context_ty ctx; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5017 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5018 if (PyObject_HasAttrString(obj, "id")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5019 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5020 tmp = PyObject_GetAttrString(obj, "id"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5021 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5022 res = obj2ast_identifier(tmp, &id, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5023 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5024 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5025 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5026 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5027 PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5028 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5029 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5030 if (PyObject_HasAttrString(obj, "ctx")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5031 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5032 tmp = PyObject_GetAttrString(obj, "ctx"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5033 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5034 res = obj2ast_expr_context(tmp, &ctx, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5035 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5036 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5037 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5038 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5039 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5040 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5041 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5042 *out = Name(id, ctx, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5043 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5044 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5045 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5046 if (PyObject_IsInstance(obj, (PyObject*)List_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5047 asdl_seq* elts; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5048 expr_context_ty ctx; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5049 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5050 if (PyObject_HasAttrString(obj, "elts")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5051 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5052 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5053 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5054 tmp = PyObject_GetAttrString(obj, "elts"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5055 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5056 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5057 PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5058 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5059 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5060 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5061 elts = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5062 if (elts == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5063 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5064 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5065 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5066 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5067 asdl_seq_SET(elts, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5068 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5069 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5070 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5071 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5072 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from List"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5073 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5074 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5075 if (PyObject_HasAttrString(obj, "ctx")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5076 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5077 tmp = PyObject_GetAttrString(obj, "ctx"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5078 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5079 res = obj2ast_expr_context(tmp, &ctx, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5080 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5081 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5082 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5083 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5084 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5085 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5086 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5087 *out = List(elts, ctx, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5088 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5089 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5090 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5091 if (PyObject_IsInstance(obj, (PyObject*)Tuple_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5092 asdl_seq* elts; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5093 expr_context_ty ctx; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5094 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5095 if (PyObject_HasAttrString(obj, "elts")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5096 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5097 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5098 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5099 tmp = PyObject_GetAttrString(obj, "elts"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5100 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5101 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5102 PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5103 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5104 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5105 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5106 elts = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5107 if (elts == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5108 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5109 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5110 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5111 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5112 asdl_seq_SET(elts, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5113 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5114 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5115 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5116 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5117 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Tuple"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5118 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5119 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5120 if (PyObject_HasAttrString(obj, "ctx")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5121 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5122 tmp = PyObject_GetAttrString(obj, "ctx"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5123 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5124 res = obj2ast_expr_context(tmp, &ctx, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5125 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5126 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5127 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5128 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5129 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5130 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5131 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5132 *out = Tuple(elts, ctx, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5133 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5134 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5135 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5136 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5137 tmp = PyObject_Repr(obj); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5138 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5139 PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %.400s", PyString_AS_STRING(tmp)); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5140 failed: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5141 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5142 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5143 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5144 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5145 int |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5146 obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5147 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5148 PyObject* tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5149 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5150 if (PyObject_IsInstance(obj, (PyObject*)Load_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5151 *out = Load; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5152 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5153 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5154 if (PyObject_IsInstance(obj, (PyObject*)Store_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5155 *out = Store; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5156 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5157 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5158 if (PyObject_IsInstance(obj, (PyObject*)Del_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5159 *out = Del; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5160 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5161 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5162 if (PyObject_IsInstance(obj, (PyObject*)AugLoad_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5163 *out = AugLoad; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5164 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5165 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5166 if (PyObject_IsInstance(obj, (PyObject*)AugStore_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5167 *out = AugStore; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5168 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5169 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5170 if (PyObject_IsInstance(obj, (PyObject*)Param_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5171 *out = Param; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5172 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5173 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5174 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5175 tmp = PyObject_Repr(obj); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5176 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5177 PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %.400s", PyString_AS_STRING(tmp)); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5178 failed: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5179 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5180 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5181 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5182 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5183 int |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5184 obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5185 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5186 PyObject* tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5187 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5188 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5189 if (obj == Py_None) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5190 *out = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5191 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5192 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5193 if (PyObject_IsInstance(obj, (PyObject*)Ellipsis_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5194 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5195 *out = Ellipsis(arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5196 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5197 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5198 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5199 if (PyObject_IsInstance(obj, (PyObject*)Slice_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5200 expr_ty lower; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5201 expr_ty upper; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5202 expr_ty step; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5203 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5204 if (PyObject_HasAttrString(obj, "lower")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5205 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5206 tmp = PyObject_GetAttrString(obj, "lower"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5207 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5208 res = obj2ast_expr(tmp, &lower, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5209 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5210 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5211 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5212 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5213 lower = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5214 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5215 if (PyObject_HasAttrString(obj, "upper")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5216 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5217 tmp = PyObject_GetAttrString(obj, "upper"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5218 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5219 res = obj2ast_expr(tmp, &upper, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5220 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5221 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5222 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5223 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5224 upper = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5225 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5226 if (PyObject_HasAttrString(obj, "step")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5227 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5228 tmp = PyObject_GetAttrString(obj, "step"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5229 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5230 res = obj2ast_expr(tmp, &step, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5231 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5232 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5233 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5234 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5235 step = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5236 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5237 *out = Slice(lower, upper, step, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5238 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5239 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5240 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5241 if (PyObject_IsInstance(obj, (PyObject*)ExtSlice_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5242 asdl_seq* dims; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5243 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5244 if (PyObject_HasAttrString(obj, "dims")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5245 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5246 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5247 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5248 tmp = PyObject_GetAttrString(obj, "dims"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5249 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5250 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5251 PyErr_Format(PyExc_TypeError, "ExtSlice field \"dims\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5252 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5253 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5254 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5255 dims = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5256 if (dims == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5257 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5258 slice_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5259 res = obj2ast_slice(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5260 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5261 asdl_seq_SET(dims, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5262 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5263 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5264 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5265 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5266 PyErr_SetString(PyExc_TypeError, "required field \"dims\" missing from ExtSlice"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5267 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5268 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5269 *out = ExtSlice(dims, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5270 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5271 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5272 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5273 if (PyObject_IsInstance(obj, (PyObject*)Index_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5274 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5275 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5276 if (PyObject_HasAttrString(obj, "value")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5277 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5278 tmp = PyObject_GetAttrString(obj, "value"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5279 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5280 res = obj2ast_expr(tmp, &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5281 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5282 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5283 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5284 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5285 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Index"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5286 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5287 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5288 *out = Index(value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5289 if (*out == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5290 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5291 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5292 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5293 tmp = PyObject_Repr(obj); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5294 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5295 PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %.400s", PyString_AS_STRING(tmp)); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5296 failed: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5297 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5298 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5299 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5300 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5301 int |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5302 obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5303 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5304 PyObject* tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5305 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5306 if (PyObject_IsInstance(obj, (PyObject*)And_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5307 *out = And; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5308 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5309 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5310 if (PyObject_IsInstance(obj, (PyObject*)Or_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5311 *out = Or; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5312 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5313 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5314 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5315 tmp = PyObject_Repr(obj); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5316 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5317 PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %.400s", PyString_AS_STRING(tmp)); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5318 failed: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5319 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5320 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5321 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5322 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5323 int |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5324 obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5325 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5326 PyObject* tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5327 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5328 if (PyObject_IsInstance(obj, (PyObject*)Add_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5329 *out = Add; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5330 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5331 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5332 if (PyObject_IsInstance(obj, (PyObject*)Sub_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5333 *out = Sub; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5334 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5335 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5336 if (PyObject_IsInstance(obj, (PyObject*)Mult_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5337 *out = Mult; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5338 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5339 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5340 if (PyObject_IsInstance(obj, (PyObject*)Div_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5341 *out = Div; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5342 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5343 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5344 if (PyObject_IsInstance(obj, (PyObject*)Mod_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5345 *out = Mod; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5346 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5347 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5348 if (PyObject_IsInstance(obj, (PyObject*)Pow_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5349 *out = Pow; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5350 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5351 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5352 if (PyObject_IsInstance(obj, (PyObject*)LShift_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5353 *out = LShift; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5354 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5355 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5356 if (PyObject_IsInstance(obj, (PyObject*)RShift_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5357 *out = RShift; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5358 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5359 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5360 if (PyObject_IsInstance(obj, (PyObject*)BitOr_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5361 *out = BitOr; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5362 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5363 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5364 if (PyObject_IsInstance(obj, (PyObject*)BitXor_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5365 *out = BitXor; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5366 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5367 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5368 if (PyObject_IsInstance(obj, (PyObject*)BitAnd_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5369 *out = BitAnd; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5370 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5371 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5372 if (PyObject_IsInstance(obj, (PyObject*)FloorDiv_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5373 *out = FloorDiv; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5374 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5375 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5376 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5377 tmp = PyObject_Repr(obj); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5378 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5379 PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %.400s", PyString_AS_STRING(tmp)); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5380 failed: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5381 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5382 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5383 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5384 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5385 int |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5386 obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5387 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5388 PyObject* tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5389 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5390 if (PyObject_IsInstance(obj, (PyObject*)Invert_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5391 *out = Invert; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5392 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5393 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5394 if (PyObject_IsInstance(obj, (PyObject*)Not_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5395 *out = Not; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5396 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5397 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5398 if (PyObject_IsInstance(obj, (PyObject*)UAdd_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5399 *out = UAdd; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5400 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5401 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5402 if (PyObject_IsInstance(obj, (PyObject*)USub_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5403 *out = USub; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5404 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5405 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5406 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5407 tmp = PyObject_Repr(obj); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5408 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5409 PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %.400s", PyString_AS_STRING(tmp)); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5410 failed: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5411 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5412 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5413 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5414 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5415 int |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5416 obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5417 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5418 PyObject* tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5419 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5420 if (PyObject_IsInstance(obj, (PyObject*)Eq_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5421 *out = Eq; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5422 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5423 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5424 if (PyObject_IsInstance(obj, (PyObject*)NotEq_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5425 *out = NotEq; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5426 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5427 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5428 if (PyObject_IsInstance(obj, (PyObject*)Lt_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5429 *out = Lt; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5430 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5431 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5432 if (PyObject_IsInstance(obj, (PyObject*)LtE_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5433 *out = LtE; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5434 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5435 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5436 if (PyObject_IsInstance(obj, (PyObject*)Gt_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5437 *out = Gt; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5438 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5439 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5440 if (PyObject_IsInstance(obj, (PyObject*)GtE_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5441 *out = GtE; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5442 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5443 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5444 if (PyObject_IsInstance(obj, (PyObject*)Is_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5445 *out = Is; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5446 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5447 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5448 if (PyObject_IsInstance(obj, (PyObject*)IsNot_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5449 *out = IsNot; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5450 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5451 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5452 if (PyObject_IsInstance(obj, (PyObject*)In_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5453 *out = In; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5454 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5455 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5456 if (PyObject_IsInstance(obj, (PyObject*)NotIn_type)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5457 *out = NotIn; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5458 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5459 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5460 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5461 tmp = PyObject_Repr(obj); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5462 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5463 PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %.400s", PyString_AS_STRING(tmp)); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5464 failed: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5465 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5466 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5467 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5468 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5469 int |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5470 obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5471 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5472 PyObject* tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5473 expr_ty target; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5474 expr_ty iter; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5475 asdl_seq* ifs; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5476 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5477 if (PyObject_HasAttrString(obj, "target")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5478 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5479 tmp = PyObject_GetAttrString(obj, "target"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5480 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5481 res = obj2ast_expr(tmp, &target, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5482 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5483 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5484 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5485 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5486 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5487 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5488 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5489 if (PyObject_HasAttrString(obj, "iter")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5490 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5491 tmp = PyObject_GetAttrString(obj, "iter"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5492 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5493 res = obj2ast_expr(tmp, &iter, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5494 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5495 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5496 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5497 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5498 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5499 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5500 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5501 if (PyObject_HasAttrString(obj, "ifs")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5502 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5503 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5504 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5505 tmp = PyObject_GetAttrString(obj, "ifs"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5506 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5507 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5508 PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5509 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5510 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5511 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5512 ifs = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5513 if (ifs == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5514 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5515 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5516 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5517 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5518 asdl_seq_SET(ifs, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5519 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5520 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5521 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5522 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5523 PyErr_SetString(PyExc_TypeError, "required field \"ifs\" missing from comprehension"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5524 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5525 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5526 *out = comprehension(target, iter, ifs, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5527 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5528 failed: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5529 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5530 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5531 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5532 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5533 int |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5534 obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5535 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5536 PyObject* tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5537 expr_ty type; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5538 expr_ty name; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5539 asdl_seq* body; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5540 int lineno; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5541 int col_offset; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5542 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5543 if (PyObject_HasAttrString(obj, "type")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5544 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5545 tmp = PyObject_GetAttrString(obj, "type"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5546 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5547 res = obj2ast_expr(tmp, &type, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5548 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5549 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5550 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5551 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5552 type = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5553 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5554 if (PyObject_HasAttrString(obj, "name")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5555 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5556 tmp = PyObject_GetAttrString(obj, "name"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5557 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5558 res = obj2ast_expr(tmp, &name, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5559 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5560 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5561 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5562 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5563 name = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5564 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5565 if (PyObject_HasAttrString(obj, "body")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5566 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5567 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5568 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5569 tmp = PyObject_GetAttrString(obj, "body"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5570 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5571 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5572 PyErr_Format(PyExc_TypeError, "excepthandler field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5573 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5574 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5575 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5576 body = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5577 if (body == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5578 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5579 stmt_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5580 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5581 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5582 asdl_seq_SET(body, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5583 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5584 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5585 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5586 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5587 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from excepthandler"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5588 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5589 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5590 if (PyObject_HasAttrString(obj, "lineno")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5591 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5592 tmp = PyObject_GetAttrString(obj, "lineno"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5593 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5594 res = obj2ast_int(tmp, &lineno, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5595 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5596 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5597 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5598 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5599 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5600 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5601 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5602 if (PyObject_HasAttrString(obj, "col_offset")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5603 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5604 tmp = PyObject_GetAttrString(obj, "col_offset"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5605 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5606 res = obj2ast_int(tmp, &col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5607 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5608 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5609 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5610 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5611 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5612 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5613 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5614 *out = excepthandler(type, name, body, lineno, col_offset, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5615 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5616 failed: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5617 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5618 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5619 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5620 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5621 int |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5622 obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5623 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5624 PyObject* tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5625 asdl_seq* args; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5626 identifier vararg; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5627 identifier kwarg; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5628 asdl_seq* defaults; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5629 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5630 if (PyObject_HasAttrString(obj, "args")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5631 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5632 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5633 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5634 tmp = PyObject_GetAttrString(obj, "args"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5635 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5636 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5637 PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5638 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5639 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5640 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5641 args = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5642 if (args == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5643 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5644 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5645 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5646 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5647 asdl_seq_SET(args, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5648 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5649 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5650 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5651 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5652 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from arguments"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5653 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5654 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5655 if (PyObject_HasAttrString(obj, "vararg")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5656 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5657 tmp = PyObject_GetAttrString(obj, "vararg"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5658 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5659 res = obj2ast_identifier(tmp, &vararg, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5660 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5661 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5662 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5663 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5664 vararg = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5665 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5666 if (PyObject_HasAttrString(obj, "kwarg")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5667 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5668 tmp = PyObject_GetAttrString(obj, "kwarg"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5669 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5670 res = obj2ast_identifier(tmp, &kwarg, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5671 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5672 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5673 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5674 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5675 kwarg = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5676 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5677 if (PyObject_HasAttrString(obj, "defaults")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5678 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5679 Py_ssize_t len; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5680 Py_ssize_t i; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5681 tmp = PyObject_GetAttrString(obj, "defaults"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5682 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5683 if (!PyList_Check(tmp)) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5684 PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5685 goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5686 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5687 len = PyList_GET_SIZE(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5688 defaults = asdl_seq_new(len, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5689 if (defaults == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5690 for (i = 0; i < len; i++) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5691 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5692 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5693 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5694 asdl_seq_SET(defaults, i, value); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5695 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5696 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5697 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5698 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5699 PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5700 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5701 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5702 *out = arguments(args, vararg, kwarg, defaults, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5703 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5704 failed: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5705 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5706 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5707 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5708 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5709 int |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5710 obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5711 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5712 PyObject* tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5713 identifier arg; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5714 expr_ty value; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5715 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5716 if (PyObject_HasAttrString(obj, "arg")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5717 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5718 tmp = PyObject_GetAttrString(obj, "arg"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5719 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5720 res = obj2ast_identifier(tmp, &arg, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5721 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5722 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5723 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5724 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5725 PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from keyword"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5726 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5727 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5728 if (PyObject_HasAttrString(obj, "value")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5729 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5730 tmp = PyObject_GetAttrString(obj, "value"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5731 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5732 res = obj2ast_expr(tmp, &value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5733 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5734 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5735 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5736 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5737 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5738 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5739 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5740 *out = keyword(arg, value, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5741 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5742 failed: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5743 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5744 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5745 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5746 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5747 int |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5748 obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5749 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5750 PyObject* tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5751 identifier name; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5752 identifier asname; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5753 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5754 if (PyObject_HasAttrString(obj, "name")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5755 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5756 tmp = PyObject_GetAttrString(obj, "name"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5757 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5758 res = obj2ast_identifier(tmp, &name, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5759 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5760 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5761 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5762 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5763 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5764 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5765 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5766 if (PyObject_HasAttrString(obj, "asname")) { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5767 int res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5768 tmp = PyObject_GetAttrString(obj, "asname"); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5769 if (tmp == NULL) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5770 res = obj2ast_identifier(tmp, &asname, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5771 if (res != 0) goto failed; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5772 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5773 tmp = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5774 } else { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5775 asname = NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5776 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5777 *out = alias(name, asname, arena); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5778 return 0; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5779 failed: |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5780 Py_XDECREF(tmp); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5781 return 1; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5782 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5783 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5784 |
| 36669 | 5785 PyMODINIT_FUNC |
| 5786 init_ast(void) | |
| 5787 { | |
| 5788 PyObject *m, *d; | |
| 5789 if (!init_types()) return; | |
| 5790 m = Py_InitModule3("_ast", NULL, NULL); | |
| 5791 if (!m) return; | |
| 5792 d = PyModule_GetDict(m); | |
| 5793 if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return; | |
| 5794 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) | |
| 5795 return; | |
|
45470
3915d5f650fa
Issue #2051 and patch from Alexander Belopolsky:
Christian Heimes <christian@cheimes.de>
parents:
45447
diff
changeset
|
5796 if (PyModule_AddStringConstant(m, "__version__", "60978") < 0) |
| 36707 | 5797 return; |
|
37412
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5798 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5799 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5800 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5801 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5802 < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5803 if (PyDict_SetItemString(d, "Expression", (PyObject*)Expression_type) < |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5804 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5805 if (PyDict_SetItemString(d, "Suite", (PyObject*)Suite_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5806 if (PyDict_SetItemString(d, "stmt", (PyObject*)stmt_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5807 if (PyDict_SetItemString(d, "FunctionDef", (PyObject*)FunctionDef_type) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5808 < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5809 if (PyDict_SetItemString(d, "ClassDef", (PyObject*)ClassDef_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5810 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5811 if (PyDict_SetItemString(d, "Return", (PyObject*)Return_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5812 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5813 if (PyDict_SetItemString(d, "Delete", (PyObject*)Delete_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5814 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5815 if (PyDict_SetItemString(d, "Assign", (PyObject*)Assign_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5816 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5817 if (PyDict_SetItemString(d, "AugAssign", (PyObject*)AugAssign_type) < |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5818 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5819 if (PyDict_SetItemString(d, "Print", (PyObject*)Print_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5820 if (PyDict_SetItemString(d, "For", (PyObject*)For_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5821 if (PyDict_SetItemString(d, "While", (PyObject*)While_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5822 if (PyDict_SetItemString(d, "If", (PyObject*)If_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5823 if (PyDict_SetItemString(d, "With", (PyObject*)With_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5824 if (PyDict_SetItemString(d, "Raise", (PyObject*)Raise_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5825 if (PyDict_SetItemString(d, "TryExcept", (PyObject*)TryExcept_type) < |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5826 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5827 if (PyDict_SetItemString(d, "TryFinally", (PyObject*)TryFinally_type) < |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5828 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5829 if (PyDict_SetItemString(d, "Assert", (PyObject*)Assert_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5830 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5831 if (PyDict_SetItemString(d, "Import", (PyObject*)Import_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5832 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5833 if (PyDict_SetItemString(d, "ImportFrom", (PyObject*)ImportFrom_type) < |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5834 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5835 if (PyDict_SetItemString(d, "Exec", (PyObject*)Exec_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5836 if (PyDict_SetItemString(d, "Global", (PyObject*)Global_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5837 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5838 if (PyDict_SetItemString(d, "Expr", (PyObject*)Expr_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5839 if (PyDict_SetItemString(d, "Pass", (PyObject*)Pass_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5840 if (PyDict_SetItemString(d, "Break", (PyObject*)Break_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5841 if (PyDict_SetItemString(d, "Continue", (PyObject*)Continue_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5842 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5843 if (PyDict_SetItemString(d, "expr", (PyObject*)expr_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5844 if (PyDict_SetItemString(d, "BoolOp", (PyObject*)BoolOp_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5845 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5846 if (PyDict_SetItemString(d, "BinOp", (PyObject*)BinOp_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5847 if (PyDict_SetItemString(d, "UnaryOp", (PyObject*)UnaryOp_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5848 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5849 if (PyDict_SetItemString(d, "Lambda", (PyObject*)Lambda_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5850 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5851 if (PyDict_SetItemString(d, "IfExp", (PyObject*)IfExp_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5852 if (PyDict_SetItemString(d, "Dict", (PyObject*)Dict_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5853 if (PyDict_SetItemString(d, "ListComp", (PyObject*)ListComp_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5854 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5855 if (PyDict_SetItemString(d, "GeneratorExp", |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5856 (PyObject*)GeneratorExp_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5857 if (PyDict_SetItemString(d, "Yield", (PyObject*)Yield_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5858 if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5859 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5860 if (PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5861 if (PyDict_SetItemString(d, "Repr", (PyObject*)Repr_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5862 if (PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5863 if (PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5864 if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5865 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5866 if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) < |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5867 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5868 if (PyDict_SetItemString(d, "Name", (PyObject*)Name_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5869 if (PyDict_SetItemString(d, "List", (PyObject*)List_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5870 if (PyDict_SetItemString(d, "Tuple", (PyObject*)Tuple_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5871 if (PyDict_SetItemString(d, "expr_context", |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5872 (PyObject*)expr_context_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5873 if (PyDict_SetItemString(d, "Load", (PyObject*)Load_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5874 if (PyDict_SetItemString(d, "Store", (PyObject*)Store_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5875 if (PyDict_SetItemString(d, "Del", (PyObject*)Del_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5876 if (PyDict_SetItemString(d, "AugLoad", (PyObject*)AugLoad_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5877 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5878 if (PyDict_SetItemString(d, "AugStore", (PyObject*)AugStore_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5879 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5880 if (PyDict_SetItemString(d, "Param", (PyObject*)Param_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5881 if (PyDict_SetItemString(d, "slice", (PyObject*)slice_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5882 if (PyDict_SetItemString(d, "Ellipsis", (PyObject*)Ellipsis_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5883 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5884 if (PyDict_SetItemString(d, "Slice", (PyObject*)Slice_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5885 if (PyDict_SetItemString(d, "ExtSlice", (PyObject*)ExtSlice_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5886 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5887 if (PyDict_SetItemString(d, "Index", (PyObject*)Index_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5888 if (PyDict_SetItemString(d, "boolop", (PyObject*)boolop_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5889 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5890 if (PyDict_SetItemString(d, "And", (PyObject*)And_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5891 if (PyDict_SetItemString(d, "Or", (PyObject*)Or_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5892 if (PyDict_SetItemString(d, "operator", (PyObject*)operator_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5893 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5894 if (PyDict_SetItemString(d, "Add", (PyObject*)Add_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5895 if (PyDict_SetItemString(d, "Sub", (PyObject*)Sub_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5896 if (PyDict_SetItemString(d, "Mult", (PyObject*)Mult_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5897 if (PyDict_SetItemString(d, "Div", (PyObject*)Div_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5898 if (PyDict_SetItemString(d, "Mod", (PyObject*)Mod_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5899 if (PyDict_SetItemString(d, "Pow", (PyObject*)Pow_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5900 if (PyDict_SetItemString(d, "LShift", (PyObject*)LShift_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5901 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5902 if (PyDict_SetItemString(d, "RShift", (PyObject*)RShift_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5903 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5904 if (PyDict_SetItemString(d, "BitOr", (PyObject*)BitOr_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5905 if (PyDict_SetItemString(d, "BitXor", (PyObject*)BitXor_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5906 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5907 if (PyDict_SetItemString(d, "BitAnd", (PyObject*)BitAnd_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5908 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5909 if (PyDict_SetItemString(d, "FloorDiv", (PyObject*)FloorDiv_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5910 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5911 if (PyDict_SetItemString(d, "unaryop", (PyObject*)unaryop_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5912 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5913 if (PyDict_SetItemString(d, "Invert", (PyObject*)Invert_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5914 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5915 if (PyDict_SetItemString(d, "Not", (PyObject*)Not_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5916 if (PyDict_SetItemString(d, "UAdd", (PyObject*)UAdd_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5917 if (PyDict_SetItemString(d, "USub", (PyObject*)USub_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5918 if (PyDict_SetItemString(d, "cmpop", (PyObject*)cmpop_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5919 if (PyDict_SetItemString(d, "Eq", (PyObject*)Eq_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5920 if (PyDict_SetItemString(d, "NotEq", (PyObject*)NotEq_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5921 if (PyDict_SetItemString(d, "Lt", (PyObject*)Lt_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5922 if (PyDict_SetItemString(d, "LtE", (PyObject*)LtE_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5923 if (PyDict_SetItemString(d, "Gt", (PyObject*)Gt_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5924 if (PyDict_SetItemString(d, "GtE", (PyObject*)GtE_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5925 if (PyDict_SetItemString(d, "Is", (PyObject*)Is_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5926 if (PyDict_SetItemString(d, "IsNot", (PyObject*)IsNot_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5927 if (PyDict_SetItemString(d, "In", (PyObject*)In_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5928 if (PyDict_SetItemString(d, "NotIn", (PyObject*)NotIn_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5929 if (PyDict_SetItemString(d, "comprehension", |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5930 (PyObject*)comprehension_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5931 if (PyDict_SetItemString(d, "excepthandler", |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5932 (PyObject*)excepthandler_type) < 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5933 if (PyDict_SetItemString(d, "arguments", (PyObject*)arguments_type) < |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5934 0) return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5935 if (PyDict_SetItemString(d, "keyword", (PyObject*)keyword_type) < 0) |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5936 return; |
|
dfc33ec7f73a
* Fix a refleak of *_attributes.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36794
diff
changeset
|
5937 if (PyDict_SetItemString(d, "alias", (PyObject*)alias_type) < 0) return; |
| 36669 | 5938 } |
| 5939 | |
| 35742 | 5940 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
5941 PyObject* PyAST_mod2obj(mod_ty t) |
| 35742 | 5942 { |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
5943 init_types(); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
5944 return ast2obj_mod(t); |
| 35742 | 5945 } |
| 5946 | |
|
46193
b0bf06d49647
Properly check for consistency with the third argument of
Georg Brandl <georg@python.org>
parents:
46168
diff
changeset
|
5947 /* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */ |
|
b0bf06d49647
Properly check for consistency with the third argument of
Georg Brandl <georg@python.org>
parents:
46168
diff
changeset
|
5948 mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode) |
|
46162
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5949 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5950 mod_ty res; |
|
46193
b0bf06d49647
Properly check for consistency with the third argument of
Georg Brandl <georg@python.org>
parents:
46168
diff
changeset
|
5951 PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type, |
|
b0bf06d49647
Properly check for consistency with the third argument of
Georg Brandl <georg@python.org>
parents:
46168
diff
changeset
|
5952 (PyObject*)Interactive_type}; |
|
b0bf06d49647
Properly check for consistency with the third argument of
Georg Brandl <georg@python.org>
parents:
46168
diff
changeset
|
5953 char *req_name[] = {"Module", "Expression", "Interactive"}; |
|
b0bf06d49647
Properly check for consistency with the third argument of
Georg Brandl <georg@python.org>
parents:
46168
diff
changeset
|
5954 assert(0 <= mode && mode <= 2); |
|
b0bf06d49647
Properly check for consistency with the third argument of
Georg Brandl <georg@python.org>
parents:
46168
diff
changeset
|
5955 |
|
46162
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5956 init_types(); |
|
46193
b0bf06d49647
Properly check for consistency with the third argument of
Georg Brandl <georg@python.org>
parents:
46168
diff
changeset
|
5957 |
|
b0bf06d49647
Properly check for consistency with the third argument of
Georg Brandl <georg@python.org>
parents:
46168
diff
changeset
|
5958 if (!PyObject_IsInstance(ast, req_type[mode])) { |
|
b0bf06d49647
Properly check for consistency with the third argument of
Georg Brandl <georg@python.org>
parents:
46168
diff
changeset
|
5959 PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s", |
|
b0bf06d49647
Properly check for consistency with the third argument of
Georg Brandl <georg@python.org>
parents:
46168
diff
changeset
|
5960 req_name[mode], Py_TYPE(ast)->tp_name); |
|
46162
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5961 return NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5962 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5963 if (obj2ast_mod(ast, &res, arena) != 0) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5964 return NULL; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5965 else |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5966 return res; |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5967 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5968 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5969 int PyAST_Check(PyObject* obj) |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5970 { |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5971 init_types(); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5972 return PyObject_IsInstance(obj, (PyObject*)AST_type); |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5973 } |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5974 |
|
ca38f7a4b4c9
Patch #1810 by Thomas Lee, reviewed by myself:
Georg Brandl <georg@python.org>
parents:
45470
diff
changeset
|
5975 |
