annotate Python/Python-ast.c @ 84850:f2d557484906 3.3

According to the PEP 7, C code must "use 4-space indents" Replace 8 spaces with 4.
author Victor Stinner <victor.stinner@gmail.com>
date Sat, 27 Jul 2013 00:00:36 +0200
parents ffb2fa900cb7
children d14f40c87438 1b464f8453a4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40893
32c4897b5d46 Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40819
diff changeset
1 /* File automatically generated by Parser/asdl_c.py. */
32c4897b5d46 Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40819
diff changeset
2
75542
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
3 #include <stddef.h>
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
4
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
5 #include "Python.h"
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
6 #include "Python-ast.h"
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
7
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
8 static PyTypeObject AST_type;
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
9 static PyTypeObject *mod_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
10 static PyObject* ast2obj_mod(void*);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
11 static PyTypeObject *Module_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
12 _Py_IDENTIFIER(body);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
13 static char *Module_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
14 "body",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
15 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
16 static PyTypeObject *Interactive_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
17 static char *Interactive_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
18 "body",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
19 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
20 static PyTypeObject *Expression_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
21 static char *Expression_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
22 "body",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
23 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
24 static PyTypeObject *Suite_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
25 static char *Suite_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
26 "body",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
27 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
28 static PyTypeObject *stmt_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
29 _Py_IDENTIFIER(lineno);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
30 _Py_IDENTIFIER(col_offset);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
31 static char *stmt_attributes[] = {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
32 "lineno",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
33 "col_offset",
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
34 };
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
35 static PyObject* ast2obj_stmt(void*);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
36 static PyTypeObject *FunctionDef_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
37 _Py_IDENTIFIER(name);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
38 _Py_IDENTIFIER(args);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
39 _Py_IDENTIFIER(decorator_list);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
40 _Py_IDENTIFIER(returns);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
41 static char *FunctionDef_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
42 "name",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
43 "args",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
44 "body",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
45 "decorator_list",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
46 "returns",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
47 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
48 static PyTypeObject *ClassDef_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
49 _Py_IDENTIFIER(bases);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
50 _Py_IDENTIFIER(keywords);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
51 _Py_IDENTIFIER(starargs);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
52 _Py_IDENTIFIER(kwargs);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
53 static char *ClassDef_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
54 "name",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
55 "bases",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
56 "keywords",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
57 "starargs",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
58 "kwargs",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
59 "body",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
60 "decorator_list",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
61 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
62 static PyTypeObject *Return_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
63 _Py_IDENTIFIER(value);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
64 static char *Return_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
65 "value",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
66 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
67 static PyTypeObject *Delete_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
68 _Py_IDENTIFIER(targets);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
69 static char *Delete_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
70 "targets",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
71 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
72 static PyTypeObject *Assign_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
73 static char *Assign_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
74 "targets",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
75 "value",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
76 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
77 static PyTypeObject *AugAssign_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
78 _Py_IDENTIFIER(target);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
79 _Py_IDENTIFIER(op);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
80 static char *AugAssign_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
81 "target",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
82 "op",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
83 "value",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
84 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
85 static PyTypeObject *For_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
86 _Py_IDENTIFIER(iter);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
87 _Py_IDENTIFIER(orelse);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
88 static char *For_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
89 "target",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
90 "iter",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
91 "body",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
92 "orelse",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
93 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
94 static PyTypeObject *While_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
95 _Py_IDENTIFIER(test);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
96 static char *While_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
97 "test",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
98 "body",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
99 "orelse",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
100 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
101 static PyTypeObject *If_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
102 static char *If_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
103 "test",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
104 "body",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
105 "orelse",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
106 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
107 static PyTypeObject *With_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
108 _Py_IDENTIFIER(items);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
109 static char *With_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
110 "items",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
111 "body",
36695
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 36669
diff changeset
112 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
113 static PyTypeObject *Raise_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
114 _Py_IDENTIFIER(exc);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
115 _Py_IDENTIFIER(cause);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
116 static char *Raise_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
117 "exc",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
118 "cause",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
119 };
70499
e0e663132363 unify TryExcept and TryFinally (closes #12199)
Benjamin Peterson <benjamin@python.org>
parents: 70439
diff changeset
120 static PyTypeObject *Try_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
121 _Py_IDENTIFIER(handlers);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
122 _Py_IDENTIFIER(finalbody);
70499
e0e663132363 unify TryExcept and TryFinally (closes #12199)
Benjamin Peterson <benjamin@python.org>
parents: 70439
diff changeset
123 static char *Try_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
124 "body",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
125 "handlers",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
126 "orelse",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
127 "finalbody",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
128 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
129 static PyTypeObject *Assert_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
130 _Py_IDENTIFIER(msg);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
131 static char *Assert_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
132 "test",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
133 "msg",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
134 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
135 static PyTypeObject *Import_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
136 _Py_IDENTIFIER(names);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
137 static char *Import_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
138 "names",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
139 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
140 static PyTypeObject *ImportFrom_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
141 _Py_IDENTIFIER(module);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
142 _Py_IDENTIFIER(level);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
143 static char *ImportFrom_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
144 "module",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
145 "names",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
146 "level",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
147 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
148 static PyTypeObject *Global_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
149 static char *Global_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
150 "names",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
151 };
40965
30e5cb3a55ac Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 40941
diff changeset
152 static PyTypeObject *Nonlocal_type;
30e5cb3a55ac Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 40941
diff changeset
153 static char *Nonlocal_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
154 "names",
40965
30e5cb3a55ac Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 40941
diff changeset
155 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
156 static PyTypeObject *Expr_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
157 static char *Expr_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
158 "value",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
159 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
160 static PyTypeObject *Pass_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
161 static PyTypeObject *Break_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
162 static PyTypeObject *Continue_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
163 static PyTypeObject *expr_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
164 static char *expr_attributes[] = {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
165 "lineno",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
166 "col_offset",
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
167 };
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
168 static PyObject* ast2obj_expr(void*);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
169 static PyTypeObject *BoolOp_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
170 _Py_IDENTIFIER(values);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
171 static char *BoolOp_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
172 "op",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
173 "values",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
174 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
175 static PyTypeObject *BinOp_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
176 _Py_IDENTIFIER(left);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
177 _Py_IDENTIFIER(right);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
178 static char *BinOp_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
179 "left",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
180 "op",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
181 "right",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
182 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
183 static PyTypeObject *UnaryOp_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
184 _Py_IDENTIFIER(operand);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
185 static char *UnaryOp_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
186 "op",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
187 "operand",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
188 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
189 static PyTypeObject *Lambda_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
190 static char *Lambda_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
191 "args",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
192 "body",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
193 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
194 static PyTypeObject *IfExp_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
195 static char *IfExp_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
196 "test",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
197 "body",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
198 "orelse",
36666
6165927431d6 PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents: 36665
diff changeset
199 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
200 static PyTypeObject *Dict_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
201 _Py_IDENTIFIER(keys);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
202 static char *Dict_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
203 "keys",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
204 "values",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
205 };
39693
d0b83c4630c0 SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents: 39691
diff changeset
206 static PyTypeObject *Set_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
207 _Py_IDENTIFIER(elts);
39693
d0b83c4630c0 SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents: 39691
diff changeset
208 static char *Set_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
209 "elts",
39693
d0b83c4630c0 SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents: 39691
diff changeset
210 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
211 static PyTypeObject *ListComp_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
212 _Py_IDENTIFIER(elt);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
213 _Py_IDENTIFIER(generators);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
214 static char *ListComp_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
215 "elt",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
216 "generators",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
217 };
41464
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 41227
diff changeset
218 static PyTypeObject *SetComp_type;
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 41227
diff changeset
219 static char *SetComp_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
220 "elt",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
221 "generators",
41464
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 41227
diff changeset
222 };
42193
090588a17490 Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42013
diff changeset
223 static PyTypeObject *DictComp_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
224 _Py_IDENTIFIER(key);
42193
090588a17490 Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42013
diff changeset
225 static char *DictComp_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
226 "key",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
227 "value",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
228 "generators",
42193
090588a17490 Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42013
diff changeset
229 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
230 static PyTypeObject *GeneratorExp_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
231 static char *GeneratorExp_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
232 "elt",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
233 "generators",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
234 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
235 static PyTypeObject *Yield_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
236 static char *Yield_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
237 "value",
74391
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
238 };
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
239 static PyTypeObject *YieldFrom_type;
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
240 static char *YieldFrom_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
241 "value",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
242 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
243 static PyTypeObject *Compare_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
244 _Py_IDENTIFIER(ops);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
245 _Py_IDENTIFIER(comparators);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
246 static char *Compare_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
247 "left",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
248 "ops",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
249 "comparators",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
250 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
251 static PyTypeObject *Call_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
252 _Py_IDENTIFIER(func);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
253 static char *Call_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
254 "func",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
255 "args",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
256 "keywords",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
257 "starargs",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
258 "kwargs",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
259 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
260 static PyTypeObject *Num_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
261 _Py_IDENTIFIER(n);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
262 static char *Num_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
263 "n",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
264 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
265 static PyTypeObject *Str_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
266 _Py_IDENTIFIER(s);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
267 static char *Str_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
268 "s",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
269 };
40894
0ea24f4f2467 Bytes literal.
Thomas Wouters <thomas@python.org>
parents: 40893
diff changeset
270 static PyTypeObject *Bytes_type;
0ea24f4f2467 Bytes literal.
Thomas Wouters <thomas@python.org>
parents: 40893
diff changeset
271 static char *Bytes_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
272 "s",
40894
0ea24f4f2467 Bytes literal.
Thomas Wouters <thomas@python.org>
parents: 40893
diff changeset
273 };
39783
7a0ad110e91e Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents: 39782
diff changeset
274 static PyTypeObject *Ellipsis_type;
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
275 static PyTypeObject *Attribute_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
276 _Py_IDENTIFIER(attr);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
277 _Py_IDENTIFIER(ctx);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
278 static char *Attribute_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
279 "value",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
280 "attr",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
281 "ctx",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
282 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
283 static PyTypeObject *Subscript_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
284 _Py_IDENTIFIER(slice);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
285 static char *Subscript_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
286 "value",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
287 "slice",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
288 "ctx",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
289 };
41699
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
290 static PyTypeObject *Starred_type;
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
291 static char *Starred_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
292 "value",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
293 "ctx",
41699
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
294 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
295 static PyTypeObject *Name_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
296 _Py_IDENTIFIER(id);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
297 static char *Name_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
298 "id",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
299 "ctx",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
300 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
301 static PyTypeObject *List_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
302 static char *List_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
303 "elts",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
304 "ctx",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
305 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
306 static PyTypeObject *Tuple_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
307 static char *Tuple_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
308 "elts",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
309 "ctx",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
310 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
311 static PyTypeObject *expr_context_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
312 static PyObject *Load_singleton, *Store_singleton, *Del_singleton,
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
313 *AugLoad_singleton, *AugStore_singleton, *Param_singleton;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
314 static PyObject* ast2obj_expr_context(expr_context_ty);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
315 static PyTypeObject *Load_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
316 static PyTypeObject *Store_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
317 static PyTypeObject *Del_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
318 static PyTypeObject *AugLoad_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
319 static PyTypeObject *AugStore_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
320 static PyTypeObject *Param_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
321 static PyTypeObject *slice_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
322 static PyObject* ast2obj_slice(void*);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
323 static PyTypeObject *Slice_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
324 _Py_IDENTIFIER(lower);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
325 _Py_IDENTIFIER(upper);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
326 _Py_IDENTIFIER(step);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
327 static char *Slice_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
328 "lower",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
329 "upper",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
330 "step",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
331 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
332 static PyTypeObject *ExtSlice_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
333 _Py_IDENTIFIER(dims);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
334 static char *ExtSlice_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
335 "dims",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
336 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
337 static PyTypeObject *Index_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
338 static char *Index_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
339 "value",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
340 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
341 static PyTypeObject *boolop_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
342 static PyObject *And_singleton, *Or_singleton;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
343 static PyObject* ast2obj_boolop(boolop_ty);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
344 static PyTypeObject *And_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
345 static PyTypeObject *Or_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
346 static PyTypeObject *operator_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
347 static PyObject *Add_singleton, *Sub_singleton, *Mult_singleton,
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
348 *Div_singleton, *Mod_singleton, *Pow_singleton, *LShift_singleton,
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
349 *RShift_singleton, *BitOr_singleton, *BitXor_singleton, *BitAnd_singleton,
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
350 *FloorDiv_singleton;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
351 static PyObject* ast2obj_operator(operator_ty);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
352 static PyTypeObject *Add_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
353 static PyTypeObject *Sub_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
354 static PyTypeObject *Mult_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
355 static PyTypeObject *Div_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
356 static PyTypeObject *Mod_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
357 static PyTypeObject *Pow_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
358 static PyTypeObject *LShift_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
359 static PyTypeObject *RShift_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
360 static PyTypeObject *BitOr_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
361 static PyTypeObject *BitXor_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
362 static PyTypeObject *BitAnd_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
363 static PyTypeObject *FloorDiv_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
364 static PyTypeObject *unaryop_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
365 static PyObject *Invert_singleton, *Not_singleton, *UAdd_singleton,
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
366 *USub_singleton;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
367 static PyObject* ast2obj_unaryop(unaryop_ty);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
368 static PyTypeObject *Invert_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
369 static PyTypeObject *Not_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
370 static PyTypeObject *UAdd_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
371 static PyTypeObject *USub_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
372 static PyTypeObject *cmpop_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
373 static PyObject *Eq_singleton, *NotEq_singleton, *Lt_singleton, *LtE_singleton,
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
374 *Gt_singleton, *GtE_singleton, *Is_singleton, *IsNot_singleton, *In_singleton,
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
375 *NotIn_singleton;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
376 static PyObject* ast2obj_cmpop(cmpop_ty);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
377 static PyTypeObject *Eq_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
378 static PyTypeObject *NotEq_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
379 static PyTypeObject *Lt_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
380 static PyTypeObject *LtE_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
381 static PyTypeObject *Gt_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
382 static PyTypeObject *GtE_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
383 static PyTypeObject *Is_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
384 static PyTypeObject *IsNot_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
385 static PyTypeObject *In_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
386 static PyTypeObject *NotIn_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
387 static PyTypeObject *comprehension_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
388 static PyObject* ast2obj_comprehension(void*);
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
389 _Py_IDENTIFIER(ifs);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
390 static char *comprehension_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
391 "target",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
392 "iter",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
393 "ifs",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
394 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
395 static PyTypeObject *excepthandler_type;
46231
81ee270a6eb5 Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46229
diff changeset
396 static char *excepthandler_attributes[] = {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
397 "lineno",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
398 "col_offset",
46231
81ee270a6eb5 Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46229
diff changeset
399 };
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
400 static PyObject* ast2obj_excepthandler(void*);
46231
81ee270a6eb5 Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46229
diff changeset
401 static PyTypeObject *ExceptHandler_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
402 _Py_IDENTIFIER(type);
46231
81ee270a6eb5 Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46229
diff changeset
403 static char *ExceptHandler_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
404 "type",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
405 "name",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
406 "body",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
407 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
408 static PyTypeObject *arguments_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
409 static PyObject* ast2obj_arguments(void*);
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
410 _Py_IDENTIFIER(vararg);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
411 _Py_IDENTIFIER(varargannotation);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
412 _Py_IDENTIFIER(kwonlyargs);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
413 _Py_IDENTIFIER(kwarg);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
414 _Py_IDENTIFIER(kwargannotation);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
415 _Py_IDENTIFIER(defaults);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
416 _Py_IDENTIFIER(kw_defaults);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
417 static char *arguments_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
418 "args",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
419 "vararg",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
420 "varargannotation",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
421 "kwonlyargs",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
422 "kwarg",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
423 "kwargannotation",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
424 "defaults",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
425 "kw_defaults",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
426 };
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
427 static PyTypeObject *arg_type;
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
428 static PyObject* ast2obj_arg(void*);
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
429 _Py_IDENTIFIER(arg);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
430 _Py_IDENTIFIER(annotation);
41717
9ad84070b22d Merged revisions 55328-55341 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41699
diff changeset
431 static char *arg_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
432 "arg",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
433 "annotation",
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
434 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
435 static PyTypeObject *keyword_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
436 static PyObject* ast2obj_keyword(void*);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
437 static char *keyword_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
438 "arg",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
439 "value",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
440 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
441 static PyTypeObject *alias_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
442 static PyObject* ast2obj_alias(void*);
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
443 _Py_IDENTIFIER(asname);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
444 static char *alias_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
445 "name",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
446 "asname",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
447 };
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
448 static PyTypeObject *withitem_type;
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
449 static PyObject* ast2obj_withitem(void*);
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
450 _Py_IDENTIFIER(context_expr);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
451 _Py_IDENTIFIER(optional_vars);
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
452 static char *withitem_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
453 "context_expr",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
454 "optional_vars",
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
455 };
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
456
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
457
75542
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
458 typedef struct {
75567
6bee4eea1efa Try to fix compilation of Python-ast.c on Visual Studio 2008
Victor Stinner <victor.stinner@gmail.com>
parents: 75542
diff changeset
459 PyObject_HEAD
75542
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
460 PyObject *dict;
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
461 } AST_object;
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
462
75686
9e7f6ddc0d76 free AST's dict
Benjamin Peterson <benjamin@python.org>
parents: 75567
diff changeset
463 static void
9e7f6ddc0d76 free AST's dict
Benjamin Peterson <benjamin@python.org>
parents: 75567
diff changeset
464 ast_dealloc(AST_object *self)
9e7f6ddc0d76 free AST's dict
Benjamin Peterson <benjamin@python.org>
parents: 75567
diff changeset
465 {
9e7f6ddc0d76 free AST's dict
Benjamin Peterson <benjamin@python.org>
parents: 75567
diff changeset
466 Py_CLEAR(self->dict);
77998
048d8d9aecf1 Issue #15291: Fix a memory leak where AST nodes where not properly deallocated.
Antoine Pitrou <solipsis@pitrou.net>
parents: 76964
diff changeset
467 Py_TYPE(self)->tp_free(self);
75686
9e7f6ddc0d76 free AST's dict
Benjamin Peterson <benjamin@python.org>
parents: 75567
diff changeset
468 }
9e7f6ddc0d76 free AST's dict
Benjamin Peterson <benjamin@python.org>
parents: 75567
diff changeset
469
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
470 static int
78006
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
471 ast_traverse(AST_object *self, visitproc visit, void *arg)
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
472 {
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
473 Py_VISIT(self->dict);
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
474 return 0;
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
475 }
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
476
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
477 static void
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
478 ast_clear(AST_object *self)
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
479 {
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
480 Py_CLEAR(self->dict);
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
481 }
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
482
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
483 static int
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
484 ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
485 {
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
486 _Py_IDENTIFIER(_fields);
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
487 Py_ssize_t i, numfields = 0;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
488 int res = -1;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
489 PyObject *key, *value, *fields;
72848
81380082d216 Use identifier API for PyObject_GetAttrString.
Martin v. Löwis <martin@v.loewis.de>
parents: 72195
diff changeset
490 fields = _PyObject_GetAttrId((PyObject*)Py_TYPE(self), &PyId__fields);
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
491 if (!fields)
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
492 PyErr_Clear();
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
493 if (fields) {
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
494 numfields = PySequence_Size(fields);
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
495 if (numfields == -1)
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
496 goto cleanup;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
497 }
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
498 res = 0; /* if no error occurs, this stays 0 to the end */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
499 if (PyTuple_GET_SIZE(args) > 0) {
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
500 if (numfields != PyTuple_GET_SIZE(args)) {
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
501 PyErr_Format(PyExc_TypeError, "%.400s constructor takes %s"
49139
6ae2d4b507a2 Merged revisions 66377 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 47580
diff changeset
502 "%zd positional argument%s",
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
503 Py_TYPE(self)->tp_name,
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
504 numfields == 0 ? "" : "either 0 or ",
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
505 numfields, numfields == 1 ? "" : "s");
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
506 res = -1;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
507 goto cleanup;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
508 }
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
509 for (i = 0; i < PyTuple_GET_SIZE(args); i++) {
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
510 /* cannot be reached when fields is NULL */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
511 PyObject *name = PySequence_GetItem(fields, i);
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
512 if (!name) {
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
513 res = -1;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
514 goto cleanup;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
515 }
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
516 res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i));
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
517 Py_DECREF(name);
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
518 if (res < 0)
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
519 goto cleanup;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
520 }
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
521 }
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
522 if (kw) {
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
523 i = 0; /* needed by PyDict_Next */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
524 while (PyDict_Next(kw, &i, &key, &value)) {
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
525 res = PyObject_SetAttr(self, key, value);
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
526 if (res < 0)
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
527 goto cleanup;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
528 }
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
529 }
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
530 cleanup:
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
531 Py_XDECREF(fields);
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
532 return res;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
533 }
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
534
46233
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
535 /* Pickling support */
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
536 static PyObject *
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
537 ast_type_reduce(PyObject *self, PyObject *unused)
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
538 {
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
539 PyObject *res;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
540 _Py_IDENTIFIER(__dict__);
72848
81380082d216 Use identifier API for PyObject_GetAttrString.
Martin v. Löwis <martin@v.loewis.de>
parents: 72195
diff changeset
541 PyObject *dict = _PyObject_GetAttrId(self, &PyId___dict__);
46233
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
542 if (dict == NULL) {
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
543 if (PyErr_ExceptionMatches(PyExc_AttributeError))
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
544 PyErr_Clear();
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
545 else
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
546 return NULL;
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
547 }
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
548 if (dict) {
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
549 res = Py_BuildValue("O()O", Py_TYPE(self), dict);
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
550 Py_DECREF(dict);
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
551 return res;
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
552 }
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
553 return Py_BuildValue("O()", Py_TYPE(self));
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
554 }
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
555
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
556 static PyMethodDef ast_type_methods[] = {
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
557 {"__reduce__", ast_type_reduce, METH_NOARGS, NULL},
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
558 {NULL}
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
559 };
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
560
75542
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
561 static PyGetSetDef ast_type_getsets[] = {
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
562 {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
563 {NULL}
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
564 };
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
565
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
566 static PyTypeObject AST_type = {
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
567 PyVarObject_HEAD_INIT(&PyType_Type, 0)
46233
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
568 "_ast.AST",
75542
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
569 sizeof(AST_object),
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
570 0,
75686
9e7f6ddc0d76 free AST's dict
Benjamin Peterson <benjamin@python.org>
parents: 75567
diff changeset
571 (destructor)ast_dealloc, /* tp_dealloc */
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
572 0, /* tp_print */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
573 0, /* tp_getattr */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
574 0, /* tp_setattr */
51270
debd14c489b9 Issue #1717: rename tp_compare to tp_reserved. I'll change the
Mark Dickinson <dickinsm@gmail.com>
parents: 50076
diff changeset
575 0, /* tp_reserved */
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
576 0, /* tp_repr */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
577 0, /* tp_as_number */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
578 0, /* tp_as_sequence */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
579 0, /* tp_as_mapping */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
580 0, /* tp_hash */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
581 0, /* tp_call */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
582 0, /* tp_str */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
583 PyObject_GenericGetAttr, /* tp_getattro */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
584 PyObject_GenericSetAttr, /* tp_setattro */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
585 0, /* tp_as_buffer */
78006
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
586 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
587 0, /* tp_doc */
78006
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
588 (traverseproc)ast_traverse, /* tp_traverse */
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
589 (inquiry)ast_clear, /* tp_clear */
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
590 0, /* tp_richcompare */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
591 0, /* tp_weaklistoffset */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
592 0, /* tp_iter */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
593 0, /* tp_iternext */
46233
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
594 ast_type_methods, /* tp_methods */
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
595 0, /* tp_members */
75542
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
596 ast_type_getsets, /* tp_getset */
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
597 0, /* tp_base */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
598 0, /* tp_dict */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
599 0, /* tp_descr_get */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
600 0, /* tp_descr_set */
75542
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
601 offsetof(AST_object, dict),/* tp_dictoffset */
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
602 (initproc)ast_type_init, /* tp_init */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
603 PyType_GenericAlloc, /* tp_alloc */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
604 PyType_GenericNew, /* tp_new */
78006
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
605 PyObject_GC_Del, /* tp_free */
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
606 };
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
607
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
608
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
609 static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int num_fields)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
610 {
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
611 PyObject *fnames, *result;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
612 int i;
46233
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
613 fnames = PyTuple_New(num_fields);
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
614 if (!fnames) return NULL;
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
615 for (i = 0; i < num_fields; i++) {
42816
872c7c3f0af3 Use unicode for AST attributes
Neal Norwitz <nnorwitz@gmail.com>
parents: 42206
diff changeset
616 PyObject *field = PyUnicode_FromString(fields[i]);
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
617 if (!field) {
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
618 Py_DECREF(fnames);
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
619 return NULL;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
620 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
621 PyTuple_SET_ITEM(fnames, i, field);
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
622 }
62155
600c23127207 Issue #8848: U / U# formats of Py_BuildValue() are just alias to s / s#
Victor Stinner <victor.stinner@haypocalc.com>
parents: 57676
diff changeset
623 result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}",
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
624 type, base, "_fields", fnames, "__module__", "_ast");
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
625 Py_DECREF(fnames);
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
626 return (PyTypeObject*)result;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
627 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
628
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
629 static int add_attributes(PyTypeObject* type, char**attrs, int num_fields)
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
630 {
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36794
diff changeset
631 int i, result;
72926
db4aa878cea2 Port SetAttrString/HasAttrString to SetAttrId/GetAttrId.
Martin v. Löwis <martin@v.loewis.de>
parents: 72925
diff changeset
632 _Py_IDENTIFIER(_attributes);
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
633 PyObject *s, *l = PyTuple_New(num_fields);
62566
504c499e8c95 Merged revisions 81465-81466,81468,81679,81735,81760,81868,82183 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 62464
diff changeset
634 if (!l)
504c499e8c95 Merged revisions 81465-81466,81468,81679,81735,81760,81868,82183 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 62464
diff changeset
635 return 0;
504c499e8c95 Merged revisions 81465-81466,81468,81679,81735,81760,81868,82183 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 62464
diff changeset
636 for (i = 0; i < num_fields; i++) {
42816
872c7c3f0af3 Use unicode for AST attributes
Neal Norwitz <nnorwitz@gmail.com>
parents: 42206
diff changeset
637 s = PyUnicode_FromString(attrs[i]);
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
638 if (!s) {
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
639 Py_DECREF(l);
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
640 return 0;
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
641 }
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
642 PyTuple_SET_ITEM(l, i, s);
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
643 }
72926
db4aa878cea2 Port SetAttrString/HasAttrString to SetAttrId/GetAttrId.
Martin v. Löwis <martin@v.loewis.de>
parents: 72925
diff changeset
644 result = _PyObject_SetAttrId((PyObject*)type, &PyId__attributes, l) >= 0;
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36794
diff changeset
645 Py_DECREF(l);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36794
diff changeset
646 return result;
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
647 }
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
648
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
649 /* Conversion AST -> Python */
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
650
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
651 static PyObject* ast2obj_list(asdl_seq *seq, PyObject* (*func)(void*))
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
652 {
76964
c18a1a82bb07 use Py_ssize_t for ast sequence lengths
Benjamin Peterson <benjamin@python.org>
parents: 76948
diff changeset
653 Py_ssize_t i, n = asdl_seq_LEN(seq);
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
654 PyObject *result = PyList_New(n);
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
655 PyObject *value;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
656 if (!result)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
657 return NULL;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
658 for (i = 0; i < n; i++) {
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
659 value = func(asdl_seq_GET(seq, i));
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
660 if (!value) {
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
661 Py_DECREF(result);
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
662 return NULL;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
663 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
664 PyList_SET_ITEM(result, i, value);
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
665 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
666 return result;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
667 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
668
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
669 static PyObject* ast2obj_object(void *o)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
670 {
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
671 if (!o)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
672 o = Py_None;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
673 Py_INCREF((PyObject*)o);
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
674 return (PyObject*)o;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
675 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
676 #define ast2obj_identifier ast2obj_object
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
677 #define ast2obj_string ast2obj_object
71792
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
678 #define ast2obj_bytes ast2obj_object
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
679
40937
6aa1be5dd009 Merged revisions 53912-53951 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40896
diff changeset
680 static PyObject* ast2obj_int(long b)
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
681 {
44099
f324631462a2 Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents: 43755
diff changeset
682 return PyLong_FromLong(b);
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
683 }
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
684
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
685 /* Conversion Python -> AST */
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
686
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
687 static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
688 {
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
689 if (obj == Py_None)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
690 obj = NULL;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
691 if (obj)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
692 PyArena_AddPyObject(arena, obj);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
693 Py_XINCREF(obj);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
694 *out = obj;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
695 return 0;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
696 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
697
71458
c9ebae3285e3 None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents: 71455
diff changeset
698 static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena)
71454
3301689bd78d type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents: 68257
diff changeset
699 {
71458
c9ebae3285e3 None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents: 71455
diff changeset
700 if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
c9ebae3285e3 None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents: 71455
diff changeset
701 PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str");
71454
3301689bd78d type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents: 68257
diff changeset
702 return 1;
3301689bd78d type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents: 68257
diff changeset
703 }
3301689bd78d type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents: 68257
diff changeset
704 return obj2ast_object(obj, out, arena);
3301689bd78d type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents: 68257
diff changeset
705 }
3301689bd78d type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents: 68257
diff changeset
706
3301689bd78d type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents: 68257
diff changeset
707 static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena)
3301689bd78d type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents: 68257
diff changeset
708 {
72154
c8b6d4417274 accept bytes for the AST 'string' type
Benjamin Peterson <benjamin@python.org>
parents: 71458
diff changeset
709 if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
71458
c9ebae3285e3 None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents: 71455
diff changeset
710 PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
c9ebae3285e3 None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents: 71455
diff changeset
711 return 1;
c9ebae3285e3 None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents: 71455
diff changeset
712 }
c9ebae3285e3 None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents: 71455
diff changeset
713 return obj2ast_object(obj, out, arena);
71454
3301689bd78d type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents: 68257
diff changeset
714 }
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
715
71792
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
716 static int obj2ast_bytes(PyObject* obj, PyObject** out, PyArena* arena)
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
717 {
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
718 if (!PyBytes_CheckExact(obj)) {
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
719 PyErr_SetString(PyExc_TypeError, "AST bytes must be of type bytes");
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
720 return 1;
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
721 }
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
722 return obj2ast_object(obj, out, arena);
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
723 }
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
724
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
725 static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
726 {
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
727 int i;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
728 if (!PyLong_Check(obj)) {
73700
470f7d7c57ce Issue #13436: commit regenerated Python-ast.c
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 72154
diff changeset
729 PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj);
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
730 return 1;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
731 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
732
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
733 i = (int)PyLong_AsLong(obj);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
734 if (i == -1 && PyErr_Occurred())
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
735 return 1;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
736 *out = i;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
737 return 0;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
738 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
739
49587
f66688e69f66 Merged revisions 66974,66977,66984,66989,66992,66994-66996,66998-67000,67007,67015 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 49583
diff changeset
740 static int add_ast_fields(void)
49583
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
741 {
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
742 PyObject *empty_tuple, *d;
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
743 if (PyType_Ready(&AST_type) < 0)
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
744 return -1;
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
745 d = AST_type.tp_dict;
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
746 empty_tuple = PyTuple_New(0);
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
747 if (!empty_tuple ||
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
748 PyDict_SetItemString(d, "_fields", empty_tuple) < 0 ||
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
749 PyDict_SetItemString(d, "_attributes", empty_tuple) < 0) {
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
750 Py_XDECREF(empty_tuple);
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
751 return -1;
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
752 }
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
753 Py_DECREF(empty_tuple);
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
754 return 0;
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
755 }
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
756
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
757
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
758 static int init_types(void)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
759 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
760 static int initialized;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
761 if (initialized) return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
762 if (add_ast_fields() < 0) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
763 mod_type = make_type("mod", &AST_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
764 if (!mod_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
765 if (!add_attributes(mod_type, NULL, 0)) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
766 Module_type = make_type("Module", mod_type, Module_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
767 if (!Module_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
768 Interactive_type = make_type("Interactive", mod_type, Interactive_fields,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
769 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
770 if (!Interactive_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
771 Expression_type = make_type("Expression", mod_type, Expression_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
772 if (!Expression_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
773 Suite_type = make_type("Suite", mod_type, Suite_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
774 if (!Suite_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
775 stmt_type = make_type("stmt", &AST_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
776 if (!stmt_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
777 if (!add_attributes(stmt_type, stmt_attributes, 2)) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
778 FunctionDef_type = make_type("FunctionDef", stmt_type, FunctionDef_fields,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
779 5);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
780 if (!FunctionDef_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
781 ClassDef_type = make_type("ClassDef", stmt_type, ClassDef_fields, 7);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
782 if (!ClassDef_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
783 Return_type = make_type("Return", stmt_type, Return_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
784 if (!Return_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
785 Delete_type = make_type("Delete", stmt_type, Delete_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
786 if (!Delete_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
787 Assign_type = make_type("Assign", stmt_type, Assign_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
788 if (!Assign_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
789 AugAssign_type = make_type("AugAssign", stmt_type, AugAssign_fields, 3);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
790 if (!AugAssign_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
791 For_type = make_type("For", stmt_type, For_fields, 4);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
792 if (!For_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
793 While_type = make_type("While", stmt_type, While_fields, 3);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
794 if (!While_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
795 If_type = make_type("If", stmt_type, If_fields, 3);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
796 if (!If_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
797 With_type = make_type("With", stmt_type, With_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
798 if (!With_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
799 Raise_type = make_type("Raise", stmt_type, Raise_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
800 if (!Raise_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
801 Try_type = make_type("Try", stmt_type, Try_fields, 4);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
802 if (!Try_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
803 Assert_type = make_type("Assert", stmt_type, Assert_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
804 if (!Assert_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
805 Import_type = make_type("Import", stmt_type, Import_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
806 if (!Import_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
807 ImportFrom_type = make_type("ImportFrom", stmt_type, ImportFrom_fields, 3);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
808 if (!ImportFrom_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
809 Global_type = make_type("Global", stmt_type, Global_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
810 if (!Global_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
811 Nonlocal_type = make_type("Nonlocal", stmt_type, Nonlocal_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
812 if (!Nonlocal_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
813 Expr_type = make_type("Expr", stmt_type, Expr_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
814 if (!Expr_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
815 Pass_type = make_type("Pass", stmt_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
816 if (!Pass_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
817 Break_type = make_type("Break", stmt_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
818 if (!Break_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
819 Continue_type = make_type("Continue", stmt_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
820 if (!Continue_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
821 expr_type = make_type("expr", &AST_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
822 if (!expr_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
823 if (!add_attributes(expr_type, expr_attributes, 2)) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
824 BoolOp_type = make_type("BoolOp", expr_type, BoolOp_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
825 if (!BoolOp_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
826 BinOp_type = make_type("BinOp", expr_type, BinOp_fields, 3);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
827 if (!BinOp_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
828 UnaryOp_type = make_type("UnaryOp", expr_type, UnaryOp_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
829 if (!UnaryOp_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
830 Lambda_type = make_type("Lambda", expr_type, Lambda_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
831 if (!Lambda_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
832 IfExp_type = make_type("IfExp", expr_type, IfExp_fields, 3);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
833 if (!IfExp_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
834 Dict_type = make_type("Dict", expr_type, Dict_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
835 if (!Dict_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
836 Set_type = make_type("Set", expr_type, Set_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
837 if (!Set_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
838 ListComp_type = make_type("ListComp", expr_type, ListComp_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
839 if (!ListComp_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
840 SetComp_type = make_type("SetComp", expr_type, SetComp_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
841 if (!SetComp_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
842 DictComp_type = make_type("DictComp", expr_type, DictComp_fields, 3);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
843 if (!DictComp_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
844 GeneratorExp_type = make_type("GeneratorExp", expr_type,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
845 GeneratorExp_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
846 if (!GeneratorExp_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
847 Yield_type = make_type("Yield", expr_type, Yield_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
848 if (!Yield_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
849 YieldFrom_type = make_type("YieldFrom", expr_type, YieldFrom_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
850 if (!YieldFrom_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
851 Compare_type = make_type("Compare", expr_type, Compare_fields, 3);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
852 if (!Compare_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
853 Call_type = make_type("Call", expr_type, Call_fields, 5);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
854 if (!Call_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
855 Num_type = make_type("Num", expr_type, Num_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
856 if (!Num_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
857 Str_type = make_type("Str", expr_type, Str_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
858 if (!Str_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
859 Bytes_type = make_type("Bytes", expr_type, Bytes_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
860 if (!Bytes_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
861 Ellipsis_type = make_type("Ellipsis", expr_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
862 if (!Ellipsis_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
863 Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
864 if (!Attribute_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
865 Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
866 if (!Subscript_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
867 Starred_type = make_type("Starred", expr_type, Starred_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
868 if (!Starred_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
869 Name_type = make_type("Name", expr_type, Name_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
870 if (!Name_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
871 List_type = make_type("List", expr_type, List_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
872 if (!List_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
873 Tuple_type = make_type("Tuple", expr_type, Tuple_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
874 if (!Tuple_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
875 expr_context_type = make_type("expr_context", &AST_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
876 if (!expr_context_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
877 if (!add_attributes(expr_context_type, NULL, 0)) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
878 Load_type = make_type("Load", expr_context_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
879 if (!Load_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
880 Load_singleton = PyType_GenericNew(Load_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
881 if (!Load_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
882 Store_type = make_type("Store", expr_context_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
883 if (!Store_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
884 Store_singleton = PyType_GenericNew(Store_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
885 if (!Store_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
886 Del_type = make_type("Del", expr_context_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
887 if (!Del_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
888 Del_singleton = PyType_GenericNew(Del_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
889 if (!Del_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
890 AugLoad_type = make_type("AugLoad", expr_context_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
891 if (!AugLoad_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
892 AugLoad_singleton = PyType_GenericNew(AugLoad_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
893 if (!AugLoad_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
894 AugStore_type = make_type("AugStore", expr_context_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
895 if (!AugStore_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
896 AugStore_singleton = PyType_GenericNew(AugStore_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
897 if (!AugStore_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
898 Param_type = make_type("Param", expr_context_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
899 if (!Param_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
900 Param_singleton = PyType_GenericNew(Param_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
901 if (!Param_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
902 slice_type = make_type("slice", &AST_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
903 if (!slice_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
904 if (!add_attributes(slice_type, NULL, 0)) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
905 Slice_type = make_type("Slice", slice_type, Slice_fields, 3);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
906 if (!Slice_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
907 ExtSlice_type = make_type("ExtSlice", slice_type, ExtSlice_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
908 if (!ExtSlice_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
909 Index_type = make_type("Index", slice_type, Index_fields, 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
910 if (!Index_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
911 boolop_type = make_type("boolop", &AST_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
912 if (!boolop_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
913 if (!add_attributes(boolop_type, NULL, 0)) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
914 And_type = make_type("And", boolop_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
915 if (!And_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
916 And_singleton = PyType_GenericNew(And_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
917 if (!And_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
918 Or_type = make_type("Or", boolop_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
919 if (!Or_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
920 Or_singleton = PyType_GenericNew(Or_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
921 if (!Or_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
922 operator_type = make_type("operator", &AST_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
923 if (!operator_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
924 if (!add_attributes(operator_type, NULL, 0)) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
925 Add_type = make_type("Add", operator_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
926 if (!Add_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
927 Add_singleton = PyType_GenericNew(Add_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
928 if (!Add_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
929 Sub_type = make_type("Sub", operator_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
930 if (!Sub_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
931 Sub_singleton = PyType_GenericNew(Sub_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
932 if (!Sub_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
933 Mult_type = make_type("Mult", operator_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
934 if (!Mult_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
935 Mult_singleton = PyType_GenericNew(Mult_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
936 if (!Mult_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
937 Div_type = make_type("Div", operator_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
938 if (!Div_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
939 Div_singleton = PyType_GenericNew(Div_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
940 if (!Div_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
941 Mod_type = make_type("Mod", operator_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
942 if (!Mod_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
943 Mod_singleton = PyType_GenericNew(Mod_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
944 if (!Mod_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
945 Pow_type = make_type("Pow", operator_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
946 if (!Pow_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
947 Pow_singleton = PyType_GenericNew(Pow_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
948 if (!Pow_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
949 LShift_type = make_type("LShift", operator_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
950 if (!LShift_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
951 LShift_singleton = PyType_GenericNew(LShift_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
952 if (!LShift_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
953 RShift_type = make_type("RShift", operator_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
954 if (!RShift_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
955 RShift_singleton = PyType_GenericNew(RShift_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
956 if (!RShift_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
957 BitOr_type = make_type("BitOr", operator_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
958 if (!BitOr_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
959 BitOr_singleton = PyType_GenericNew(BitOr_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
960 if (!BitOr_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
961 BitXor_type = make_type("BitXor", operator_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
962 if (!BitXor_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
963 BitXor_singleton = PyType_GenericNew(BitXor_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
964 if (!BitXor_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
965 BitAnd_type = make_type("BitAnd", operator_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
966 if (!BitAnd_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
967 BitAnd_singleton = PyType_GenericNew(BitAnd_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
968 if (!BitAnd_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
969 FloorDiv_type = make_type("FloorDiv", operator_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
970 if (!FloorDiv_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
971 FloorDiv_singleton = PyType_GenericNew(FloorDiv_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
972 if (!FloorDiv_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
973 unaryop_type = make_type("unaryop", &AST_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
974 if (!unaryop_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
975 if (!add_attributes(unaryop_type, NULL, 0)) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
976 Invert_type = make_type("Invert", unaryop_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
977 if (!Invert_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
978 Invert_singleton = PyType_GenericNew(Invert_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
979 if (!Invert_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
980 Not_type = make_type("Not", unaryop_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
981 if (!Not_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
982 Not_singleton = PyType_GenericNew(Not_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
983 if (!Not_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
984 UAdd_type = make_type("UAdd", unaryop_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
985 if (!UAdd_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
986 UAdd_singleton = PyType_GenericNew(UAdd_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
987 if (!UAdd_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
988 USub_type = make_type("USub", unaryop_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
989 if (!USub_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
990 USub_singleton = PyType_GenericNew(USub_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
991 if (!USub_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
992 cmpop_type = make_type("cmpop", &AST_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
993 if (!cmpop_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
994 if (!add_attributes(cmpop_type, NULL, 0)) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
995 Eq_type = make_type("Eq", cmpop_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
996 if (!Eq_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
997 Eq_singleton = PyType_GenericNew(Eq_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
998 if (!Eq_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
999 NotEq_type = make_type("NotEq", cmpop_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1000 if (!NotEq_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1001 NotEq_singleton = PyType_GenericNew(NotEq_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1002 if (!NotEq_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1003 Lt_type = make_type("Lt", cmpop_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1004 if (!Lt_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1005 Lt_singleton = PyType_GenericNew(Lt_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1006 if (!Lt_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1007 LtE_type = make_type("LtE", cmpop_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1008 if (!LtE_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1009 LtE_singleton = PyType_GenericNew(LtE_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1010 if (!LtE_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1011 Gt_type = make_type("Gt", cmpop_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1012 if (!Gt_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1013 Gt_singleton = PyType_GenericNew(Gt_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1014 if (!Gt_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1015 GtE_type = make_type("GtE", cmpop_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1016 if (!GtE_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1017 GtE_singleton = PyType_GenericNew(GtE_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1018 if (!GtE_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1019 Is_type = make_type("Is", cmpop_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1020 if (!Is_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1021 Is_singleton = PyType_GenericNew(Is_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1022 if (!Is_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1023 IsNot_type = make_type("IsNot", cmpop_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1024 if (!IsNot_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1025 IsNot_singleton = PyType_GenericNew(IsNot_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1026 if (!IsNot_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1027 In_type = make_type("In", cmpop_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1028 if (!In_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1029 In_singleton = PyType_GenericNew(In_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1030 if (!In_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1031 NotIn_type = make_type("NotIn", cmpop_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1032 if (!NotIn_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1033 NotIn_singleton = PyType_GenericNew(NotIn_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1034 if (!NotIn_singleton) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1035 comprehension_type = make_type("comprehension", &AST_type,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1036 comprehension_fields, 3);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1037 if (!comprehension_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1038 excepthandler_type = make_type("excepthandler", &AST_type, NULL, 0);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1039 if (!excepthandler_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1040 if (!add_attributes(excepthandler_type, excepthandler_attributes, 2))
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1041 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1042 ExceptHandler_type = make_type("ExceptHandler", excepthandler_type,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1043 ExceptHandler_fields, 3);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1044 if (!ExceptHandler_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1045 arguments_type = make_type("arguments", &AST_type, arguments_fields, 8);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1046 if (!arguments_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1047 arg_type = make_type("arg", &AST_type, arg_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1048 if (!arg_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1049 keyword_type = make_type("keyword", &AST_type, keyword_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1050 if (!keyword_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1051 alias_type = make_type("alias", &AST_type, alias_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1052 if (!alias_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1053 withitem_type = make_type("withitem", &AST_type, withitem_fields, 2);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1054 if (!withitem_type) return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1055 initialized = 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1056 return 1;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
1057 }
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
1058
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1059 static int obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1060 static int obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1061 static int obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1062 static int obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena*
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1063 arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1064 static int obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1065 static int obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1066 static int obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1067 static int obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1068 static int obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1069 static int obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena*
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1070 arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1071 static int obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena*
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1072 arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1073 static int obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1074 static int obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1075 static int obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1076 static int obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena);
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
1077 static int obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena);
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1078
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1079 mod_ty
36065
ea083efdc96c Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents: 36003
diff changeset
1080 Module(asdl_seq * body, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1081 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1082 mod_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1083 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1084 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1085 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1086 p->kind = Module_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1087 p->v.Module.body = body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1088 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1089 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1090
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1091 mod_ty
36065
ea083efdc96c Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents: 36003
diff changeset
1092 Interactive(asdl_seq * body, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1093 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1094 mod_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1095 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1096 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1097 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1098 p->kind = Interactive_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1099 p->v.Interactive.body = body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1100 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1101 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1102
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1103 mod_ty
36065
ea083efdc96c Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents: 36003
diff changeset
1104 Expression(expr_ty body, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1105 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1106 mod_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1107 if (!body) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1108 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1109 "field body is required for Expression");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1110 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1111 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1112 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1113 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1114 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1115 p->kind = Expression_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1116 p->v.Expression.body = body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1117 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1118 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1119
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1120 mod_ty
36065
ea083efdc96c Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents: 36003
diff changeset
1121 Suite(asdl_seq * body, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1122 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1123 mod_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1124 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1125 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1126 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1127 p->kind = Suite_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1128 p->v.Suite.body = body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1129 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1130 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1131
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1132 stmt_ty
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1133 FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq *
41824
24b60622b944 Merged revisions 55407-55513 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41722
diff changeset
1134 decorator_list, expr_ty returns, int lineno, int col_offset,
24b60622b944 Merged revisions 55407-55513 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41722
diff changeset
1135 PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1136 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1137 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1138 if (!name) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1139 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1140 "field name is required for FunctionDef");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1141 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1142 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1143 if (!args) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1144 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1145 "field args is required for FunctionDef");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1146 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1147 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1148 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1149 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1150 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1151 p->kind = FunctionDef_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1152 p->v.FunctionDef.name = name;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1153 p->v.FunctionDef.args = args;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1154 p->v.FunctionDef.body = body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1155 p->v.FunctionDef.decorator_list = decorator_list;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1156 p->v.FunctionDef.returns = returns;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1157 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1158 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1159 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1160 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1161
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1162 stmt_ty
41226
19f7ff443718 Implement PEP 3115 -- new metaclass syntax and semantics.
Guido van Rossum <guido@python.org>
parents: 40980
diff changeset
1163 ClassDef(identifier name, asdl_seq * bases, asdl_seq * keywords, expr_ty
41824
24b60622b944 Merged revisions 55407-55513 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41722
diff changeset
1164 starargs, expr_ty kwargs, asdl_seq * body, asdl_seq * decorator_list,
24b60622b944 Merged revisions 55407-55513 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41722
diff changeset
1165 int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1166 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1167 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1168 if (!name) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1169 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1170 "field name is required for ClassDef");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1171 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1172 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1173 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1174 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1175 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1176 p->kind = ClassDef_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1177 p->v.ClassDef.name = name;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1178 p->v.ClassDef.bases = bases;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1179 p->v.ClassDef.keywords = keywords;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1180 p->v.ClassDef.starargs = starargs;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1181 p->v.ClassDef.kwargs = kwargs;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1182 p->v.ClassDef.body = body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1183 p->v.ClassDef.decorator_list = decorator_list;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1184 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1185 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1186 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1187 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1188
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1189 stmt_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1190 Return(expr_ty value, int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1191 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1192 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1193 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1194 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1195 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1196 p->kind = Return_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1197 p->v.Return.value = value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1198 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1199 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1200 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1201 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1202
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1203 stmt_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1204 Delete(asdl_seq * targets, int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1205 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1206 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1207 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1208 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1209 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1210 p->kind = Delete_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1211 p->v.Delete.targets = targets;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1212 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1213 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1214 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1215 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1216
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1217 stmt_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1218 Assign(asdl_seq * targets, expr_ty value, int lineno, int col_offset, PyArena
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1219 *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1220 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1221 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1222 if (!value) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1223 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1224 "field value is required for Assign");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1225 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1226 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1227 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1228 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1229 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1230 p->kind = Assign_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1231 p->v.Assign.targets = targets;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1232 p->v.Assign.value = value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1233 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1234 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1235 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1236 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1237
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1238 stmt_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1239 AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1240 col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1241 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1242 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1243 if (!target) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1244 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1245 "field target is required for AugAssign");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1246 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1247 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1248 if (!op) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1249 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1250 "field op is required for AugAssign");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1251 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1252 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1253 if (!value) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1254 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1255 "field value is required for AugAssign");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1256 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1257 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1258 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1259 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1260 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1261 p->kind = AugAssign_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1262 p->v.AugAssign.target = target;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1263 p->v.AugAssign.op = op;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1264 p->v.AugAssign.value = value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1265 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1266 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1267 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1268 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1269
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1270 stmt_ty
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1271 For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, int
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1272 lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1273 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1274 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1275 if (!target) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1276 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1277 "field target is required for For");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1278 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1279 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1280 if (!iter) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1281 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1282 "field iter is required for For");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1283 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1284 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1285 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1286 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1287 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1288 p->kind = For_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1289 p->v.For.target = target;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1290 p->v.For.iter = iter;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1291 p->v.For.body = body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1292 p->v.For.orelse = orelse;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1293 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1294 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1295 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1296 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1297
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1298 stmt_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1299 While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1300 col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1301 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1302 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1303 if (!test) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1304 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1305 "field test is required for While");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1306 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1307 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1308 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1309 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1310 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1311 p->kind = While_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1312 p->v.While.test = test;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1313 p->v.While.body = body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1314 p->v.While.orelse = orelse;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1315 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1316 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1317 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1318 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1319
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1320 stmt_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1321 If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1322 col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1323 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1324 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1325 if (!test) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1326 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1327 "field test is required for If");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1328 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1329 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1330 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1331 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1332 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1333 p->kind = If_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1334 p->v.If.test = test;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1335 p->v.If.body = body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1336 p->v.If.orelse = orelse;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1337 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1338 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1339 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1340 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1341
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1342 stmt_ty
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
1343 With(asdl_seq * items, asdl_seq * body, int lineno, int col_offset, PyArena
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
1344 *arena)
36695
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 36669
diff changeset
1345 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1346 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1347 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1348 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1349 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1350 p->kind = With_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1351 p->v.With.items = items;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1352 p->v.With.body = body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1353 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1354 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1355 return p;
36695
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 36669
diff changeset
1356 }
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 36669
diff changeset
1357
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 36669
diff changeset
1358 stmt_ty
43102
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42844
diff changeset
1359 Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1360 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1361 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1362 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1363 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1364 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1365 p->kind = Raise_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1366 p->v.Raise.exc = exc;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1367 p->v.Raise.cause = cause;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1368 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1369 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1370 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1371 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1372
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1373 stmt_ty
70499
e0e663132363 unify TryExcept and TryFinally (closes #12199)
Benjamin Peterson <benjamin@python.org>
parents: 70439
diff changeset
1374 Try(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, asdl_seq *
e0e663132363 unify TryExcept and TryFinally (closes #12199)
Benjamin Peterson <benjamin@python.org>
parents: 70439
diff changeset
1375 finalbody, int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1376 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1377 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1378 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1379 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1380 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1381 p->kind = Try_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1382 p->v.Try.body = body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1383 p->v.Try.handlers = handlers;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1384 p->v.Try.orelse = orelse;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1385 p->v.Try.finalbody = finalbody;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1386 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1387 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1388 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1389 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1390
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1391 stmt_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1392 Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1393 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1394 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1395 if (!test) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1396 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1397 "field test is required for Assert");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1398 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1399 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1400 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1401 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1402 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1403 p->kind = Assert_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1404 p->v.Assert.test = test;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1405 p->v.Assert.msg = msg;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1406 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1407 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1408 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1409 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1410
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1411 stmt_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1412 Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1413 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1414 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1415 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1416 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1417 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1418 p->kind = Import_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1419 p->v.Import.names = names;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1420 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1421 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1422 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1423 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1424
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1425 stmt_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1426 ImportFrom(identifier module, asdl_seq * names, int level, int lineno, int
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1427 col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1428 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1429 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1430 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1431 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1432 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1433 p->kind = ImportFrom_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1434 p->v.ImportFrom.module = module;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1435 p->v.ImportFrom.names = names;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1436 p->v.ImportFrom.level = level;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1437 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1438 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1439 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1440 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1441
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1442 stmt_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1443 Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1444 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1445 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1446 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1447 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1448 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1449 p->kind = Global_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1450 p->v.Global.names = names;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1451 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1452 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1453 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1454 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1455
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1456 stmt_ty
40965
30e5cb3a55ac Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 40941
diff changeset
1457 Nonlocal(asdl_seq * names, int lineno, int col_offset, PyArena *arena)
30e5cb3a55ac Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 40941
diff changeset
1458 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1459 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1460 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1461 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1462 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1463 p->kind = Nonlocal_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1464 p->v.Nonlocal.names = names;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1465 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1466 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1467 return p;
40965
30e5cb3a55ac Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 40941
diff changeset
1468 }
30e5cb3a55ac Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 40941
diff changeset
1469
30e5cb3a55ac Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 40941
diff changeset
1470 stmt_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1471 Expr(expr_ty value, int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1472 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1473 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1474 if (!value) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1475 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1476 "field value is required for Expr");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1477 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1478 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1479 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1480 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1481 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1482 p->kind = Expr_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1483 p->v.Expr.value = value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1484 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1485 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1486 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1487 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1488
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1489 stmt_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1490 Pass(int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1491 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1492 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1493 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1494 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1495 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1496 p->kind = Pass_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1497 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1498 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1499 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1500 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1501
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1502 stmt_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1503 Break(int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1504 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1505 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1506 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1507 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1508 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1509 p->kind = Break_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1510 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1511 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1512 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1513 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1514
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1515 stmt_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1516 Continue(int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1517 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1518 stmt_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1519 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1520 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1521 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1522 p->kind = Continue_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1523 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1524 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1525 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1526 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1527
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1528 expr_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1529 BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, PyArena
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1530 *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1531 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1532 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1533 if (!op) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1534 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1535 "field op is required for BoolOp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1536 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1537 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1538 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1539 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1540 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1541 p->kind = BoolOp_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1542 p->v.BoolOp.op = op;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1543 p->v.BoolOp.values = values;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1544 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1545 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1546 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1547 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1548
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1549 expr_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1550 BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int col_offset,
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1551 PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1552 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1553 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1554 if (!left) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1555 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1556 "field left is required for BinOp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1557 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1558 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1559 if (!op) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1560 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1561 "field op is required for BinOp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1562 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1563 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1564 if (!right) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1565 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1566 "field right is required for BinOp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1567 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1568 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1569 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1570 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1571 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1572 p->kind = BinOp_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1573 p->v.BinOp.left = left;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1574 p->v.BinOp.op = op;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1575 p->v.BinOp.right = right;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1576 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1577 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1578 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1579 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1580
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1581 expr_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1582 UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, PyArena
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1583 *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1584 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1585 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1586 if (!op) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1587 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1588 "field op is required for UnaryOp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1589 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1590 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1591 if (!operand) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1592 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1593 "field operand is required for UnaryOp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1594 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1595 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1596 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1597 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1598 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1599 p->kind = UnaryOp_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1600 p->v.UnaryOp.op = op;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1601 p->v.UnaryOp.operand = operand;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1602 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1603 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1604 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1605 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1606
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1607 expr_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1608 Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, PyArena
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1609 *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1610 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1611 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1612 if (!args) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1613 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1614 "field args is required for Lambda");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1615 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1616 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1617 if (!body) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1618 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1619 "field body is required for Lambda");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1620 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1621 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1622 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1623 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1624 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1625 p->kind = Lambda_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1626 p->v.Lambda.args = args;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1627 p->v.Lambda.body = body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1628 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1629 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1630 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1631 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1632
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1633 expr_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1634 IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int col_offset,
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1635 PyArena *arena)
36666
6165927431d6 PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents: 36665
diff changeset
1636 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1637 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1638 if (!test) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1639 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1640 "field test is required for IfExp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1641 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1642 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1643 if (!body) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1644 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1645 "field body is required for IfExp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1646 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1647 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1648 if (!orelse) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1649 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1650 "field orelse is required for IfExp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1651 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1652 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1653 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1654 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1655 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1656 p->kind = IfExp_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1657 p->v.IfExp.test = test;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1658 p->v.IfExp.body = body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1659 p->v.IfExp.orelse = orelse;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1660 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1661 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1662 return p;
36666
6165927431d6 PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents: 36665
diff changeset
1663 }
6165927431d6 PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents: 36665
diff changeset
1664
6165927431d6 PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents: 36665
diff changeset
1665 expr_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1666 Dict(asdl_seq * keys, asdl_seq * values, int lineno, int col_offset, PyArena
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1667 *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1668 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1669 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1670 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1671 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1672 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1673 p->kind = Dict_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1674 p->v.Dict.keys = keys;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1675 p->v.Dict.values = values;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1676 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1677 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1678 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1679 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1680
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1681 expr_ty
39693
d0b83c4630c0 SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents: 39691
diff changeset
1682 Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena)
d0b83c4630c0 SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents: 39691
diff changeset
1683 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1684 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1685 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1686 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1687 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1688 p->kind = Set_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1689 p->v.Set.elts = elts;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1690 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1691 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1692 return p;
39693
d0b83c4630c0 SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents: 39691
diff changeset
1693 }
d0b83c4630c0 SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents: 39691
diff changeset
1694
d0b83c4630c0 SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents: 39691
diff changeset
1695 expr_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1696 ListComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset,
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1697 PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1698 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1699 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1700 if (!elt) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1701 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1702 "field elt is required for ListComp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1703 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1704 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1705 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1706 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1707 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1708 p->kind = ListComp_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1709 p->v.ListComp.elt = elt;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1710 p->v.ListComp.generators = generators;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1711 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1712 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1713 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1714 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1715
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1716 expr_ty
41464
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 41227
diff changeset
1717 SetComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, PyArena
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 41227
diff changeset
1718 *arena)
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 41227
diff changeset
1719 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1720 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1721 if (!elt) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1722 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1723 "field elt is required for SetComp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1724 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1725 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1726 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1727 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1728 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1729 p->kind = SetComp_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1730 p->v.SetComp.elt = elt;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1731 p->v.SetComp.generators = generators;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1732 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1733 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1734 return p;
41464
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 41227
diff changeset
1735 }
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 41227
diff changeset
1736
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 41227
diff changeset
1737 expr_ty
42193
090588a17490 Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42013
diff changeset
1738 DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int lineno, int
090588a17490 Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42013
diff changeset
1739 col_offset, PyArena *arena)
090588a17490 Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42013
diff changeset
1740 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1741 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1742 if (!key) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1743 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1744 "field key is required for DictComp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1745 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1746 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1747 if (!value) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1748 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1749 "field value is required for DictComp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1750 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1751 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1752 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1753 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1754 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1755 p->kind = DictComp_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1756 p->v.DictComp.key = key;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1757 p->v.DictComp.value = value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1758 p->v.DictComp.generators = generators;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1759 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1760 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1761 return p;
42193
090588a17490 Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42013
diff changeset
1762 }
090588a17490 Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42013
diff changeset
1763
090588a17490 Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42013
diff changeset
1764 expr_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1765 GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset,
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1766 PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1767 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1768 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1769 if (!elt) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1770 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1771 "field elt is required for GeneratorExp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1772 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1773 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1774 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1775 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1776 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1777 p->kind = GeneratorExp_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1778 p->v.GeneratorExp.elt = elt;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1779 p->v.GeneratorExp.generators = generators;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1780 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1781 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1782 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1783 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1784
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1785 expr_ty
74391
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
1786 Yield(expr_ty value, int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1787 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1788 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1789 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1790 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1791 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1792 p->kind = Yield_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1793 p->v.Yield.value = value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1794 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1795 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1796 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1797 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1798
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1799 expr_ty
74391
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
1800 YieldFrom(expr_ty value, int lineno, int col_offset, PyArena *arena)
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
1801 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1802 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1803 if (!value) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1804 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1805 "field value is required for YieldFrom");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1806 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1807 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1808 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1809 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1810 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1811 p->kind = YieldFrom_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1812 p->v.YieldFrom.value = value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1813 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1814 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1815 return p;
74391
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
1816 }
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
1817
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
1818 expr_ty
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36794
diff changeset
1819 Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int lineno,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36794
diff changeset
1820 int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1821 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1822 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1823 if (!left) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1824 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1825 "field left is required for Compare");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1826 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1827 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1828 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1829 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1830 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1831 p->kind = Compare_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1832 p->v.Compare.left = left;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1833 p->v.Compare.ops = ops;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1834 p->v.Compare.comparators = comparators;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1835 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1836 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1837 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1838 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1839
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1840 expr_ty
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1841 Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs,
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1842 expr_ty kwargs, int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1843 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1844 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1845 if (!func) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1846 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1847 "field func is required for Call");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1848 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1849 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1850 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1851 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1852 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1853 p->kind = Call_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1854 p->v.Call.func = func;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1855 p->v.Call.args = args;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1856 p->v.Call.keywords = keywords;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1857 p->v.Call.starargs = starargs;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1858 p->v.Call.kwargs = kwargs;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1859 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1860 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1861 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1862 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1863
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1864 expr_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1865 Num(object n, int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1866 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1867 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1868 if (!n) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1869 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1870 "field n is required for Num");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1871 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1872 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1873 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1874 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1875 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1876 p->kind = Num_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1877 p->v.Num.n = n;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1878 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1879 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1880 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1881 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1882
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1883 expr_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1884 Str(string s, int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1885 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1886 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1887 if (!s) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1888 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1889 "field s is required for Str");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1890 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1891 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1892 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1893 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1894 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1895 p->kind = Str_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1896 p->v.Str.s = s;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1897 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1898 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1899 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1900 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1901
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1902 expr_ty
71792
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
1903 Bytes(bytes s, int lineno, int col_offset, PyArena *arena)
40894
0ea24f4f2467 Bytes literal.
Thomas Wouters <thomas@python.org>
parents: 40893
diff changeset
1904 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1905 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1906 if (!s) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1907 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1908 "field s is required for Bytes");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1909 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1910 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1911 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1912 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1913 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1914 p->kind = Bytes_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1915 p->v.Bytes.s = s;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1916 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1917 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1918 return p;
40894
0ea24f4f2467 Bytes literal.
Thomas Wouters <thomas@python.org>
parents: 40893
diff changeset
1919 }
0ea24f4f2467 Bytes literal.
Thomas Wouters <thomas@python.org>
parents: 40893
diff changeset
1920
0ea24f4f2467 Bytes literal.
Thomas Wouters <thomas@python.org>
parents: 40893
diff changeset
1921 expr_ty
39783
7a0ad110e91e Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents: 39782
diff changeset
1922 Ellipsis(int lineno, int col_offset, PyArena *arena)
7a0ad110e91e Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents: 39782
diff changeset
1923 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1924 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1925 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1926 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1927 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1928 p->kind = Ellipsis_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1929 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1930 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1931 return p;
39783
7a0ad110e91e Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents: 39782
diff changeset
1932 }
7a0ad110e91e Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents: 39782
diff changeset
1933
7a0ad110e91e Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents: 39782
diff changeset
1934 expr_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1935 Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, int
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1936 col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1937 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1938 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1939 if (!value) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1940 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1941 "field value is required for Attribute");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1942 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1943 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1944 if (!attr) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1945 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1946 "field attr is required for Attribute");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1947 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1948 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1949 if (!ctx) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1950 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1951 "field ctx is required for Attribute");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1952 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1953 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1954 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1955 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1956 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1957 p->kind = Attribute_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1958 p->v.Attribute.value = value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1959 p->v.Attribute.attr = attr;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1960 p->v.Attribute.ctx = ctx;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1961 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1962 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1963 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1964 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1965
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1966 expr_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1967 Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int lineno, int
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1968 col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1969 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1970 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1971 if (!value) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1972 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1973 "field value is required for Subscript");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1974 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1975 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1976 if (!slice) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1977 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1978 "field slice is required for Subscript");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1979 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1980 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1981 if (!ctx) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1982 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1983 "field ctx is required for Subscript");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1984 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1985 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1986 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1987 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1988 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1989 p->kind = Subscript_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1990 p->v.Subscript.value = value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1991 p->v.Subscript.slice = slice;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1992 p->v.Subscript.ctx = ctx;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1993 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1994 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1995 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1996 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1997
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1998 expr_ty
41699
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
1999 Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset, PyArena
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
2000 *arena)
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
2001 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2002 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2003 if (!value) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2004 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2005 "field value is required for Starred");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2006 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2007 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2008 if (!ctx) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2009 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2010 "field ctx is required for Starred");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2011 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2012 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2013 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2014 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2015 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2016 p->kind = Starred_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2017 p->v.Starred.value = value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2018 p->v.Starred.ctx = ctx;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2019 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2020 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2021 return p;
41699
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
2022 }
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
2023
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
2024 expr_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
2025 Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, PyArena
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
2026 *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2027 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2028 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2029 if (!id) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2030 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2031 "field id is required for Name");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2032 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2033 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2034 if (!ctx) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2035 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2036 "field ctx is required for Name");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2037 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2038 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2039 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2040 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2041 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2042 p->kind = Name_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2043 p->v.Name.id = id;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2044 p->v.Name.ctx = ctx;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2045 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2046 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2047 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2048 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2049
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2050 expr_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
2051 List(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
2052 *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2053 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2054 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2055 if (!ctx) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2056 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2057 "field ctx is required for List");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2058 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2059 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2060 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2061 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2062 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2063 p->kind = List_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2064 p->v.List.elts = elts;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2065 p->v.List.ctx = ctx;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2066 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2067 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2068 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2069 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2070
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2071 expr_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
2072 Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
2073 *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2074 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2075 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2076 if (!ctx) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2077 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2078 "field ctx is required for Tuple");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2079 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2080 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2081 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2082 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2083 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2084 p->kind = Tuple_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2085 p->v.Tuple.elts = elts;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2086 p->v.Tuple.ctx = ctx;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2087 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2088 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2089 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2090 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2091
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2092 slice_ty
36065
ea083efdc96c Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents: 36003
diff changeset
2093 Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2094 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2095 slice_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2096 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2097 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2098 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2099 p->kind = Slice_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2100 p->v.Slice.lower = lower;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2101 p->v.Slice.upper = upper;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2102 p->v.Slice.step = step;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2103 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2104 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2105
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2106 slice_ty
36065
ea083efdc96c Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents: 36003
diff changeset
2107 ExtSlice(asdl_seq * dims, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2108 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2109 slice_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2110 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2111 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2112 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2113 p->kind = ExtSlice_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2114 p->v.ExtSlice.dims = dims;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2115 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2116 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2117
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2118 slice_ty
36065
ea083efdc96c Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents: 36003
diff changeset
2119 Index(expr_ty value, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2120 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2121 slice_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2122 if (!value) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2123 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2124 "field value is required for Index");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2125 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2126 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2127 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2128 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2129 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2130 p->kind = Index_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2131 p->v.Index.value = value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2132 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2133 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2134
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2135 comprehension_ty
36065
ea083efdc96c Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents: 36003
diff changeset
2136 comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2137 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2138 comprehension_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2139 if (!target) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2140 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2141 "field target is required for comprehension");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2142 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2143 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2144 if (!iter) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2145 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2146 "field iter is required for comprehension");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2147 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2148 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2149 p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2150 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2151 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2152 p->target = target;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2153 p->iter = iter;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2154 p->ifs = ifs;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2155 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2156 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2157
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2158 excepthandler_ty
46231
81ee270a6eb5 Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46229
diff changeset
2159 ExceptHandler(expr_ty type, identifier name, asdl_seq * body, int lineno, int
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36794
diff changeset
2160 col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2161 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2162 excepthandler_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2163 p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2164 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2165 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2166 p->kind = ExceptHandler_kind;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2167 p->v.ExceptHandler.type = type;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2168 p->v.ExceptHandler.name = name;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2169 p->v.ExceptHandler.body = body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2170 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2171 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2172 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2173 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2174
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2175 arguments_ty
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
2176 arguments(asdl_seq * args, identifier vararg, expr_ty varargannotation,
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
2177 asdl_seq * kwonlyargs, identifier kwarg, expr_ty kwargannotation,
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
2178 asdl_seq * defaults, asdl_seq * kw_defaults, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2179 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2180 arguments_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2181 p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2182 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2183 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2184 p->args = args;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2185 p->vararg = vararg;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2186 p->varargannotation = varargannotation;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2187 p->kwonlyargs = kwonlyargs;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2188 p->kwarg = kwarg;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2189 p->kwargannotation = kwargannotation;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2190 p->defaults = defaults;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2191 p->kw_defaults = kw_defaults;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2192 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2193 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2194
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
2195 arg_ty
41717
9ad84070b22d Merged revisions 55328-55341 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41699
diff changeset
2196 arg(identifier arg, expr_ty annotation, PyArena *arena)
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
2197 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2198 arg_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2199 if (!arg) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2200 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2201 "field arg is required for arg");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2202 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2203 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2204 p = (arg_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2205 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2206 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2207 p->arg = arg;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2208 p->annotation = annotation;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2209 return p;
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
2210 }
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
2211
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2212 keyword_ty
36065
ea083efdc96c Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents: 36003
diff changeset
2213 keyword(identifier arg, expr_ty value, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2214 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2215 keyword_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2216 if (!arg) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2217 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2218 "field arg is required for keyword");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2219 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2220 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2221 if (!value) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2222 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2223 "field value is required for keyword");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2224 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2225 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2226 p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2227 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2228 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2229 p->arg = arg;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2230 p->value = value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2231 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2232 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2233
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2234 alias_ty
36065
ea083efdc96c Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents: 36003
diff changeset
2235 alias(identifier name, identifier asname, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2236 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2237 alias_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2238 if (!name) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2239 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2240 "field name is required for alias");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2241 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2242 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2243 p = (alias_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2244 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2245 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2246 p->name = name;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2247 p->asname = asname;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2248 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2249 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2250
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
2251 withitem_ty
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
2252 withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
2253 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2254 withitem_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2255 if (!context_expr) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2256 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2257 "field context_expr is required for withitem");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2258 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2259 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2260 p = (withitem_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2261 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2262 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2263 p->context_expr = context_expr;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2264 p->optional_vars = optional_vars;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2265 return p;
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
2266 }
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
2267
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
2268
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2269 PyObject*
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2270 ast2obj_mod(void* _o)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2271 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2272 mod_ty o = (mod_ty)_o;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2273 PyObject *result = NULL, *value = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2274 if (!o) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2275 Py_INCREF(Py_None);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2276 return Py_None;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2277 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2278
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2279 switch (o->kind) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2280 case Module_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2281 result = PyType_GenericNew(Module_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2282 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2283 value = ast2obj_list(o->v.Module.body, ast2obj_stmt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2284 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2285 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2286 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2287 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2288 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2289 case Interactive_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2290 result = PyType_GenericNew(Interactive_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2291 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2292 value = ast2obj_list(o->v.Interactive.body, ast2obj_stmt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2293 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2294 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2295 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2296 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2297 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2298 case Expression_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2299 result = PyType_GenericNew(Expression_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2300 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2301 value = ast2obj_expr(o->v.Expression.body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2302 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2303 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2304 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2305 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2306 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2307 case Suite_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2308 result = PyType_GenericNew(Suite_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2309 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2310 value = ast2obj_list(o->v.Suite.body, ast2obj_stmt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2311 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2312 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2313 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2314 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2315 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2316 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2317 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2318 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2319 Py_XDECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2320 Py_XDECREF(result);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2321 return NULL;
36174
85b2d804ac0a Regenerate.
Martin v. Löwis <martin@v.loewis.de>
parents: 36065
diff changeset
2322 }
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
2323
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2324 PyObject*
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2325 ast2obj_stmt(void* _o)
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
2326 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2327 stmt_ty o = (stmt_ty)_o;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2328 PyObject *result = NULL, *value = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2329 if (!o) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2330 Py_INCREF(Py_None);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2331 return Py_None;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2332 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2333
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2334 switch (o->kind) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2335 case FunctionDef_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2336 result = PyType_GenericNew(FunctionDef_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2337 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2338 value = ast2obj_identifier(o->v.FunctionDef.name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2339 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2340 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2341 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2342 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2343 value = ast2obj_arguments(o->v.FunctionDef.args);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2344 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2345 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2346 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2347 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2348 value = ast2obj_list(o->v.FunctionDef.body, ast2obj_stmt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2349 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2350 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2351 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2352 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2353 value = ast2obj_list(o->v.FunctionDef.decorator_list, ast2obj_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2354 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2355 if (_PyObject_SetAttrId(result, &PyId_decorator_list, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2356 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2357 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2358 value = ast2obj_expr(o->v.FunctionDef.returns);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2359 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2360 if (_PyObject_SetAttrId(result, &PyId_returns, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2361 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2362 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2363 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2364 case ClassDef_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2365 result = PyType_GenericNew(ClassDef_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2366 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2367 value = ast2obj_identifier(o->v.ClassDef.name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2368 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2369 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2370 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2371 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2372 value = ast2obj_list(o->v.ClassDef.bases, ast2obj_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2373 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2374 if (_PyObject_SetAttrId(result, &PyId_bases, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2375 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2376 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2377 value = ast2obj_list(o->v.ClassDef.keywords, ast2obj_keyword);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2378 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2379 if (_PyObject_SetAttrId(result, &PyId_keywords, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2380 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2381 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2382 value = ast2obj_expr(o->v.ClassDef.starargs);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2383 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2384 if (_PyObject_SetAttrId(result, &PyId_starargs, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2385 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2386 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2387 value = ast2obj_expr(o->v.ClassDef.kwargs);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2388 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2389 if (_PyObject_SetAttrId(result, &PyId_kwargs, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2390 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2391 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2392 value = ast2obj_list(o->v.ClassDef.body, ast2obj_stmt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2393 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2394 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2395 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2396 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2397 value = ast2obj_list(o->v.ClassDef.decorator_list, ast2obj_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2398 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2399 if (_PyObject_SetAttrId(result, &PyId_decorator_list, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2400 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2401 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2402 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2403 case Return_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2404 result = PyType_GenericNew(Return_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2405 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2406 value = ast2obj_expr(o->v.Return.value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2407 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2408 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2409 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2410 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2411 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2412 case Delete_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2413 result = PyType_GenericNew(Delete_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2414 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2415 value = ast2obj_list(o->v.Delete.targets, ast2obj_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2416 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2417 if (_PyObject_SetAttrId(result, &PyId_targets, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2418 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2419 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2420 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2421 case Assign_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2422 result = PyType_GenericNew(Assign_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2423 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2424 value = ast2obj_list(o->v.Assign.targets, ast2obj_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2425 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2426 if (_PyObject_SetAttrId(result, &PyId_targets, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2427 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2428 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2429 value = ast2obj_expr(o->v.Assign.value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2430 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2431 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2432 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2433 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2434 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2435 case AugAssign_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2436 result = PyType_GenericNew(AugAssign_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2437 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2438 value = ast2obj_expr(o->v.AugAssign.target);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2439 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2440 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2441 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2442 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2443 value = ast2obj_operator(o->v.AugAssign.op);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2444 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2445 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2446 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2447 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2448 value = ast2obj_expr(o->v.AugAssign.value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2449 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2450 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2451 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2452 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2453 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2454 case For_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2455 result = PyType_GenericNew(For_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2456 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2457 value = ast2obj_expr(o->v.For.target);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2458 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2459 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2460 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2461 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2462 value = ast2obj_expr(o->v.For.iter);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2463 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2464 if (_PyObject_SetAttrId(result, &PyId_iter, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2465 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2466 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2467 value = ast2obj_list(o->v.For.body, ast2obj_stmt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2468 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2469 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2470 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2471 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2472 value = ast2obj_list(o->v.For.orelse, ast2obj_stmt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2473 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2474 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2475 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2476 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2477 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2478 case While_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2479 result = PyType_GenericNew(While_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2480 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2481 value = ast2obj_expr(o->v.While.test);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2482 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2483 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2484 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2485 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2486 value = ast2obj_list(o->v.While.body, ast2obj_stmt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2487 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2488 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2489 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2490 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2491 value = ast2obj_list(o->v.While.orelse, ast2obj_stmt);
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
2492 if (!value) goto failed;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2493 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2494 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2495 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2496 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2497 case If_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2498 result = PyType_GenericNew(If_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2499 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2500 value = ast2obj_expr(o->v.If.test);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2501 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2502 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2503 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2504 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2505 value = ast2obj_list(o->v.If.body, ast2obj_stmt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2506 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2507 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2508 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2509 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2510 value = ast2obj_list(o->v.If.orelse, ast2obj_stmt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2511 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2512 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2513 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2514 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2515 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2516 case With_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2517 result = PyType_GenericNew(With_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2518 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2519 value = ast2obj_list(o->v.With.items, ast2obj_withitem);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2520 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2521 if (_PyObject_SetAttrId(result, &PyId_items, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2522 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2523 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2524 value = ast2obj_list(o->v.With.body, ast2obj_stmt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2525 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2526 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2527 goto failed;
36794
df843b07f5fe Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36786
diff changeset
2528 Py_DECREF(value);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2529 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2530 case Raise_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2531 result = PyType_GenericNew(Raise_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2532 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2533 value = ast2obj_expr(o->v.Raise.exc);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2534 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2535 if (_PyObject_SetAttrId(result, &PyId_exc, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2536 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2537 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2538 value = ast2obj_expr(o->v.Raise.cause);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2539 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2540 if (_PyObject_SetAttrId(result, &PyId_cause, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2541 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2542 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2543 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2544 case Try_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2545 result = PyType_GenericNew(Try_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2546 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2547 value = ast2obj_list(o->v.Try.body, ast2obj_stmt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2548 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2549 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2550 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2551 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2552 value = ast2obj_list(o->v.Try.handlers, ast2obj_excepthandler);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2553 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2554 if (_PyObject_SetAttrId(result, &PyId_handlers, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2555 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2556 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2557 value = ast2obj_list(o->v.Try.orelse, ast2obj_stmt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2558 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2559 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2560 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2561 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2562 value = ast2obj_list(o->v.Try.finalbody, ast2obj_stmt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2563 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2564 if (_PyObject_SetAttrId(result, &PyId_finalbody, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2565 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2566 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2567 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2568 case Assert_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2569 result = PyType_GenericNew(Assert_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2570 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2571 value = ast2obj_expr(o->v.Assert.test);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2572 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2573 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2574 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2575 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2576 value = ast2obj_expr(o->v.Assert.msg);
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
2577 if (!value) goto failed;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2578 if (_PyObject_SetAttrId(result, &PyId_msg, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2579 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2580 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2581 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2582 case Import_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2583 result = PyType_GenericNew(Import_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2584 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2585 value = ast2obj_list(o->v.Import.names, ast2obj_alias);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2586 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2587 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2588 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2589 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2590 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2591 case ImportFrom_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2592 result = PyType_GenericNew(ImportFrom_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2593 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2594 value = ast2obj_identifier(o->v.ImportFrom.module);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2595 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2596 if (_PyObject_SetAttrId(result, &PyId_module, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2597 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2598 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2599 value = ast2obj_list(o->v.ImportFrom.names, ast2obj_alias);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2600 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2601 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2602 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2603 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2604 value = ast2obj_int(o->v.ImportFrom.level);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2605 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2606 if (_PyObject_SetAttrId(result, &PyId_level, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2607 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2608 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2609 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2610 case Global_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2611 result = PyType_GenericNew(Global_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2612 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2613 value = ast2obj_list(o->v.Global.names, ast2obj_identifier);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2614 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2615 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2616 goto failed;
36794
df843b07f5fe Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36786
diff changeset
2617 Py_DECREF(value);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2618 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2619 case Nonlocal_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2620 result = PyType_GenericNew(Nonlocal_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2621 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2622 value = ast2obj_list(o->v.Nonlocal.names, ast2obj_identifier);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2623 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2624 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2625 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2626 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2627 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2628 case Expr_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2629 result = PyType_GenericNew(Expr_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2630 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2631 value = ast2obj_expr(o->v.Expr.value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2632 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2633 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2634 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2635 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2636 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2637 case Pass_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2638 result = PyType_GenericNew(Pass_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2639 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2640 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2641 case Break_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2642 result = PyType_GenericNew(Break_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2643 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2644 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2645 case Continue_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2646 result = PyType_GenericNew(Continue_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2647 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2648 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2649 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2650 value = ast2obj_int(o->lineno);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2651 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2652 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2653 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2654 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2655 value = ast2obj_int(o->col_offset);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2656 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2657 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2658 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2659 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2660 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2661 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2662 Py_XDECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2663 Py_XDECREF(result);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2664 return NULL;
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
2665 }
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
2666
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2667 PyObject*
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2668 ast2obj_expr(void* _o)
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
2669 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2670 expr_ty o = (expr_ty)_o;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2671 PyObject *result = NULL, *value = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2672 if (!o) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2673 Py_INCREF(Py_None);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2674 return Py_None;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2675 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2676
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2677 switch (o->kind) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2678 case BoolOp_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2679 result = PyType_GenericNew(BoolOp_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2680 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2681 value = ast2obj_boolop(o->v.BoolOp.op);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2682 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2683 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2684 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2685 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2686 value = ast2obj_list(o->v.BoolOp.values, ast2obj_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2687 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2688 if (_PyObject_SetAttrId(result, &PyId_values, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2689 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2690 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2691 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2692 case BinOp_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2693 result = PyType_GenericNew(BinOp_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2694 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2695 value = ast2obj_expr(o->v.BinOp.left);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2696 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2697 if (_PyObject_SetAttrId(result, &PyId_left, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2698 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2699 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2700 value = ast2obj_operator(o->v.BinOp.op);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2701 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2702 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2703 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2704 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2705 value = ast2obj_expr(o->v.BinOp.right);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2706 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2707 if (_PyObject_SetAttrId(result, &PyId_right, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2708 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2709 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2710 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2711 case UnaryOp_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2712 result = PyType_GenericNew(UnaryOp_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2713 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2714 value = ast2obj_unaryop(o->v.UnaryOp.op);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2715 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2716 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2717 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2718 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2719 value = ast2obj_expr(o->v.UnaryOp.operand);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2720 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2721 if (_PyObject_SetAttrId(result, &PyId_operand, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2722 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2723 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2724 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2725 case Lambda_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2726 result = PyType_GenericNew(Lambda_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2727 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2728 value = ast2obj_arguments(o->v.Lambda.args);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2729 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2730 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2731 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2732 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2733 value = ast2obj_expr(o->v.Lambda.body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2734 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2735 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2736 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2737 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2738 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2739 case IfExp_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2740 result = PyType_GenericNew(IfExp_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2741 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2742 value = ast2obj_expr(o->v.IfExp.test);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2743 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2744 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2745 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2746 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2747 value = ast2obj_expr(o->v.IfExp.body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2748 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2749 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2750 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2751 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2752 value = ast2obj_expr(o->v.IfExp.orelse);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2753 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2754 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2755 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2756 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2757 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2758 case Dict_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2759 result = PyType_GenericNew(Dict_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2760 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2761 value = ast2obj_list(o->v.Dict.keys, ast2obj_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2762 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2763 if (_PyObject_SetAttrId(result, &PyId_keys, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2764 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2765 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2766 value = ast2obj_list(o->v.Dict.values, ast2obj_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2767 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2768 if (_PyObject_SetAttrId(result, &PyId_values, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2769 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2770 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2771 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2772 case Set_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2773 result = PyType_GenericNew(Set_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2774 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2775 value = ast2obj_list(o->v.Set.elts, ast2obj_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2776 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2777 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2778 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2779 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2780 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2781 case ListComp_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2782 result = PyType_GenericNew(ListComp_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2783 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2784 value = ast2obj_expr(o->v.ListComp.elt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2785 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2786 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2787 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2788 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2789 value = ast2obj_list(o->v.ListComp.generators, ast2obj_comprehension);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2790 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2791 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2792 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2793 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2794 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2795 case SetComp_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2796 result = PyType_GenericNew(SetComp_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2797 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2798 value = ast2obj_expr(o->v.SetComp.elt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2799 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2800 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2801 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2802 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2803 value = ast2obj_list(o->v.SetComp.generators, ast2obj_comprehension);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2804 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2805 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2806 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2807 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2808 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2809 case DictComp_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2810 result = PyType_GenericNew(DictComp_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2811 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2812 value = ast2obj_expr(o->v.DictComp.key);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2813 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2814 if (_PyObject_SetAttrId(result, &PyId_key, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2815 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2816 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2817 value = ast2obj_expr(o->v.DictComp.value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2818 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2819 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2820 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2821 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2822 value = ast2obj_list(o->v.DictComp.generators, ast2obj_comprehension);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2823 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2824 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2825 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2826 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2827 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2828 case GeneratorExp_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2829 result = PyType_GenericNew(GeneratorExp_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2830 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2831 value = ast2obj_expr(o->v.GeneratorExp.elt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2832 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2833 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2834 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2835 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2836 value = ast2obj_list(o->v.GeneratorExp.generators,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2837 ast2obj_comprehension);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2838 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2839 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2840 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2841 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2842 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2843 case Yield_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2844 result = PyType_GenericNew(Yield_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2845 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2846 value = ast2obj_expr(o->v.Yield.value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2847 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2848 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2849 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2850 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2851 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2852 case YieldFrom_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2853 result = PyType_GenericNew(YieldFrom_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2854 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2855 value = ast2obj_expr(o->v.YieldFrom.value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2856 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2857 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2858 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2859 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2860 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2861 case Compare_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2862 result = PyType_GenericNew(Compare_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2863 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2864 value = ast2obj_expr(o->v.Compare.left);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2865 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2866 if (_PyObject_SetAttrId(result, &PyId_left, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2867 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2868 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2869 {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2870 Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2871 value = PyList_New(n);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2872 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2873 for(i = 0; i < n; i++)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2874 PyList_SET_ITEM(value, i, ast2obj_cmpop((cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2875 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2876 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2877 if (_PyObject_SetAttrId(result, &PyId_ops, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2878 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2879 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2880 value = ast2obj_list(o->v.Compare.comparators, ast2obj_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2881 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2882 if (_PyObject_SetAttrId(result, &PyId_comparators, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2883 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2884 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2885 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2886 case Call_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2887 result = PyType_GenericNew(Call_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2888 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2889 value = ast2obj_expr(o->v.Call.func);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2890 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2891 if (_PyObject_SetAttrId(result, &PyId_func, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2892 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2893 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2894 value = ast2obj_list(o->v.Call.args, ast2obj_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2895 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2896 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2897 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2898 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2899 value = ast2obj_list(o->v.Call.keywords, ast2obj_keyword);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2900 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2901 if (_PyObject_SetAttrId(result, &PyId_keywords, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2902 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2903 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2904 value = ast2obj_expr(o->v.Call.starargs);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2905 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2906 if (_PyObject_SetAttrId(result, &PyId_starargs, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2907 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2908 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2909 value = ast2obj_expr(o->v.Call.kwargs);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2910 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2911 if (_PyObject_SetAttrId(result, &PyId_kwargs, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2912 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2913 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2914 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2915 case Num_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2916 result = PyType_GenericNew(Num_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2917 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2918 value = ast2obj_object(o->v.Num.n);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2919 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2920 if (_PyObject_SetAttrId(result, &PyId_n, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2921 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2922 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2923 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2924 case Str_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2925 result = PyType_GenericNew(Str_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2926 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2927 value = ast2obj_string(o->v.Str.s);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2928 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2929 if (_PyObject_SetAttrId(result, &PyId_s, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2930 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2931 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2932 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2933 case Bytes_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2934 result = PyType_GenericNew(Bytes_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2935 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2936 value = ast2obj_bytes(o->v.Bytes.s);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2937 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2938 if (_PyObject_SetAttrId(result, &PyId_s, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2939 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2940 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2941 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2942 case Ellipsis_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2943 result = PyType_GenericNew(Ellipsis_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2944 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2945 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2946 case Attribute_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2947 result = PyType_GenericNew(Attribute_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2948 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2949 value = ast2obj_expr(o->v.Attribute.value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2950 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2951 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2952 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2953 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2954 value = ast2obj_identifier(o->v.Attribute.attr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2955 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2956 if (_PyObject_SetAttrId(result, &PyId_attr, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2957 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2958 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2959 value = ast2obj_expr_context(o->v.Attribute.ctx);
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
2960 if (!value) goto failed;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2961 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2962 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2963 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2964 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2965 case Subscript_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2966 result = PyType_GenericNew(Subscript_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2967 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2968 value = ast2obj_expr(o->v.Subscript.value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2969 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2970 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2971 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2972 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2973 value = ast2obj_slice(o->v.Subscript.slice);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2974 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2975 if (_PyObject_SetAttrId(result, &PyId_slice, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2976 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2977 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2978 value = ast2obj_expr_context(o->v.Subscript.ctx);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2979 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2980 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2981 goto failed;
36794
df843b07f5fe Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36786
diff changeset
2982 Py_DECREF(value);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2983 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2984 case Starred_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2985 result = PyType_GenericNew(Starred_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2986 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2987 value = ast2obj_expr(o->v.Starred.value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2988 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2989 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2990 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2991 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2992 value = ast2obj_expr_context(o->v.Starred.ctx);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2993 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2994 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2995 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2996 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2997 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2998 case Name_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2999 result = PyType_GenericNew(Name_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3000 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3001 value = ast2obj_identifier(o->v.Name.id);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3002 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3003 if (_PyObject_SetAttrId(result, &PyId_id, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3004 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3005 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3006 value = ast2obj_expr_context(o->v.Name.ctx);
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
3007 if (!value) goto failed;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3008 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3009 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3010 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3011 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3012 case List_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3013 result = PyType_GenericNew(List_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3014 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3015 value = ast2obj_list(o->v.List.elts, ast2obj_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3016 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3017 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3018 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3019 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3020 value = ast2obj_expr_context(o->v.List.ctx);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3021 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3022 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3023 goto failed;
36794
df843b07f5fe Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36786
diff changeset
3024 Py_DECREF(value);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3025 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3026 case Tuple_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3027 result = PyType_GenericNew(Tuple_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3028 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3029 value = ast2obj_list(o->v.Tuple.elts, ast2obj_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3030 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3031 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3032 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3033 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3034 value = ast2obj_expr_context(o->v.Tuple.ctx);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3035 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3036 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3037 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3038 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3039 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3040 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3041 value = ast2obj_int(o->lineno);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3042 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3043 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3044 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3045 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3046 value = ast2obj_int(o->col_offset);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3047 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3048 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3049 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3050 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3051 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3052 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3053 Py_XDECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3054 Py_XDECREF(result);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3055 return NULL;
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3056 }
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3057
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3058 PyObject* ast2obj_expr_context(expr_context_ty o)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3059 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3060 switch(o) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3061 case Load:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3062 Py_INCREF(Load_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3063 return Load_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3064 case Store:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3065 Py_INCREF(Store_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3066 return Store_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3067 case Del:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3068 Py_INCREF(Del_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3069 return Del_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3070 case AugLoad:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3071 Py_INCREF(AugLoad_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3072 return AugLoad_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3073 case AugStore:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3074 Py_INCREF(AugStore_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3075 return AugStore_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3076 case Param:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3077 Py_INCREF(Param_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3078 return Param_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3079 default:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3080 /* should never happen, but just in case ... */
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3081 PyErr_Format(PyExc_SystemError, "unknown expr_context found");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3082 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3083 }
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3084 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3085 PyObject*
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3086 ast2obj_slice(void* _o)
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3087 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3088 slice_ty o = (slice_ty)_o;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3089 PyObject *result = NULL, *value = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3090 if (!o) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3091 Py_INCREF(Py_None);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3092 return Py_None;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3093 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3094
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3095 switch (o->kind) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3096 case Slice_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3097 result = PyType_GenericNew(Slice_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3098 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3099 value = ast2obj_expr(o->v.Slice.lower);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3100 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3101 if (_PyObject_SetAttrId(result, &PyId_lower, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3102 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3103 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3104 value = ast2obj_expr(o->v.Slice.upper);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3105 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3106 if (_PyObject_SetAttrId(result, &PyId_upper, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3107 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3108 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3109 value = ast2obj_expr(o->v.Slice.step);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3110 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3111 if (_PyObject_SetAttrId(result, &PyId_step, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3112 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3113 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3114 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3115 case ExtSlice_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3116 result = PyType_GenericNew(ExtSlice_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3117 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3118 value = ast2obj_list(o->v.ExtSlice.dims, ast2obj_slice);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3119 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3120 if (_PyObject_SetAttrId(result, &PyId_dims, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3121 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3122 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3123 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3124 case Index_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3125 result = PyType_GenericNew(Index_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3126 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3127 value = ast2obj_expr(o->v.Index.value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3128 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3129 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3130 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3131 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3132 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3133 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3134 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3135 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3136 Py_XDECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3137 Py_XDECREF(result);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3138 return NULL;
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3139 }
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3140
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3141 PyObject* ast2obj_boolop(boolop_ty o)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3142 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3143 switch(o) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3144 case And:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3145 Py_INCREF(And_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3146 return And_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3147 case Or:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3148 Py_INCREF(Or_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3149 return Or_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3150 default:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3151 /* should never happen, but just in case ... */
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3152 PyErr_Format(PyExc_SystemError, "unknown boolop found");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3153 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3154 }
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3155 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3156 PyObject* ast2obj_operator(operator_ty o)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3157 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3158 switch(o) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3159 case Add:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3160 Py_INCREF(Add_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3161 return Add_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3162 case Sub:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3163 Py_INCREF(Sub_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3164 return Sub_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3165 case Mult:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3166 Py_INCREF(Mult_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3167 return Mult_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3168 case Div:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3169 Py_INCREF(Div_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3170 return Div_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3171 case Mod:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3172 Py_INCREF(Mod_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3173 return Mod_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3174 case Pow:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3175 Py_INCREF(Pow_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3176 return Pow_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3177 case LShift:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3178 Py_INCREF(LShift_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3179 return LShift_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3180 case RShift:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3181 Py_INCREF(RShift_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3182 return RShift_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3183 case BitOr:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3184 Py_INCREF(BitOr_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3185 return BitOr_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3186 case BitXor:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3187 Py_INCREF(BitXor_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3188 return BitXor_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3189 case BitAnd:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3190 Py_INCREF(BitAnd_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3191 return BitAnd_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3192 case FloorDiv:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3193 Py_INCREF(FloorDiv_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3194 return FloorDiv_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3195 default:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3196 /* should never happen, but just in case ... */
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3197 PyErr_Format(PyExc_SystemError, "unknown operator found");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3198 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3199 }
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3200 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3201 PyObject* ast2obj_unaryop(unaryop_ty o)
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3202 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3203 switch(o) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3204 case Invert:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3205 Py_INCREF(Invert_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3206 return Invert_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3207 case Not:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3208 Py_INCREF(Not_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3209 return Not_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3210 case UAdd:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3211 Py_INCREF(UAdd_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3212 return UAdd_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3213 case USub:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3214 Py_INCREF(USub_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3215 return USub_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3216 default:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3217 /* should never happen, but just in case ... */
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3218 PyErr_Format(PyExc_SystemError, "unknown unaryop found");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3219 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3220 }
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3221 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3222 PyObject* ast2obj_cmpop(cmpop_ty o)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3223 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3224 switch(o) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3225 case Eq:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3226 Py_INCREF(Eq_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3227 return Eq_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3228 case NotEq:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3229 Py_INCREF(NotEq_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3230 return NotEq_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3231 case Lt:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3232 Py_INCREF(Lt_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3233 return Lt_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3234 case LtE:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3235 Py_INCREF(LtE_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3236 return LtE_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3237 case Gt:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3238 Py_INCREF(Gt_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3239 return Gt_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3240 case GtE:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3241 Py_INCREF(GtE_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3242 return GtE_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3243 case Is:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3244 Py_INCREF(Is_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3245 return Is_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3246 case IsNot:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3247 Py_INCREF(IsNot_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3248 return IsNot_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3249 case In:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3250 Py_INCREF(In_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3251 return In_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3252 case NotIn:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3253 Py_INCREF(NotIn_singleton);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3254 return NotIn_singleton;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3255 default:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3256 /* should never happen, but just in case ... */
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3257 PyErr_Format(PyExc_SystemError, "unknown cmpop found");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3258 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3259 }
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3260 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3261 PyObject*
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3262 ast2obj_comprehension(void* _o)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3263 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3264 comprehension_ty o = (comprehension_ty)_o;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3265 PyObject *result = NULL, *value = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3266 if (!o) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3267 Py_INCREF(Py_None);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3268 return Py_None;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3269 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3270
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3271 result = PyType_GenericNew(comprehension_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3272 if (!result) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3273 value = ast2obj_expr(o->target);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3274 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3275 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3276 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3277 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3278 value = ast2obj_expr(o->iter);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3279 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3280 if (_PyObject_SetAttrId(result, &PyId_iter, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3281 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3282 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3283 value = ast2obj_list(o->ifs, ast2obj_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3284 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3285 if (_PyObject_SetAttrId(result, &PyId_ifs, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3286 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3287 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3288 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3289 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3290 Py_XDECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3291 Py_XDECREF(result);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3292 return NULL;
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3293 }
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3294
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3295 PyObject*
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3296 ast2obj_excepthandler(void* _o)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3297 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3298 excepthandler_ty o = (excepthandler_ty)_o;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3299 PyObject *result = NULL, *value = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3300 if (!o) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3301 Py_INCREF(Py_None);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3302 return Py_None;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3303 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3304
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3305 switch (o->kind) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3306 case ExceptHandler_kind:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3307 result = PyType_GenericNew(ExceptHandler_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3308 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3309 value = ast2obj_expr(o->v.ExceptHandler.type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3310 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3311 if (_PyObject_SetAttrId(result, &PyId_type, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3312 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3313 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3314 value = ast2obj_identifier(o->v.ExceptHandler.name);
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36794
diff changeset
3315 if (!value) goto failed;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3316 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3317 goto failed;
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36794
diff changeset
3318 Py_DECREF(value);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3319 value = ast2obj_list(o->v.ExceptHandler.body, ast2obj_stmt);
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36794
diff changeset
3320 if (!value) goto failed;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3321 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3322 goto failed;
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36794
diff changeset
3323 Py_DECREF(value);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3324 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3325 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3326 value = ast2obj_int(o->lineno);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3327 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3328 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3329 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3330 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3331 value = ast2obj_int(o->col_offset);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3332 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3333 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3334 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3335 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3336 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3337 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3338 Py_XDECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3339 Py_XDECREF(result);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3340 return NULL;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3341 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3342
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3343 PyObject*
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3344 ast2obj_arguments(void* _o)
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3345 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3346 arguments_ty o = (arguments_ty)_o;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3347 PyObject *result = NULL, *value = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3348 if (!o) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3349 Py_INCREF(Py_None);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3350 return Py_None;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3351 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3352
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3353 result = PyType_GenericNew(arguments_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3354 if (!result) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3355 value = ast2obj_list(o->args, ast2obj_arg);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3356 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3357 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3358 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3359 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3360 value = ast2obj_identifier(o->vararg);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3361 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3362 if (_PyObject_SetAttrId(result, &PyId_vararg, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3363 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3364 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3365 value = ast2obj_expr(o->varargannotation);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3366 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3367 if (_PyObject_SetAttrId(result, &PyId_varargannotation, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3368 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3369 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3370 value = ast2obj_list(o->kwonlyargs, ast2obj_arg);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3371 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3372 if (_PyObject_SetAttrId(result, &PyId_kwonlyargs, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3373 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3374 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3375 value = ast2obj_identifier(o->kwarg);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3376 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3377 if (_PyObject_SetAttrId(result, &PyId_kwarg, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3378 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3379 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3380 value = ast2obj_expr(o->kwargannotation);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3381 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3382 if (_PyObject_SetAttrId(result, &PyId_kwargannotation, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3383 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3384 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3385 value = ast2obj_list(o->defaults, ast2obj_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3386 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3387 if (_PyObject_SetAttrId(result, &PyId_defaults, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3388 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3389 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3390 value = ast2obj_list(o->kw_defaults, ast2obj_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3391 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3392 if (_PyObject_SetAttrId(result, &PyId_kw_defaults, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3393 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3394 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3395 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3396 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3397 Py_XDECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3398 Py_XDECREF(result);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3399 return NULL;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3400 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3401
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3402 PyObject*
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
3403 ast2obj_arg(void* _o)
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
3404 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3405 arg_ty o = (arg_ty)_o;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3406 PyObject *result = NULL, *value = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3407 if (!o) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3408 Py_INCREF(Py_None);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3409 return Py_None;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3410 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3411
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3412 result = PyType_GenericNew(arg_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3413 if (!result) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3414 value = ast2obj_identifier(o->arg);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3415 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3416 if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3417 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3418 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3419 value = ast2obj_expr(o->annotation);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3420 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3421 if (_PyObject_SetAttrId(result, &PyId_annotation, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3422 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3423 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3424 return result;
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
3425 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3426 Py_XDECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3427 Py_XDECREF(result);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3428 return NULL;
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
3429 }
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
3430
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
3431 PyObject*
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3432 ast2obj_keyword(void* _o)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3433 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3434 keyword_ty o = (keyword_ty)_o;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3435 PyObject *result = NULL, *value = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3436 if (!o) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3437 Py_INCREF(Py_None);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3438 return Py_None;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3439 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3440
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3441 result = PyType_GenericNew(keyword_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3442 if (!result) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3443 value = ast2obj_identifier(o->arg);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3444 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3445 if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3446 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3447 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3448 value = ast2obj_expr(o->value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3449 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3450 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3451 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3452 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3453 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3454 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3455 Py_XDECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3456 Py_XDECREF(result);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3457 return NULL;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3458 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3459
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3460 PyObject*
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3461 ast2obj_alias(void* _o)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3462 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3463 alias_ty o = (alias_ty)_o;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3464 PyObject *result = NULL, *value = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3465 if (!o) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3466 Py_INCREF(Py_None);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3467 return Py_None;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3468 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3469
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3470 result = PyType_GenericNew(alias_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3471 if (!result) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3472 value = ast2obj_identifier(o->name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3473 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3474 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3475 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3476 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3477 value = ast2obj_identifier(o->asname);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3478 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3479 if (_PyObject_SetAttrId(result, &PyId_asname, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3480 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3481 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3482 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3483 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3484 Py_XDECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3485 Py_XDECREF(result);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3486 return NULL;
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3487 }
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3488
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
3489 PyObject*
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
3490 ast2obj_withitem(void* _o)
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
3491 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3492 withitem_ty o = (withitem_ty)_o;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3493 PyObject *result = NULL, *value = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3494 if (!o) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3495 Py_INCREF(Py_None);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3496 return Py_None;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3497 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3498
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3499 result = PyType_GenericNew(withitem_type, NULL, NULL);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3500 if (!result) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3501 value = ast2obj_expr(o->context_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3502 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3503 if (_PyObject_SetAttrId(result, &PyId_context_expr, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3504 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3505 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3506 value = ast2obj_expr(o->optional_vars);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3507 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3508 if (_PyObject_SetAttrId(result, &PyId_optional_vars, value) == -1)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3509 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3510 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3511 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3512 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3513 Py_XDECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3514 Py_XDECREF(result);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3515 return NULL;
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3516 }
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3517
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3518
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3519 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3520 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3521 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3522 int isinstance;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3523
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3524 PyObject *tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3525
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3526 if (obj == Py_None) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3527 *out = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3528 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3529 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3530 isinstance = PyObject_IsInstance(obj, (PyObject*)Module_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3531 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3532 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3533 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3534 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3535 asdl_seq* body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3536
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3537 if (_PyObject_HasAttrId(obj, &PyId_body)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3538 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3539 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3540 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3541 tmp = _PyObject_GetAttrId(obj, &PyId_body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3542 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3543 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3544 PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3545 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3546 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3547 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3548 body = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3549 if (body == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3550 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3551 stmt_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3552 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3553 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3554 asdl_seq_SET(body, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3555 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3556 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3557 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3558 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3559 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Module");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3560 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
3561 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3562 *out = Module(body, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3563 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3564 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3565 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3566 isinstance = PyObject_IsInstance(obj, (PyObject*)Interactive_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3567 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3568 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3569 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3570 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3571 asdl_seq* body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3572
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3573 if (_PyObject_HasAttrId(obj, &PyId_body)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3574 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3575 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3576 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3577 tmp = _PyObject_GetAttrId(obj, &PyId_body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3578 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3579 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3580 PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3581 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3582 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3583 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3584 body = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3585 if (body == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3586 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3587 stmt_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3588 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3589 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3590 asdl_seq_SET(body, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3591 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3592 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3593 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3594 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3595 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Interactive");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3596 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
3597 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3598 *out = Interactive(body, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3599 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3600 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3601 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3602 isinstance = PyObject_IsInstance(obj, (PyObject*)Expression_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3603 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3604 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3605 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3606 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3607 expr_ty body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3608
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3609 if (_PyObject_HasAttrId(obj, &PyId_body)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3610 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3611 tmp = _PyObject_GetAttrId(obj, &PyId_body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3612 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3613 res = obj2ast_expr(tmp, &body, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3614 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3615 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3616 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3617 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3618 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3619 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
3620 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3621 *out = Expression(body, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3622 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3623 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3624 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3625 isinstance = PyObject_IsInstance(obj, (PyObject*)Suite_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3626 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3627 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3628 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3629 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3630 asdl_seq* body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3631
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3632 if (_PyObject_HasAttrId(obj, &PyId_body)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3633 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3634 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3635 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3636 tmp = _PyObject_GetAttrId(obj, &PyId_body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3637 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3638 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3639 PyErr_Format(PyExc_TypeError, "Suite field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3640 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3641 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3642 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3643 body = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3644 if (body == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3645 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3646 stmt_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3647 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3648 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3649 asdl_seq_SET(body, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3650 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3651 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3652 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3653 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3654 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Suite");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3655 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3656 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3657 *out = Suite(body, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3658 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3659 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3660 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3661
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3662 PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3663 failed:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3664 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3665 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3666 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3667
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3668 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3669 obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3670 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3671 int isinstance;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3672
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3673 PyObject *tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3674 int lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3675 int col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3676
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3677 if (obj == Py_None) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3678 *out = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3679 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3680 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3681 if (_PyObject_HasAttrId(obj, &PyId_lineno)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3682 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3683 tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3684 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3685 res = obj2ast_int(tmp, &lineno, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3686 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3687 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3688 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3689 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3690 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3691 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3692 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3693 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3694 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3695 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3696 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3697 res = obj2ast_int(tmp, &col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3698 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3699 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3700 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3701 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3702 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3703 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3704 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3705 isinstance = PyObject_IsInstance(obj, (PyObject*)FunctionDef_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3706 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3707 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3708 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3709 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3710 identifier name;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3711 arguments_ty args;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3712 asdl_seq* body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3713 asdl_seq* decorator_list;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3714 expr_ty returns;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3715
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3716 if (_PyObject_HasAttrId(obj, &PyId_name)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3717 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3718 tmp = _PyObject_GetAttrId(obj, &PyId_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3719 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3720 res = obj2ast_identifier(tmp, &name, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3721 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3722 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3723 tmp = NULL;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3724 } else {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3725 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3726 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3727 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3728 if (_PyObject_HasAttrId(obj, &PyId_args)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3729 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3730 tmp = _PyObject_GetAttrId(obj, &PyId_args);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3731 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3732 res = obj2ast_arguments(tmp, &args, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3733 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3734 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3735 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3736 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3737 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3738 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3739 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3740 if (_PyObject_HasAttrId(obj, &PyId_body)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3741 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3742 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3743 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3744 tmp = _PyObject_GetAttrId(obj, &PyId_body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3745 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3746 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3747 PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3748 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3749 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3750 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3751 body = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3752 if (body == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3753 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3754 stmt_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3755 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3756 if (res != 0) goto failed;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3757 asdl_seq_SET(body, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3758 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3759 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3760 tmp = NULL;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3761 } else {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3762 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from FunctionDef");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3763 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3764 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3765 if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3766 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3767 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3768 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3769 tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3770 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3771 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3772 PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3773 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3774 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3775 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3776 decorator_list = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3777 if (decorator_list == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3778 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3779 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3780 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3781 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3782 asdl_seq_SET(decorator_list, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3783 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3784 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3785 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3786 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3787 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from FunctionDef");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3788 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3789 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3790 if (_PyObject_HasAttrId(obj, &PyId_returns)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3791 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3792 tmp = _PyObject_GetAttrId(obj, &PyId_returns);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3793 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3794 res = obj2ast_expr(tmp, &returns, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3795 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3796 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3797 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3798 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3799 returns = NULL;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
3800 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3801 *out = FunctionDef(name, args, body, decorator_list, returns, lineno,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3802 col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3803 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3804 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3805 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3806 isinstance = PyObject_IsInstance(obj, (PyObject*)ClassDef_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3807 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3808 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3809 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3810 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3811 identifier name;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3812 asdl_seq* bases;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3813 asdl_seq* keywords;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3814 expr_ty starargs;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3815 expr_ty kwargs;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3816 asdl_seq* body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3817 asdl_seq* decorator_list;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3818
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3819 if (_PyObject_HasAttrId(obj, &PyId_name)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3820 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3821 tmp = _PyObject_GetAttrId(obj, &PyId_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3822 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3823 res = obj2ast_identifier(tmp, &name, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3824 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3825 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3826 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3827 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3828 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3829 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3830 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3831 if (_PyObject_HasAttrId(obj, &PyId_bases)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3832 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3833 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3834 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3835 tmp = _PyObject_GetAttrId(obj, &PyId_bases);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3836 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3837 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3838 PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3839 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3840 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3841 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3842 bases = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3843 if (bases == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3844 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3845 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3846 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3847 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3848 asdl_seq_SET(bases, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3849 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3850 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3851 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3852 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3853 PyErr_SetString(PyExc_TypeError, "required field \"bases\" missing from ClassDef");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3854 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3855 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3856 if (_PyObject_HasAttrId(obj, &PyId_keywords)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3857 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3858 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3859 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3860 tmp = _PyObject_GetAttrId(obj, &PyId_keywords);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3861 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3862 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3863 PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3864 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3865 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3866 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3867 keywords = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3868 if (keywords == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3869 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3870 keyword_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3871 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3872 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3873 asdl_seq_SET(keywords, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3874 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3875 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3876 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3877 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3878 PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from ClassDef");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3879 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3880 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3881 if (_PyObject_HasAttrId(obj, &PyId_starargs)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3882 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3883 tmp = _PyObject_GetAttrId(obj, &PyId_starargs);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3884 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3885 res = obj2ast_expr(tmp, &starargs, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3886 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3887 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3888 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3889 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3890 starargs = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3891 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3892 if (_PyObject_HasAttrId(obj, &PyId_kwargs)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3893 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3894 tmp = _PyObject_GetAttrId(obj, &PyId_kwargs);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3895 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3896 res = obj2ast_expr(tmp, &kwargs, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3897 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3898 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3899 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3900 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3901 kwargs = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3902 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3903 if (_PyObject_HasAttrId(obj, &PyId_body)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3904 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3905 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3906 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3907 tmp = _PyObject_GetAttrId(obj, &PyId_body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3908 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3909 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3910 PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3911 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3912 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3913 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3914 body = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3915 if (body == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3916 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3917 stmt_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3918 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3919 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3920 asdl_seq_SET(body, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3921 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3922 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3923 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3924 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3925 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ClassDef");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3926 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3927 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3928 if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3929 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3930 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3931 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3932 tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3933 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3934 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3935 PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3936 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3937 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3938 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3939 decorator_list = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3940 if (decorator_list == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3941 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3942 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3943 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3944 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3945 asdl_seq_SET(decorator_list, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3946 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3947 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3948 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3949 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3950 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from ClassDef");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3951 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
3952 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3953 *out = ClassDef(name, bases, keywords, starargs, kwargs, body,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3954 decorator_list, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3955 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3956 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3957 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3958 isinstance = PyObject_IsInstance(obj, (PyObject*)Return_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3959 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3960 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3961 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3962 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3963 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3964
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3965 if (_PyObject_HasAttrId(obj, &PyId_value)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3966 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3967 tmp = _PyObject_GetAttrId(obj, &PyId_value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3968 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3969 res = obj2ast_expr(tmp, &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3970 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3971 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3972 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3973 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3974 value = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3975 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3976 *out = Return(value, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3977 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3978 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3979 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3980 isinstance = PyObject_IsInstance(obj, (PyObject*)Delete_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3981 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3982 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3983 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3984 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3985 asdl_seq* targets;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3986
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3987 if (_PyObject_HasAttrId(obj, &PyId_targets)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3988 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3989 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3990 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3991 tmp = _PyObject_GetAttrId(obj, &PyId_targets);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3992 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3993 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3994 PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3995 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3996 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3997 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3998 targets = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3999 if (targets == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4000 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4001 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4002 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4003 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4004 asdl_seq_SET(targets, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4005 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4006 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4007 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4008 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4009 PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Delete");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4010 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4011 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4012 *out = Delete(targets, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4013 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4014 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4015 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4016 isinstance = PyObject_IsInstance(obj, (PyObject*)Assign_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4017 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4018 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4019 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4020 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4021 asdl_seq* targets;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4022 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4023
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4024 if (_PyObject_HasAttrId(obj, &PyId_targets)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4025 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4026 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4027 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4028 tmp = _PyObject_GetAttrId(obj, &PyId_targets);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4029 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4030 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4031 PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4032 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4033 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4034 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4035 targets = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4036 if (targets == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4037 for (i = 0; i < len; i++) {
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4038 expr_ty value;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4039 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4040 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4041 asdl_seq_SET(targets, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4042 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4043 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4044 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4045 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4046 PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Assign");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4047 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4048 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4049 if (_PyObject_HasAttrId(obj, &PyId_value)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4050 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4051 tmp = _PyObject_GetAttrId(obj, &PyId_value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4052 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4053 res = obj2ast_expr(tmp, &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4054 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4055 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4056 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4057 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4058 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4059 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4060 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4061 *out = Assign(targets, value, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4062 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4063 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4064 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4065 isinstance = PyObject_IsInstance(obj, (PyObject*)AugAssign_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4066 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4067 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4068 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4069 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4070 expr_ty target;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4071 operator_ty op;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4072 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4073
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4074 if (_PyObject_HasAttrId(obj, &PyId_target)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4075 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4076 tmp = _PyObject_GetAttrId(obj, &PyId_target);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4077 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4078 res = obj2ast_expr(tmp, &target, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4079 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4080 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4081 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4082 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4083 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4084 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4085 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4086 if (_PyObject_HasAttrId(obj, &PyId_op)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4087 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4088 tmp = _PyObject_GetAttrId(obj, &PyId_op);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4089 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4090 res = obj2ast_operator(tmp, &op, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4091 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4092 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4093 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4094 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4095 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4096 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4097 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4098 if (_PyObject_HasAttrId(obj, &PyId_value)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4099 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4100 tmp = _PyObject_GetAttrId(obj, &PyId_value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4101 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4102 res = obj2ast_expr(tmp, &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4103 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4104 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4105 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4106 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4107 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4108 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4109 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4110 *out = AugAssign(target, op, value, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4111 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4112 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4113 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4114 isinstance = PyObject_IsInstance(obj, (PyObject*)For_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4115 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4116 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4117 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4118 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4119 expr_ty target;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4120 expr_ty iter;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4121 asdl_seq* body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4122 asdl_seq* orelse;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4123
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4124 if (_PyObject_HasAttrId(obj, &PyId_target)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4125 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4126 tmp = _PyObject_GetAttrId(obj, &PyId_target);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4127 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4128 res = obj2ast_expr(tmp, &target, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4129 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4130 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4131 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4132 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4133 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4134 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4135 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4136 if (_PyObject_HasAttrId(obj, &PyId_iter)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4137 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4138 tmp = _PyObject_GetAttrId(obj, &PyId_iter);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4139 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4140 res = obj2ast_expr(tmp, &iter, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4141 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4142 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4143 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4144 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4145 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4146 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4147 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4148 if (_PyObject_HasAttrId(obj, &PyId_body)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4149 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4150 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4151 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4152 tmp = _PyObject_GetAttrId(obj, &PyId_body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4153 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4154 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4155 PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4156 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4157 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4158 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4159 body = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4160 if (body == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4161 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4162 stmt_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4163 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4164 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4165 asdl_seq_SET(body, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4166 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4167 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4168 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4169 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4170 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from For");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4171 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4172 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4173 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4174 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4175 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4176 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4177 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4178 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4179 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4180 PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4181 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4182 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4183 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4184 orelse = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4185 if (orelse == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4186 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4187 stmt_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4188 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4189 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4190 asdl_seq_SET(orelse, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4191 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4192 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4193 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4194 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4195 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from For");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4196 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4197 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4198 *out = For(target, iter, body, orelse, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4199 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4200 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4201 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4202 isinstance = PyObject_IsInstance(obj, (PyObject*)While_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4203 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4204 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4205 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4206 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4207 expr_ty test;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4208 asdl_seq* body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4209 asdl_seq* orelse;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4210
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4211 if (_PyObject_HasAttrId(obj, &PyId_test)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4212 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4213 tmp = _PyObject_GetAttrId(obj, &PyId_test);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4214 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4215 res = obj2ast_expr(tmp, &test, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4216 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4217 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4218 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4219 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4220 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4221 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4222 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4223 if (_PyObject_HasAttrId(obj, &PyId_body)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4224 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4225 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4226 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4227 tmp = _PyObject_GetAttrId(obj, &PyId_body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4228 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4229 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4230 PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4231 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4232 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4233 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4234 body = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4235 if (body == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4236 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4237 stmt_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4238 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4239 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4240 asdl_seq_SET(body, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4241 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4242 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4243 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4244 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4245 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from While");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4246 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4247 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4248 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4249 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4250 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4251 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4252 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4253 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4254 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4255 PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4256 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4257 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4258 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4259 orelse = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4260 if (orelse == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4261 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4262 stmt_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4263 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4264 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4265 asdl_seq_SET(orelse, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4266 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4267 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4268 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4269 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4270 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from While");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4271 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4272 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4273 *out = While(test, body, orelse, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4274 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4275 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4276 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4277 isinstance = PyObject_IsInstance(obj, (PyObject*)If_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4278 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4279 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4280 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4281 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4282 expr_ty test;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4283 asdl_seq* body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4284 asdl_seq* orelse;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4285
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4286 if (_PyObject_HasAttrId(obj, &PyId_test)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4287 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4288 tmp = _PyObject_GetAttrId(obj, &PyId_test);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4289 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4290 res = obj2ast_expr(tmp, &test, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4291 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4292 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4293 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4294 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4295 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4296 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4297 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4298 if (_PyObject_HasAttrId(obj, &PyId_body)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4299 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4300 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4301 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4302 tmp = _PyObject_GetAttrId(obj, &PyId_body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4303 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4304 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4305 PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4306 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4307 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4308 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4309 body = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4310 if (body == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4311 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4312 stmt_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4313 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4314 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4315 asdl_seq_SET(body, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4316 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4317 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4318 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4319 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4320 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from If");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4321 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4322 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4323 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4324 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4325 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4326 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4327 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4328 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4329 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4330 PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4331 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4332 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4333 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4334 orelse = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4335 if (orelse == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4336 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4337 stmt_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4338 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4339 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4340 asdl_seq_SET(orelse, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4341 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4342 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4343 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4344 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4345 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from If");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4346 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4347 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4348 *out = If(test, body, orelse, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4349 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4350 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4351 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4352 isinstance = PyObject_IsInstance(obj, (PyObject*)With_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4353 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4354 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4355 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4356 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4357 asdl_seq* items;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4358 asdl_seq* body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4359
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4360 if (_PyObject_HasAttrId(obj, &PyId_items)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4361 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4362 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4363 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4364 tmp = _PyObject_GetAttrId(obj, &PyId_items);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4365 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4366 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4367 PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4368 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4369 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4370 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4371 items = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4372 if (items == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4373 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4374 withitem_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4375 res = obj2ast_withitem(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4376 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4377 asdl_seq_SET(items, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4378 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4379 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4380 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4381 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4382 PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from With");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4383 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4384 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4385 if (_PyObject_HasAttrId(obj, &PyId_body)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4386 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4387 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4388 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4389 tmp = _PyObject_GetAttrId(obj, &PyId_body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4390 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4391 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4392 PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4393 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4394 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4395 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4396 body = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4397 if (body == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4398 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4399 stmt_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4400 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4401 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4402 asdl_seq_SET(body, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4403 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4404 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4405 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4406 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4407 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from With");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4408 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4409 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4410 *out = With(items, body, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4411 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4412 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4413 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4414 isinstance = PyObject_IsInstance(obj, (PyObject*)Raise_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4415 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4416 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4417 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4418 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4419 expr_ty exc;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4420 expr_ty cause;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4421
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4422 if (_PyObject_HasAttrId(obj, &PyId_exc)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4423 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4424 tmp = _PyObject_GetAttrId(obj, &PyId_exc);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4425 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4426 res = obj2ast_expr(tmp, &exc, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4427 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4428 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4429 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4430 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4431 exc = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4432 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4433 if (_PyObject_HasAttrId(obj, &PyId_cause)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4434 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4435 tmp = _PyObject_GetAttrId(obj, &PyId_cause);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4436 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4437 res = obj2ast_expr(tmp, &cause, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4438 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4439 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4440 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4441 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4442 cause = NULL;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4443 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4444 *out = Raise(exc, cause, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4445 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4446 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4447 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4448 isinstance = PyObject_IsInstance(obj, (PyObject*)Try_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4449 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4450 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4451 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4452 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4453 asdl_seq* body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4454 asdl_seq* handlers;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4455 asdl_seq* orelse;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4456 asdl_seq* finalbody;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4457
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4458 if (_PyObject_HasAttrId(obj, &PyId_body)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4459 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4460 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4461 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4462 tmp = _PyObject_GetAttrId(obj, &PyId_body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4463 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4464 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4465 PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4466 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4467 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4468 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4469 body = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4470 if (body == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4471 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4472 stmt_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4473 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4474 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4475 asdl_seq_SET(body, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4476 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4477 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4478 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4479 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4480 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Try");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4481 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4482 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4483 if (_PyObject_HasAttrId(obj, &PyId_handlers)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4484 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4485 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4486 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4487 tmp = _PyObject_GetAttrId(obj, &PyId_handlers);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4488 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4489 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4490 PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4491 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4492 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4493 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4494 handlers = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4495 if (handlers == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4496 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4497 excepthandler_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4498 res = obj2ast_excepthandler(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4499 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4500 asdl_seq_SET(handlers, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4501 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4502 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4503 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4504 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4505 PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from Try");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4506 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4507 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4508 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4509 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4510 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4511 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4512 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4513 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4514 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4515 PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4516 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4517 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4518 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4519 orelse = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4520 if (orelse == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4521 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4522 stmt_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4523 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4524 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4525 asdl_seq_SET(orelse, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4526 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4527 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4528 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4529 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4530 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from Try");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4531 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4532 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4533 if (_PyObject_HasAttrId(obj, &PyId_finalbody)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4534 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4535 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4536 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4537 tmp = _PyObject_GetAttrId(obj, &PyId_finalbody);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4538 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4539 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4540 PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4541 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4542 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4543 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4544 finalbody = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4545 if (finalbody == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4546 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4547 stmt_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4548 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4549 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4550 asdl_seq_SET(finalbody, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4551 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4552 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4553 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4554 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4555 PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from Try");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4556 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4557 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4558 *out = Try(body, handlers, orelse, finalbody, lineno, col_offset,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4559 arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4560 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4561 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4562 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4563 isinstance = PyObject_IsInstance(obj, (PyObject*)Assert_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4564 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4565 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4566 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4567 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4568 expr_ty test;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4569 expr_ty msg;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4570
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4571 if (_PyObject_HasAttrId(obj, &PyId_test)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4572 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4573 tmp = _PyObject_GetAttrId(obj, &PyId_test);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4574 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4575 res = obj2ast_expr(tmp, &test, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4576 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4577 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4578 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4579 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4580 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4581 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4582 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4583 if (_PyObject_HasAttrId(obj, &PyId_msg)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4584 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4585 tmp = _PyObject_GetAttrId(obj, &PyId_msg);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4586 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4587 res = obj2ast_expr(tmp, &msg, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4588 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4589 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4590 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4591 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4592 msg = NULL;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4593 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4594 *out = Assert(test, msg, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4595 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4596 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4597 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4598 isinstance = PyObject_IsInstance(obj, (PyObject*)Import_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4599 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4600 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4601 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4602 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4603 asdl_seq* names;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4604
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4605 if (_PyObject_HasAttrId(obj, &PyId_names)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4606 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4607 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4608 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4609 tmp = _PyObject_GetAttrId(obj, &PyId_names);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4610 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4611 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4612 PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4613 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4614 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4615 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4616 names = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4617 if (names == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4618 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4619 alias_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4620 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4621 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4622 asdl_seq_SET(names, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4623 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4624 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4625 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4626 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4627 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Import");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4628 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4629 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4630 *out = Import(names, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4631 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4632 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4633 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4634 isinstance = PyObject_IsInstance(obj, (PyObject*)ImportFrom_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4635 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4636 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4637 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4638 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4639 identifier module;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4640 asdl_seq* names;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4641 int level;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4642
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4643 if (_PyObject_HasAttrId(obj, &PyId_module)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4644 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4645 tmp = _PyObject_GetAttrId(obj, &PyId_module);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4646 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4647 res = obj2ast_identifier(tmp, &module, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4648 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4649 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4650 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4651 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4652 module = NULL;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4653 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4654 if (_PyObject_HasAttrId(obj, &PyId_names)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4655 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4656 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4657 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4658 tmp = _PyObject_GetAttrId(obj, &PyId_names);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4659 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4660 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4661 PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4662 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4663 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4664 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4665 names = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4666 if (names == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4667 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4668 alias_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4669 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4670 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4671 asdl_seq_SET(names, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4672 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4673 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4674 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4675 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4676 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from ImportFrom");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4677 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4678 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4679 if (_PyObject_HasAttrId(obj, &PyId_level)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4680 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4681 tmp = _PyObject_GetAttrId(obj, &PyId_level);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4682 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4683 res = obj2ast_int(tmp, &level, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4684 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4685 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4686 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4687 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4688 level = 0;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4689 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4690 *out = ImportFrom(module, names, level, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4691 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4692 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4693 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4694 isinstance = PyObject_IsInstance(obj, (PyObject*)Global_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4695 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4696 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4697 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4698 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4699 asdl_seq* names;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4700
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4701 if (_PyObject_HasAttrId(obj, &PyId_names)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4702 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4703 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4704 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4705 tmp = _PyObject_GetAttrId(obj, &PyId_names);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4706 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4707 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4708 PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4709 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4710 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4711 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4712 names = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4713 if (names == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4714 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4715 identifier value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4716 res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4717 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4718 asdl_seq_SET(names, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4719 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4720 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4721 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4722 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4723 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Global");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4724 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4725 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4726 *out = Global(names, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4727 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4728 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4729 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4730 isinstance = PyObject_IsInstance(obj, (PyObject*)Nonlocal_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4731 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4732 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4733 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4734 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4735 asdl_seq* names;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4736
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4737 if (_PyObject_HasAttrId(obj, &PyId_names)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4738 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4739 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4740 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4741 tmp = _PyObject_GetAttrId(obj, &PyId_names);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4742 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4743 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4744 PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4745 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4746 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4747 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4748 names = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4749 if (names == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4750 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4751 identifier value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4752 res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4753 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4754 asdl_seq_SET(names, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4755 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4756 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4757 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4758 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4759 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Nonlocal");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4760 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4761 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4762 *out = Nonlocal(names, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4763 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4764 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4765 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4766 isinstance = PyObject_IsInstance(obj, (PyObject*)Expr_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4767 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4768 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4769 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4770 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4771 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4772
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4773 if (_PyObject_HasAttrId(obj, &PyId_value)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4774 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4775 tmp = _PyObject_GetAttrId(obj, &PyId_value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4776 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4777 res = obj2ast_expr(tmp, &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4778 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4779 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4780 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4781 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4782 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4783 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4784 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4785 *out = Expr(value, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4786 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4787 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4788 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4789 isinstance = PyObject_IsInstance(obj, (PyObject*)Pass_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4790 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4791 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4792 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4793 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4794
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4795 *out = Pass(lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4796 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4797 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4798 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4799 isinstance = PyObject_IsInstance(obj, (PyObject*)Break_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4800 if (isinstance == -1) {
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4801 return 1;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4802 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4803 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4804
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4805 *out = Break(lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4806 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4807 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4808 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4809 isinstance = PyObject_IsInstance(obj, (PyObject*)Continue_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4810 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4811 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4812 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4813 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4814
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4815 *out = Continue(lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4816 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4817 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4818 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4819
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4820 PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4821 failed:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4822 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4823 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4824 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4825
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4826 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4827 obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4828 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4829 int isinstance;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4830
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4831 PyObject *tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4832 int lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4833 int col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4834
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4835 if (obj == Py_None) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4836 *out = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4837 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4838 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4839 if (_PyObject_HasAttrId(obj, &PyId_lineno)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4840 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4841 tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4842 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4843 res = obj2ast_int(tmp, &lineno, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4844 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4845 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4846 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4847 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4848 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4849 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4850 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4851 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4852 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4853 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4854 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4855 res = obj2ast_int(tmp, &col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4856 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4857 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4858 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4859 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4860 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4861 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4862 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4863 isinstance = PyObject_IsInstance(obj, (PyObject*)BoolOp_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4864 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4865 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4866 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4867 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4868 boolop_ty op;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4869 asdl_seq* values;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4870
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4871 if (_PyObject_HasAttrId(obj, &PyId_op)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4872 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4873 tmp = _PyObject_GetAttrId(obj, &PyId_op);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4874 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4875 res = obj2ast_boolop(tmp, &op, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4876 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4877 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4878 tmp = NULL;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4879 } else {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4880 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4881 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4882 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4883 if (_PyObject_HasAttrId(obj, &PyId_values)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4884 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4885 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4886 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4887 tmp = _PyObject_GetAttrId(obj, &PyId_values);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4888 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4889 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4890 PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4891 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4892 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4893 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4894 values = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4895 if (values == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4896 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4897 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4898 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4899 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4900 asdl_seq_SET(values, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4901 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4902 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4903 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4904 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4905 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from BoolOp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4906 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4907 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4908 *out = BoolOp(op, values, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4909 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4910 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4911 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4912 isinstance = PyObject_IsInstance(obj, (PyObject*)BinOp_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4913 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4914 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4915 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4916 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4917 expr_ty left;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4918 operator_ty op;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4919 expr_ty right;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4920
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4921 if (_PyObject_HasAttrId(obj, &PyId_left)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4922 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4923 tmp = _PyObject_GetAttrId(obj, &PyId_left);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4924 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4925 res = obj2ast_expr(tmp, &left, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4926 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4927 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4928 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4929 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4930 PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4931 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4932 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4933 if (_PyObject_HasAttrId(obj, &PyId_op)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4934 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4935 tmp = _PyObject_GetAttrId(obj, &PyId_op);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4936 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4937 res = obj2ast_operator(tmp, &op, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4938 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4939 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4940 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4941 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4942 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4943 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4944 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4945 if (_PyObject_HasAttrId(obj, &PyId_right)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4946 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4947 tmp = _PyObject_GetAttrId(obj, &PyId_right);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4948 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4949 res = obj2ast_expr(tmp, &right, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4950 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4951 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4952 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4953 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4954 PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4955 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4956 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4957 *out = BinOp(left, op, right, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4958 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4959 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4960 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4961 isinstance = PyObject_IsInstance(obj, (PyObject*)UnaryOp_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4962 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4963 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4964 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4965 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4966 unaryop_ty op;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4967 expr_ty operand;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4968
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4969 if (_PyObject_HasAttrId(obj, &PyId_op)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4970 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4971 tmp = _PyObject_GetAttrId(obj, &PyId_op);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4972 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4973 res = obj2ast_unaryop(tmp, &op, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4974 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4975 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4976 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4977 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4978 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4979 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4980 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4981 if (_PyObject_HasAttrId(obj, &PyId_operand)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4982 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4983 tmp = _PyObject_GetAttrId(obj, &PyId_operand);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4984 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4985 res = obj2ast_expr(tmp, &operand, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4986 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4987 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4988 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4989 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4990 PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4991 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4992 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4993 *out = UnaryOp(op, operand, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4994 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4995 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4996 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4997 isinstance = PyObject_IsInstance(obj, (PyObject*)Lambda_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4998 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4999 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5000 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5001 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5002 arguments_ty args;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5003 expr_ty body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5004
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5005 if (_PyObject_HasAttrId(obj, &PyId_args)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5006 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5007 tmp = _PyObject_GetAttrId(obj, &PyId_args);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5008 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5009 res = obj2ast_arguments(tmp, &args, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5010 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5011 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5012 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5013 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5014 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5015 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5016 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5017 if (_PyObject_HasAttrId(obj, &PyId_body)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5018 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5019 tmp = _PyObject_GetAttrId(obj, &PyId_body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5020 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5021 res = obj2ast_expr(tmp, &body, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5022 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5023 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5024 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5025 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5026 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5027 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5028 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5029 *out = Lambda(args, body, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5030 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5031 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5032 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5033 isinstance = PyObject_IsInstance(obj, (PyObject*)IfExp_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5034 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5035 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5036 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5037 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5038 expr_ty test;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5039 expr_ty body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5040 expr_ty orelse;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5041
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5042 if (_PyObject_HasAttrId(obj, &PyId_test)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5043 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5044 tmp = _PyObject_GetAttrId(obj, &PyId_test);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5045 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5046 res = obj2ast_expr(tmp, &test, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5047 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5048 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5049 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5050 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5051 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5052 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5053 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5054 if (_PyObject_HasAttrId(obj, &PyId_body)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5055 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5056 tmp = _PyObject_GetAttrId(obj, &PyId_body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5057 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5058 res = obj2ast_expr(tmp, &body, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5059 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5060 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5061 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5062 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5063 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5064 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5065 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5066 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5067 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5068 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5069 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5070 res = obj2ast_expr(tmp, &orelse, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5071 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5072 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5073 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5074 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5075 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5076 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5077 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5078 *out = IfExp(test, body, orelse, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5079 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5080 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5081 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5082 isinstance = PyObject_IsInstance(obj, (PyObject*)Dict_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5083 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5084 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5085 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5086 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5087 asdl_seq* keys;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5088 asdl_seq* values;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5089
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5090 if (_PyObject_HasAttrId(obj, &PyId_keys)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5091 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5092 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5093 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5094 tmp = _PyObject_GetAttrId(obj, &PyId_keys);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5095 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5096 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5097 PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5098 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5099 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5100 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5101 keys = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5102 if (keys == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5103 for (i = 0; i < len; i++) {
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5104 expr_ty value;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5105 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5106 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5107 asdl_seq_SET(keys, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5108 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5109 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5110 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5111 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5112 PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from Dict");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5113 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5114 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5115 if (_PyObject_HasAttrId(obj, &PyId_values)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5116 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5117 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5118 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5119 tmp = _PyObject_GetAttrId(obj, &PyId_values);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5120 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5121 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5122 PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5123 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5124 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5125 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5126 values = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5127 if (values == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5128 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5129 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5130 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5131 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5132 asdl_seq_SET(values, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5133 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5134 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5135 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5136 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5137 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Dict");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5138 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5139 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5140 *out = Dict(keys, values, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5141 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5142 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5143 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5144 isinstance = PyObject_IsInstance(obj, (PyObject*)Set_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5145 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5146 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5147 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5148 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5149 asdl_seq* elts;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5150
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5151 if (_PyObject_HasAttrId(obj, &PyId_elts)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5152 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5153 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5154 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5155 tmp = _PyObject_GetAttrId(obj, &PyId_elts);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5156 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5157 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5158 PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5159 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5160 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5161 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5162 elts = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5163 if (elts == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5164 for (i = 0; i < len; i++) {
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5165 expr_ty value;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5166 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5167 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5168 asdl_seq_SET(elts, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5169 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5170 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5171 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5172 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5173 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Set");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5174 return 1;
74391
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
5175 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5176 *out = Set(elts, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5177 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5178 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5179 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5180 isinstance = PyObject_IsInstance(obj, (PyObject*)ListComp_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5181 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5182 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5183 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5184 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5185 expr_ty elt;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5186 asdl_seq* generators;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5187
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5188 if (_PyObject_HasAttrId(obj, &PyId_elt)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5189 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5190 tmp = _PyObject_GetAttrId(obj, &PyId_elt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5191 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5192 res = obj2ast_expr(tmp, &elt, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5193 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5194 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5195 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5196 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5197 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5198 return 1;
74391
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
5199 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5200 if (_PyObject_HasAttrId(obj, &PyId_generators)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5201 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5202 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5203 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5204 tmp = _PyObject_GetAttrId(obj, &PyId_generators);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5205 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5206 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5207 PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5208 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5209 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5210 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5211 generators = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5212 if (generators == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5213 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5214 comprehension_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5215 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5216 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5217 asdl_seq_SET(generators, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5218 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5219 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5220 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5221 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5222 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from ListComp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5223 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5224 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5225 *out = ListComp(elt, generators, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5226 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5227 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5228 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5229 isinstance = PyObject_IsInstance(obj, (PyObject*)SetComp_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5230 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5231 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5232 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5233 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5234 expr_ty elt;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5235 asdl_seq* generators;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5236
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5237 if (_PyObject_HasAttrId(obj, &PyId_elt)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5238 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5239 tmp = _PyObject_GetAttrId(obj, &PyId_elt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5240 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5241 res = obj2ast_expr(tmp, &elt, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5242 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5243 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5244 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5245 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5246 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5247 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5248 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5249 if (_PyObject_HasAttrId(obj, &PyId_generators)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5250 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5251 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5252 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5253 tmp = _PyObject_GetAttrId(obj, &PyId_generators);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5254 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5255 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5256 PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5257 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5258 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5259 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5260 generators = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5261 if (generators == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5262 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5263 comprehension_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5264 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5265 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5266 asdl_seq_SET(generators, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5267 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5268 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5269 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5270 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5271 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from SetComp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5272 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5273 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5274 *out = SetComp(elt, generators, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5275 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5276 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5277 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5278 isinstance = PyObject_IsInstance(obj, (PyObject*)DictComp_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5279 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5280 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5281 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5282 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5283 expr_ty key;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5284 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5285 asdl_seq* generators;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5286
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5287 if (_PyObject_HasAttrId(obj, &PyId_key)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5288 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5289 tmp = _PyObject_GetAttrId(obj, &PyId_key);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5290 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5291 res = obj2ast_expr(tmp, &key, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5292 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5293 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5294 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5295 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5296 PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5297 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5298 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5299 if (_PyObject_HasAttrId(obj, &PyId_value)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5300 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5301 tmp = _PyObject_GetAttrId(obj, &PyId_value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5302 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5303 res = obj2ast_expr(tmp, &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5304 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5305 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5306 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5307 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5308 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from DictComp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5309 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5310 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5311 if (_PyObject_HasAttrId(obj, &PyId_generators)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5312 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5313 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5314 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5315 tmp = _PyObject_GetAttrId(obj, &PyId_generators);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5316 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5317 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5318 PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5319 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5320 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5321 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5322 generators = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5323 if (generators == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5324 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5325 comprehension_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5326 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5327 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5328 asdl_seq_SET(generators, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5329 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5330 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5331 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5332 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5333 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from DictComp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5334 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5335 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5336 *out = DictComp(key, value, generators, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5337 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5338 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5339 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5340 isinstance = PyObject_IsInstance(obj, (PyObject*)GeneratorExp_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5341 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5342 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5343 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5344 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5345 expr_ty elt;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5346 asdl_seq* generators;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5347
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5348 if (_PyObject_HasAttrId(obj, &PyId_elt)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5349 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5350 tmp = _PyObject_GetAttrId(obj, &PyId_elt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5351 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5352 res = obj2ast_expr(tmp, &elt, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5353 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5354 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5355 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5356 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5357 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5358 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5359 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5360 if (_PyObject_HasAttrId(obj, &PyId_generators)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5361 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5362 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5363 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5364 tmp = _PyObject_GetAttrId(obj, &PyId_generators);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5365 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5366 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5367 PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5368 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5369 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5370 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5371 generators = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5372 if (generators == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5373 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5374 comprehension_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5375 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5376 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5377 asdl_seq_SET(generators, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5378 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5379 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5380 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5381 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5382 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from GeneratorExp");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5383 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5384 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5385 *out = GeneratorExp(elt, generators, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5386 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5387 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5388 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5389 isinstance = PyObject_IsInstance(obj, (PyObject*)Yield_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5390 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5391 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5392 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5393 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5394 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5395
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5396 if (_PyObject_HasAttrId(obj, &PyId_value)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5397 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5398 tmp = _PyObject_GetAttrId(obj, &PyId_value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5399 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5400 res = obj2ast_expr(tmp, &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5401 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5402 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5403 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5404 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5405 value = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5406 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5407 *out = Yield(value, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5408 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5409 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5410 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5411 isinstance = PyObject_IsInstance(obj, (PyObject*)YieldFrom_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5412 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5413 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5414 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5415 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5416 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5417
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5418 if (_PyObject_HasAttrId(obj, &PyId_value)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5419 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5420 tmp = _PyObject_GetAttrId(obj, &PyId_value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5421 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5422 res = obj2ast_expr(tmp, &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5423 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5424 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5425 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5426 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5427 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5428 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5429 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5430 *out = YieldFrom(value, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5431 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5432 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5433 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5434 isinstance = PyObject_IsInstance(obj, (PyObject*)Compare_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5435 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5436 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5437 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5438 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5439 expr_ty left;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5440 asdl_int_seq* ops;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5441 asdl_seq* comparators;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5442
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5443 if (_PyObject_HasAttrId(obj, &PyId_left)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5444 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5445 tmp = _PyObject_GetAttrId(obj, &PyId_left);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5446 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5447 res = obj2ast_expr(tmp, &left, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5448 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5449 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5450 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5451 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5452 PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5453 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5454 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5455 if (_PyObject_HasAttrId(obj, &PyId_ops)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5456 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5457 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5458 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5459 tmp = _PyObject_GetAttrId(obj, &PyId_ops);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5460 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5461 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5462 PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5463 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5464 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5465 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5466 ops = asdl_int_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5467 if (ops == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5468 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5469 cmpop_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5470 res = obj2ast_cmpop(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5471 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5472 asdl_seq_SET(ops, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5473 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5474 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5475 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5476 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5477 PyErr_SetString(PyExc_TypeError, "required field \"ops\" missing from Compare");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5478 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5479 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5480 if (_PyObject_HasAttrId(obj, &PyId_comparators)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5481 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5482 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5483 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5484 tmp = _PyObject_GetAttrId(obj, &PyId_comparators);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5485 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5486 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5487 PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5488 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5489 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5490 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5491 comparators = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5492 if (comparators == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5493 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5494 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5495 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5496 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5497 asdl_seq_SET(comparators, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5498 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5499 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5500 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5501 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5502 PyErr_SetString(PyExc_TypeError, "required field \"comparators\" missing from Compare");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5503 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5504 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5505 *out = Compare(left, ops, comparators, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5506 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5507 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5508 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5509 isinstance = PyObject_IsInstance(obj, (PyObject*)Call_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5510 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5511 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5512 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5513 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5514 expr_ty func;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5515 asdl_seq* args;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5516 asdl_seq* keywords;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5517 expr_ty starargs;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5518 expr_ty kwargs;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5519
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5520 if (_PyObject_HasAttrId(obj, &PyId_func)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5521 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5522 tmp = _PyObject_GetAttrId(obj, &PyId_func);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5523 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5524 res = obj2ast_expr(tmp, &func, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5525 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5526 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5527 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5528 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5529 PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5530 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5531 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5532 if (_PyObject_HasAttrId(obj, &PyId_args)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5533 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5534 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5535 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5536 tmp = _PyObject_GetAttrId(obj, &PyId_args);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5537 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5538 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5539 PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5540 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5541 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5542 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5543 args = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5544 if (args == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5545 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5546 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5547 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5548 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5549 asdl_seq_SET(args, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5550 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5551 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5552 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5553 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5554 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Call");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5555 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5556 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5557 if (_PyObject_HasAttrId(obj, &PyId_keywords)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5558 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5559 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5560 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5561 tmp = _PyObject_GetAttrId(obj, &PyId_keywords);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5562 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5563 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5564 PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5565 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5566 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5567 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5568 keywords = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5569 if (keywords == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5570 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5571 keyword_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5572 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5573 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5574 asdl_seq_SET(keywords, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5575 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5576 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5577 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5578 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5579 PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from Call");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5580 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5581 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5582 if (_PyObject_HasAttrId(obj, &PyId_starargs)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5583 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5584 tmp = _PyObject_GetAttrId(obj, &PyId_starargs);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5585 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5586 res = obj2ast_expr(tmp, &starargs, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5587 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5588 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5589 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5590 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5591 starargs = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5592 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5593 if (_PyObject_HasAttrId(obj, &PyId_kwargs)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5594 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5595 tmp = _PyObject_GetAttrId(obj, &PyId_kwargs);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5596 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5597 res = obj2ast_expr(tmp, &kwargs, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5598 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5599 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5600 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5601 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5602 kwargs = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5603 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5604 *out = Call(func, args, keywords, starargs, kwargs, lineno, col_offset,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5605 arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5606 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5607 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5608 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5609 isinstance = PyObject_IsInstance(obj, (PyObject*)Num_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5610 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5611 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5612 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5613 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5614 object n;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5615
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5616 if (_PyObject_HasAttrId(obj, &PyId_n)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5617 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5618 tmp = _PyObject_GetAttrId(obj, &PyId_n);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5619 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5620 res = obj2ast_object(tmp, &n, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5621 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5622 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5623 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5624 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5625 PyErr_SetString(PyExc_TypeError, "required field \"n\" missing from Num");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5626 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5627 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5628 *out = Num(n, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5629 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5630 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5631 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5632 isinstance = PyObject_IsInstance(obj, (PyObject*)Str_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5633 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5634 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5635 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5636 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5637 string s;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5638
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5639 if (_PyObject_HasAttrId(obj, &PyId_s)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5640 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5641 tmp = _PyObject_GetAttrId(obj, &PyId_s);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5642 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5643 res = obj2ast_string(tmp, &s, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5644 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5645 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5646 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5647 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5648 PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Str");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5649 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5650 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5651 *out = Str(s, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5652 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5653 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5654 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5655 isinstance = PyObject_IsInstance(obj, (PyObject*)Bytes_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5656 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5657 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5658 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5659 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5660 bytes s;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5661
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5662 if (_PyObject_HasAttrId(obj, &PyId_s)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5663 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5664 tmp = _PyObject_GetAttrId(obj, &PyId_s);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5665 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5666 res = obj2ast_bytes(tmp, &s, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5667 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5668 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5669 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5670 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5671 PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Bytes");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5672 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5673 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5674 *out = Bytes(s, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5675 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5676 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5677 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5678 isinstance = PyObject_IsInstance(obj, (PyObject*)Ellipsis_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5679 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5680 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5681 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5682 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5683
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5684 *out = Ellipsis(lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5685 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5686 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5687 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5688 isinstance = PyObject_IsInstance(obj, (PyObject*)Attribute_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5689 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5690 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5691 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5692 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5693 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5694 identifier attr;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5695 expr_context_ty ctx;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5696
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5697 if (_PyObject_HasAttrId(obj, &PyId_value)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5698 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5699 tmp = _PyObject_GetAttrId(obj, &PyId_value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5700 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5701 res = obj2ast_expr(tmp, &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5702 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5703 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5704 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5705 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5706 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5707 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5708 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5709 if (_PyObject_HasAttrId(obj, &PyId_attr)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5710 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5711 tmp = _PyObject_GetAttrId(obj, &PyId_attr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5712 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5713 res = obj2ast_identifier(tmp, &attr, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5714 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5715 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5716 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5717 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5718 PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5719 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5720 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5721 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5722 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5723 tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5724 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5725 res = obj2ast_expr_context(tmp, &ctx, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5726 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5727 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5728 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5729 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5730 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5731 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5732 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5733 *out = Attribute(value, attr, ctx, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5734 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5735 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5736 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5737 isinstance = PyObject_IsInstance(obj, (PyObject*)Subscript_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5738 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5739 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5740 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5741 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5742 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5743 slice_ty slice;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5744 expr_context_ty ctx;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5745
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5746 if (_PyObject_HasAttrId(obj, &PyId_value)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5747 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5748 tmp = _PyObject_GetAttrId(obj, &PyId_value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5749 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5750 res = obj2ast_expr(tmp, &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5751 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5752 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5753 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5754 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5755 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5756 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5757 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5758 if (_PyObject_HasAttrId(obj, &PyId_slice)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5759 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5760 tmp = _PyObject_GetAttrId(obj, &PyId_slice);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5761 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5762 res = obj2ast_slice(tmp, &slice, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5763 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5764 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5765 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5766 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5767 PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5768 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5769 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5770 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5771 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5772 tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5773 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5774 res = obj2ast_expr_context(tmp, &ctx, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5775 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5776 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5777 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5778 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5779 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5780 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5781 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5782 *out = Subscript(value, slice, ctx, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5783 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5784 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5785 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5786 isinstance = PyObject_IsInstance(obj, (PyObject*)Starred_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5787 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5788 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5789 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5790 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5791 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5792 expr_context_ty ctx;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5793
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5794 if (_PyObject_HasAttrId(obj, &PyId_value)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5795 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5796 tmp = _PyObject_GetAttrId(obj, &PyId_value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5797 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5798 res = obj2ast_expr(tmp, &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5799 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5800 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5801 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5802 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5803 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5804 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5805 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5806 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5807 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5808 tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5809 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5810 res = obj2ast_expr_context(tmp, &ctx, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5811 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5812 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5813 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5814 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5815 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5816 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5817 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5818 *out = Starred(value, ctx, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5819 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5820 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5821 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5822 isinstance = PyObject_IsInstance(obj, (PyObject*)Name_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5823 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5824 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5825 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5826 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5827 identifier id;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5828 expr_context_ty ctx;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5829
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5830 if (_PyObject_HasAttrId(obj, &PyId_id)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5831 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5832 tmp = _PyObject_GetAttrId(obj, &PyId_id);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5833 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5834 res = obj2ast_identifier(tmp, &id, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5835 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5836 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5837 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5838 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5839 PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5840 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5841 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5842 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5843 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5844 tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5845 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5846 res = obj2ast_expr_context(tmp, &ctx, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5847 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5848 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5849 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5850 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5851 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5852 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5853 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5854 *out = Name(id, ctx, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5855 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5856 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5857 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5858 isinstance = PyObject_IsInstance(obj, (PyObject*)List_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5859 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5860 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5861 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5862 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5863 asdl_seq* elts;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5864 expr_context_ty ctx;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5865
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5866 if (_PyObject_HasAttrId(obj, &PyId_elts)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5867 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5868 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5869 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5870 tmp = _PyObject_GetAttrId(obj, &PyId_elts);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5871 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5872 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5873 PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5874 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5875 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5876 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5877 elts = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5878 if (elts == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5879 for (i = 0; i < len; i++) {
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5880 expr_ty value;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5881 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5882 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5883 asdl_seq_SET(elts, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5884 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5885 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5886 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5887 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5888 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from List");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5889 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5890 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5891 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5892 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5893 tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5894 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5895 res = obj2ast_expr_context(tmp, &ctx, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5896 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5897 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5898 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5899 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5900 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5901 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5902 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5903 *out = List(elts, ctx, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5904 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5905 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5906 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5907 isinstance = PyObject_IsInstance(obj, (PyObject*)Tuple_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5908 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5909 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5910 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5911 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5912 asdl_seq* elts;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5913 expr_context_ty ctx;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5914
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5915 if (_PyObject_HasAttrId(obj, &PyId_elts)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5916 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5917 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5918 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5919 tmp = _PyObject_GetAttrId(obj, &PyId_elts);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5920 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5921 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5922 PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5923 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5924 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5925 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5926 elts = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5927 if (elts == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5928 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5929 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5930 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5931 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5932 asdl_seq_SET(elts, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5933 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5934 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5935 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5936 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5937 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Tuple");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5938 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5939 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5940 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5941 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5942 tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5943 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5944 res = obj2ast_expr_context(tmp, &ctx, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5945 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5946 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5947 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5948 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5949 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5950 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5951 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5952 *out = Tuple(elts, ctx, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5953 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5954 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5955 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5956
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5957 PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5958 failed:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5959 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5960 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5961 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5962
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5963 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5964 obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5965 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5966 int isinstance;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5967
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5968 isinstance = PyObject_IsInstance(obj, (PyObject *)Load_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5969 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5970 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5971 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5972 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5973 *out = Load;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5974 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5975 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5976 isinstance = PyObject_IsInstance(obj, (PyObject *)Store_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5977 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5978 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5979 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5980 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5981 *out = Store;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5982 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5983 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5984 isinstance = PyObject_IsInstance(obj, (PyObject *)Del_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5985 if (isinstance == -1) {
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5986 return 1;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5987 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5988 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5989 *out = Del;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5990 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5991 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5992 isinstance = PyObject_IsInstance(obj, (PyObject *)AugLoad_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5993 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5994 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5995 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5996 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5997 *out = AugLoad;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5998 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5999 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6000 isinstance = PyObject_IsInstance(obj, (PyObject *)AugStore_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6001 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6002 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6003 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6004 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6005 *out = AugStore;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6006 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6007 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6008 isinstance = PyObject_IsInstance(obj, (PyObject *)Param_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6009 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6010 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6011 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6012 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6013 *out = Param;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6014 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6015 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6016
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6017 PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6018 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6019 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6020
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6021 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6022 obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6023 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6024 int isinstance;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6025
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6026 PyObject *tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6027
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6028 if (obj == Py_None) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6029 *out = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6030 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6031 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6032 isinstance = PyObject_IsInstance(obj, (PyObject*)Slice_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6033 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6034 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6035 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6036 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6037 expr_ty lower;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6038 expr_ty upper;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6039 expr_ty step;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6040
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6041 if (_PyObject_HasAttrId(obj, &PyId_lower)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6042 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6043 tmp = _PyObject_GetAttrId(obj, &PyId_lower);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6044 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6045 res = obj2ast_expr(tmp, &lower, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6046 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6047 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6048 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6049 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6050 lower = NULL;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
6051 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6052 if (_PyObject_HasAttrId(obj, &PyId_upper)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6053 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6054 tmp = _PyObject_GetAttrId(obj, &PyId_upper);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6055 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6056 res = obj2ast_expr(tmp, &upper, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6057 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6058 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6059 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6060 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6061 upper = NULL;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6062 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6063 if (_PyObject_HasAttrId(obj, &PyId_step)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6064 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6065 tmp = _PyObject_GetAttrId(obj, &PyId_step);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6066 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6067 res = obj2ast_expr(tmp, &step, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6068 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6069 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6070 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6071 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6072 step = NULL;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
6073 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6074 *out = Slice(lower, upper, step, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6075 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6076 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6077 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6078 isinstance = PyObject_IsInstance(obj, (PyObject*)ExtSlice_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6079 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6080 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6081 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6082 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6083 asdl_seq* dims;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6084
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6085 if (_PyObject_HasAttrId(obj, &PyId_dims)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6086 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6087 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6088 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6089 tmp = _PyObject_GetAttrId(obj, &PyId_dims);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6090 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6091 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6092 PyErr_Format(PyExc_TypeError, "ExtSlice field \"dims\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6093 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6094 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6095 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6096 dims = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6097 if (dims == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6098 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6099 slice_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6100 res = obj2ast_slice(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6101 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6102 asdl_seq_SET(dims, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6103 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6104 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6105 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6106 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6107 PyErr_SetString(PyExc_TypeError, "required field \"dims\" missing from ExtSlice");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6108 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6109 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6110 *out = ExtSlice(dims, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6111 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6112 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6113 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6114 isinstance = PyObject_IsInstance(obj, (PyObject*)Index_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6115 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6116 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6117 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6118 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6119 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6120
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6121 if (_PyObject_HasAttrId(obj, &PyId_value)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6122 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6123 tmp = _PyObject_GetAttrId(obj, &PyId_value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6124 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6125 res = obj2ast_expr(tmp, &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6126 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6127 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6128 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6129 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6130 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Index");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6131 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
6132 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6133 *out = Index(value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6134 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6135 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6136 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6137
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6138 PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %R", obj);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6139 failed:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6140 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6141 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6142 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6143
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6144 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6145 obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6146 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6147 int isinstance;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6148
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6149 isinstance = PyObject_IsInstance(obj, (PyObject *)And_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6150 if (isinstance == -1) {
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6151 return 1;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6152 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6153 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6154 *out = And;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6155 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6156 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6157 isinstance = PyObject_IsInstance(obj, (PyObject *)Or_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6158 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6159 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6160 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6161 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6162 *out = Or;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6163 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6164 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6165
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6166 PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6167 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6168 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6169
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6170 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6171 obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6172 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6173 int isinstance;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6174
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6175 isinstance = PyObject_IsInstance(obj, (PyObject *)Add_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6176 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6177 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6178 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6179 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6180 *out = Add;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6181 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6182 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6183 isinstance = PyObject_IsInstance(obj, (PyObject *)Sub_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6184 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6185 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6186 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6187 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6188 *out = Sub;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6189 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6190 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6191 isinstance = PyObject_IsInstance(obj, (PyObject *)Mult_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6192 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6193 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6194 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6195 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6196 *out = Mult;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6197 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6198 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6199 isinstance = PyObject_IsInstance(obj, (PyObject *)Div_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6200 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6201 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6202 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6203 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6204 *out = Div;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6205 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6206 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6207 isinstance = PyObject_IsInstance(obj, (PyObject *)Mod_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6208 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6209 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6210 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6211 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6212 *out = Mod;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6213 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6214 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6215 isinstance = PyObject_IsInstance(obj, (PyObject *)Pow_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6216 if (isinstance == -1) {
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6217 return 1;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6218 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6219 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6220 *out = Pow;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6221 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6222 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6223 isinstance = PyObject_IsInstance(obj, (PyObject *)LShift_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6224 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6225 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6226 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6227 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6228 *out = LShift;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6229 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6230 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6231 isinstance = PyObject_IsInstance(obj, (PyObject *)RShift_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6232 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6233 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6234 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6235 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6236 *out = RShift;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6237 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6238 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6239 isinstance = PyObject_IsInstance(obj, (PyObject *)BitOr_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6240 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6241 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6242 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6243 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6244 *out = BitOr;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6245 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6246 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6247 isinstance = PyObject_IsInstance(obj, (PyObject *)BitXor_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6248 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6249 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6250 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6251 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6252 *out = BitXor;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6253 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6254 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6255 isinstance = PyObject_IsInstance(obj, (PyObject *)BitAnd_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6256 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6257 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6258 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6259 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6260 *out = BitAnd;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6261 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6262 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6263 isinstance = PyObject_IsInstance(obj, (PyObject *)FloorDiv_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6264 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6265 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6266 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6267 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6268 *out = FloorDiv;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6269 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6270 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6271
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6272 PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6273 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6274 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6275
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6276 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6277 obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6278 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6279 int isinstance;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6280
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6281 isinstance = PyObject_IsInstance(obj, (PyObject *)Invert_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6282 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6283 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6284 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6285 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6286 *out = Invert;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6287 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6288 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6289 isinstance = PyObject_IsInstance(obj, (PyObject *)Not_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6290 if (isinstance == -1) {
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6291 return 1;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6292 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6293 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6294 *out = Not;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6295 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6296 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6297 isinstance = PyObject_IsInstance(obj, (PyObject *)UAdd_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6298 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6299 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6300 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6301 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6302 *out = UAdd;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6303 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6304 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6305 isinstance = PyObject_IsInstance(obj, (PyObject *)USub_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6306 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6307 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6308 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6309 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6310 *out = USub;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6311 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6312 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6313
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6314 PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6315 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6316 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6317
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6318 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6319 obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6320 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6321 int isinstance;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6322
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6323 isinstance = PyObject_IsInstance(obj, (PyObject *)Eq_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6324 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6325 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6326 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6327 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6328 *out = Eq;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6329 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6330 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6331 isinstance = PyObject_IsInstance(obj, (PyObject *)NotEq_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6332 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6333 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6334 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6335 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6336 *out = NotEq;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6337 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6338 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6339 isinstance = PyObject_IsInstance(obj, (PyObject *)Lt_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6340 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6341 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6342 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6343 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6344 *out = Lt;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6345 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6346 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6347 isinstance = PyObject_IsInstance(obj, (PyObject *)LtE_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6348 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6349 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6350 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6351 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6352 *out = LtE;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6353 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6354 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6355 isinstance = PyObject_IsInstance(obj, (PyObject *)Gt_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6356 if (isinstance == -1) {
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6357 return 1;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6358 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6359 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6360 *out = Gt;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6361 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6362 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6363 isinstance = PyObject_IsInstance(obj, (PyObject *)GtE_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6364 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6365 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6366 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6367 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6368 *out = GtE;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6369 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6370 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6371 isinstance = PyObject_IsInstance(obj, (PyObject *)Is_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6372 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6373 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6374 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6375 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6376 *out = Is;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6377 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6378 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6379 isinstance = PyObject_IsInstance(obj, (PyObject *)IsNot_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6380 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6381 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6382 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6383 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6384 *out = IsNot;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6385 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6386 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6387 isinstance = PyObject_IsInstance(obj, (PyObject *)In_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6388 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6389 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6390 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6391 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6392 *out = In;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6393 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6394 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6395 isinstance = PyObject_IsInstance(obj, (PyObject *)NotIn_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6396 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6397 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6398 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6399 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6400 *out = NotIn;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6401 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6402 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6403
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6404 PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6405 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6406 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6407
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6408 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6409 obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6410 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6411 PyObject* tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6412 expr_ty target;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6413 expr_ty iter;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6414 asdl_seq* ifs;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6415
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6416 if (_PyObject_HasAttrId(obj, &PyId_target)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6417 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6418 tmp = _PyObject_GetAttrId(obj, &PyId_target);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6419 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6420 res = obj2ast_expr(tmp, &target, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6421 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6422 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6423 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6424 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6425 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6426 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6427 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6428 if (_PyObject_HasAttrId(obj, &PyId_iter)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6429 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6430 tmp = _PyObject_GetAttrId(obj, &PyId_iter);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6431 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6432 res = obj2ast_expr(tmp, &iter, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6433 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6434 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6435 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6436 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6437 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6438 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6439 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6440 if (_PyObject_HasAttrId(obj, &PyId_ifs)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6441 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6442 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6443 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6444 tmp = _PyObject_GetAttrId(obj, &PyId_ifs);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6445 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6446 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6447 PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6448 goto failed;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6449 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6450 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6451 ifs = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6452 if (ifs == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6453 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6454 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6455 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6456 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6457 asdl_seq_SET(ifs, i, value);
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6458 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6459 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6460 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6461 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6462 PyErr_SetString(PyExc_TypeError, "required field \"ifs\" missing from comprehension");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6463 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6464 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6465 *out = comprehension(target, iter, ifs, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6466 return 0;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6467 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6468 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6469 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6470 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6471
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6472 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6473 obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6474 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6475 int isinstance;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6476
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6477 PyObject *tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6478 int lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6479 int col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6480
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6481 if (obj == Py_None) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6482 *out = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6483 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6484 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6485 if (_PyObject_HasAttrId(obj, &PyId_lineno)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6486 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6487 tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6488 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6489 res = obj2ast_int(tmp, &lineno, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6490 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6491 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6492 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6493 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6494 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6495 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6496 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6497 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6498 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6499 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6500 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6501 res = obj2ast_int(tmp, &col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6502 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6503 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6504 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6505 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6506 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6507 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6508 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6509 isinstance = PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6510 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6511 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6512 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6513 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6514 expr_ty type;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6515 identifier name;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6516 asdl_seq* body;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6517
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6518 if (_PyObject_HasAttrId(obj, &PyId_type)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6519 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6520 tmp = _PyObject_GetAttrId(obj, &PyId_type);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6521 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6522 res = obj2ast_expr(tmp, &type, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6523 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6524 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6525 tmp = NULL;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6526 } else {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6527 type = NULL;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
6528 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6529 if (_PyObject_HasAttrId(obj, &PyId_name)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6530 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6531 tmp = _PyObject_GetAttrId(obj, &PyId_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6532 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6533 res = obj2ast_identifier(tmp, &name, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6534 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6535 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6536 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6537 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6538 name = NULL;
46231
81ee270a6eb5 Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46229
diff changeset
6539 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6540 if (_PyObject_HasAttrId(obj, &PyId_body)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6541 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6542 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6543 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6544 tmp = _PyObject_GetAttrId(obj, &PyId_body);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6545 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6546 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6547 PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6548 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6549 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6550 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6551 body = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6552 if (body == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6553 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6554 stmt_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6555 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6556 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6557 asdl_seq_SET(body, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6558 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6559 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6560 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6561 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6562 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ExceptHandler");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6563 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6564 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6565 *out = ExceptHandler(type, name, body, lineno, col_offset, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6566 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6567 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6568 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6569
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6570 PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6571 failed:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6572 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6573 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6574 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6575
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6576 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6577 obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6578 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6579 PyObject* tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6580 asdl_seq* args;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6581 identifier vararg;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6582 expr_ty varargannotation;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6583 asdl_seq* kwonlyargs;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6584 identifier kwarg;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6585 expr_ty kwargannotation;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6586 asdl_seq* defaults;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6587 asdl_seq* kw_defaults;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6588
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6589 if (_PyObject_HasAttrId(obj, &PyId_args)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6590 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6591 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6592 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6593 tmp = _PyObject_GetAttrId(obj, &PyId_args);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6594 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6595 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6596 PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6597 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6598 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6599 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6600 args = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6601 if (args == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6602 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6603 arg_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6604 res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6605 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6606 asdl_seq_SET(args, i, value);
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6607 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6608 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6609 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6610 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6611 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from arguments");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6612 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6613 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6614 if (_PyObject_HasAttrId(obj, &PyId_vararg)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6615 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6616 tmp = _PyObject_GetAttrId(obj, &PyId_vararg);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6617 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6618 res = obj2ast_identifier(tmp, &vararg, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6619 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6620 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6621 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6622 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6623 vararg = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6624 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6625 if (_PyObject_HasAttrId(obj, &PyId_varargannotation)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6626 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6627 tmp = _PyObject_GetAttrId(obj, &PyId_varargannotation);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6628 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6629 res = obj2ast_expr(tmp, &varargannotation, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6630 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6631 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6632 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6633 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6634 varargannotation = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6635 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6636 if (_PyObject_HasAttrId(obj, &PyId_kwonlyargs)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6637 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6638 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6639 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6640 tmp = _PyObject_GetAttrId(obj, &PyId_kwonlyargs);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6641 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6642 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6643 PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6644 goto failed;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6645 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6646 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6647 kwonlyargs = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6648 if (kwonlyargs == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6649 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6650 arg_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6651 res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6652 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6653 asdl_seq_SET(kwonlyargs, i, value);
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6654 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6655 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6656 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6657 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6658 PyErr_SetString(PyExc_TypeError, "required field \"kwonlyargs\" missing from arguments");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6659 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6660 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6661 if (_PyObject_HasAttrId(obj, &PyId_kwarg)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6662 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6663 tmp = _PyObject_GetAttrId(obj, &PyId_kwarg);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6664 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6665 res = obj2ast_identifier(tmp, &kwarg, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6666 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6667 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6668 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6669 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6670 kwarg = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6671 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6672 if (_PyObject_HasAttrId(obj, &PyId_kwargannotation)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6673 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6674 tmp = _PyObject_GetAttrId(obj, &PyId_kwargannotation);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6675 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6676 res = obj2ast_expr(tmp, &kwargannotation, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6677 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6678 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6679 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6680 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6681 kwargannotation = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6682 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6683 if (_PyObject_HasAttrId(obj, &PyId_defaults)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6684 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6685 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6686 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6687 tmp = _PyObject_GetAttrId(obj, &PyId_defaults);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6688 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6689 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6690 PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6691 goto failed;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6692 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6693 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6694 defaults = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6695 if (defaults == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6696 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6697 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6698 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6699 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6700 asdl_seq_SET(defaults, i, value);
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6701 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6702 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6703 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6704 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6705 PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6706 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6707 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6708 if (_PyObject_HasAttrId(obj, &PyId_kw_defaults)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6709 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6710 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6711 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6712 tmp = _PyObject_GetAttrId(obj, &PyId_kw_defaults);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6713 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6714 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6715 PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6716 goto failed;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6717 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6718 len = PyList_GET_SIZE(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6719 kw_defaults = asdl_seq_new(len, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6720 if (kw_defaults == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6721 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6722 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6723 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6724 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6725 asdl_seq_SET(kw_defaults, i, value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6726 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6727 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6728 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6729 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6730 PyErr_SetString(PyExc_TypeError, "required field \"kw_defaults\" missing from arguments");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6731 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6732 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6733 *out = arguments(args, vararg, varargannotation, kwonlyargs, kwarg,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6734 kwargannotation, defaults, kw_defaults, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6735 return 0;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6736 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6737 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6738 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6739 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6740
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6741 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6742 obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6743 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6744 PyObject* tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6745 identifier arg;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6746 expr_ty annotation;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6747
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6748 if (_PyObject_HasAttrId(obj, &PyId_arg)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6749 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6750 tmp = _PyObject_GetAttrId(obj, &PyId_arg);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6751 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6752 res = obj2ast_identifier(tmp, &arg, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6753 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6754 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6755 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6756 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6757 PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6758 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6759 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6760 if (_PyObject_HasAttrId(obj, &PyId_annotation)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6761 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6762 tmp = _PyObject_GetAttrId(obj, &PyId_annotation);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6763 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6764 res = obj2ast_expr(tmp, &annotation, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6765 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6766 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6767 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6768 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6769 annotation = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6770 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6771 *out = arg(arg, annotation, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6772 return 0;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6773 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6774 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6775 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6776 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6777
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6778 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6779 obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6780 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6781 PyObject* tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6782 identifier arg;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6783 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6784
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6785 if (_PyObject_HasAttrId(obj, &PyId_arg)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6786 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6787 tmp = _PyObject_GetAttrId(obj, &PyId_arg);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6788 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6789 res = obj2ast_identifier(tmp, &arg, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6790 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6791 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6792 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6793 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6794 PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from keyword");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6795 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6796 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6797 if (_PyObject_HasAttrId(obj, &PyId_value)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6798 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6799 tmp = _PyObject_GetAttrId(obj, &PyId_value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6800 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6801 res = obj2ast_expr(tmp, &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6802 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6803 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6804 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6805 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6806 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6807 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6808 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6809 *out = keyword(arg, value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6810 return 0;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6811 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6812 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6813 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6814 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6815
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6816 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6817 obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6818 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6819 PyObject* tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6820 identifier name;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6821 identifier asname;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6822
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6823 if (_PyObject_HasAttrId(obj, &PyId_name)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6824 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6825 tmp = _PyObject_GetAttrId(obj, &PyId_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6826 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6827 res = obj2ast_identifier(tmp, &name, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6828 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6829 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6830 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6831 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6832 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6833 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6834 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6835 if (_PyObject_HasAttrId(obj, &PyId_asname)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6836 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6837 tmp = _PyObject_GetAttrId(obj, &PyId_asname);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6838 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6839 res = obj2ast_identifier(tmp, &asname, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6840 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6841 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6842 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6843 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6844 asname = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6845 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6846 *out = alias(name, asname, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6847 return 0;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6848 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6849 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6850 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6851 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6852
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
6853 int
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
6854 obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena)
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
6855 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6856 PyObject* tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6857 expr_ty context_expr;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6858 expr_ty optional_vars;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6859
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6860 if (_PyObject_HasAttrId(obj, &PyId_context_expr)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6861 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6862 tmp = _PyObject_GetAttrId(obj, &PyId_context_expr);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6863 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6864 res = obj2ast_expr(tmp, &context_expr, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6865 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6866 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6867 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6868 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6869 PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6870 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6871 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6872 if (_PyObject_HasAttrId(obj, &PyId_optional_vars)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6873 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6874 tmp = _PyObject_GetAttrId(obj, &PyId_optional_vars);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6875 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6876 res = obj2ast_expr(tmp, &optional_vars, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6877 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6878 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6879 tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6880 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6881 optional_vars = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6882 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6883 *out = withitem(context_expr, optional_vars, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6884 return 0;
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
6885 failed:
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6886 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6887 return 1;
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
6888 }
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
6889
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6890
47580
94f64f11fdd0 Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents: 47301
diff changeset
6891 static struct PyModuleDef _astmodule = {
94f64f11fdd0 Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents: 47301
diff changeset
6892 PyModuleDef_HEAD_INIT, "_ast"
94f64f11fdd0 Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents: 47301
diff changeset
6893 };
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
6894 PyMODINIT_FUNC
47580
94f64f11fdd0 Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents: 47301
diff changeset
6895 PyInit__ast(void)
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
6896 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6897 PyObject *m, *d;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6898 if (!init_types()) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6899 m = PyModule_Create(&_astmodule);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6900 if (!m) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6901 d = PyModule_GetDict(m);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6902 if (PyDict_SetItemString(d, "AST", (PyObject*)&AST_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6903 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6904 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6905 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6906 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6907 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6908 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) <
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6909 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6910 if (PyDict_SetItemString(d, "Expression", (PyObject*)Expression_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6911 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6912 if (PyDict_SetItemString(d, "Suite", (PyObject*)Suite_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6913 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6914 if (PyDict_SetItemString(d, "stmt", (PyObject*)stmt_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6915 if (PyDict_SetItemString(d, "FunctionDef", (PyObject*)FunctionDef_type) <
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6916 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6917 if (PyDict_SetItemString(d, "ClassDef", (PyObject*)ClassDef_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6918 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6919 if (PyDict_SetItemString(d, "Return", (PyObject*)Return_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6920 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6921 if (PyDict_SetItemString(d, "Delete", (PyObject*)Delete_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6922 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6923 if (PyDict_SetItemString(d, "Assign", (PyObject*)Assign_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6924 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6925 if (PyDict_SetItemString(d, "AugAssign", (PyObject*)AugAssign_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6926 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6927 if (PyDict_SetItemString(d, "For", (PyObject*)For_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6928 if (PyDict_SetItemString(d, "While", (PyObject*)While_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6929 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6930 if (PyDict_SetItemString(d, "If", (PyObject*)If_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6931 if (PyDict_SetItemString(d, "With", (PyObject*)With_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6932 if (PyDict_SetItemString(d, "Raise", (PyObject*)Raise_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6933 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6934 if (PyDict_SetItemString(d, "Try", (PyObject*)Try_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6935 if (PyDict_SetItemString(d, "Assert", (PyObject*)Assert_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6936 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6937 if (PyDict_SetItemString(d, "Import", (PyObject*)Import_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6938 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6939 if (PyDict_SetItemString(d, "ImportFrom", (PyObject*)ImportFrom_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6940 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6941 if (PyDict_SetItemString(d, "Global", (PyObject*)Global_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6942 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6943 if (PyDict_SetItemString(d, "Nonlocal", (PyObject*)Nonlocal_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6944 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6945 if (PyDict_SetItemString(d, "Expr", (PyObject*)Expr_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6946 if (PyDict_SetItemString(d, "Pass", (PyObject*)Pass_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6947 if (PyDict_SetItemString(d, "Break", (PyObject*)Break_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6948 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6949 if (PyDict_SetItemString(d, "Continue", (PyObject*)Continue_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6950 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6951 if (PyDict_SetItemString(d, "expr", (PyObject*)expr_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6952 if (PyDict_SetItemString(d, "BoolOp", (PyObject*)BoolOp_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6953 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6954 if (PyDict_SetItemString(d, "BinOp", (PyObject*)BinOp_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6955 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6956 if (PyDict_SetItemString(d, "UnaryOp", (PyObject*)UnaryOp_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6957 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6958 if (PyDict_SetItemString(d, "Lambda", (PyObject*)Lambda_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6959 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6960 if (PyDict_SetItemString(d, "IfExp", (PyObject*)IfExp_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6961 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6962 if (PyDict_SetItemString(d, "Dict", (PyObject*)Dict_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6963 if (PyDict_SetItemString(d, "Set", (PyObject*)Set_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6964 if (PyDict_SetItemString(d, "ListComp", (PyObject*)ListComp_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6965 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6966 if (PyDict_SetItemString(d, "SetComp", (PyObject*)SetComp_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6967 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6968 if (PyDict_SetItemString(d, "DictComp", (PyObject*)DictComp_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6969 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6970 if (PyDict_SetItemString(d, "GeneratorExp", (PyObject*)GeneratorExp_type) <
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6971 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6972 if (PyDict_SetItemString(d, "Yield", (PyObject*)Yield_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6973 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6974 if (PyDict_SetItemString(d, "YieldFrom", (PyObject*)YieldFrom_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6975 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6976 if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6977 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6978 if (PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6979 if (PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6980 if (PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6981 if (PyDict_SetItemString(d, "Bytes", (PyObject*)Bytes_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6982 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6983 if (PyDict_SetItemString(d, "Ellipsis", (PyObject*)Ellipsis_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6984 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6985 if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6986 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6987 if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6988 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6989 if (PyDict_SetItemString(d, "Starred", (PyObject*)Starred_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6990 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6991 if (PyDict_SetItemString(d, "Name", (PyObject*)Name_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6992 if (PyDict_SetItemString(d, "List", (PyObject*)List_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6993 if (PyDict_SetItemString(d, "Tuple", (PyObject*)Tuple_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6994 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6995 if (PyDict_SetItemString(d, "expr_context", (PyObject*)expr_context_type) <
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6996 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6997 if (PyDict_SetItemString(d, "Load", (PyObject*)Load_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6998 if (PyDict_SetItemString(d, "Store", (PyObject*)Store_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6999 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7000 if (PyDict_SetItemString(d, "Del", (PyObject*)Del_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7001 if (PyDict_SetItemString(d, "AugLoad", (PyObject*)AugLoad_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7002 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7003 if (PyDict_SetItemString(d, "AugStore", (PyObject*)AugStore_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7004 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7005 if (PyDict_SetItemString(d, "Param", (PyObject*)Param_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7006 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7007 if (PyDict_SetItemString(d, "slice", (PyObject*)slice_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7008 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7009 if (PyDict_SetItemString(d, "Slice", (PyObject*)Slice_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7010 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7011 if (PyDict_SetItemString(d, "ExtSlice", (PyObject*)ExtSlice_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7012 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7013 if (PyDict_SetItemString(d, "Index", (PyObject*)Index_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7014 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7015 if (PyDict_SetItemString(d, "boolop", (PyObject*)boolop_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7016 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7017 if (PyDict_SetItemString(d, "And", (PyObject*)And_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7018 if (PyDict_SetItemString(d, "Or", (PyObject*)Or_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7019 if (PyDict_SetItemString(d, "operator", (PyObject*)operator_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7020 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7021 if (PyDict_SetItemString(d, "Add", (PyObject*)Add_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7022 if (PyDict_SetItemString(d, "Sub", (PyObject*)Sub_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7023 if (PyDict_SetItemString(d, "Mult", (PyObject*)Mult_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7024 if (PyDict_SetItemString(d, "Div", (PyObject*)Div_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7025 if (PyDict_SetItemString(d, "Mod", (PyObject*)Mod_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7026 if (PyDict_SetItemString(d, "Pow", (PyObject*)Pow_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7027 if (PyDict_SetItemString(d, "LShift", (PyObject*)LShift_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7028 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7029 if (PyDict_SetItemString(d, "RShift", (PyObject*)RShift_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7030 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7031 if (PyDict_SetItemString(d, "BitOr", (PyObject*)BitOr_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7032 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7033 if (PyDict_SetItemString(d, "BitXor", (PyObject*)BitXor_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7034 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7035 if (PyDict_SetItemString(d, "BitAnd", (PyObject*)BitAnd_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7036 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7037 if (PyDict_SetItemString(d, "FloorDiv", (PyObject*)FloorDiv_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7038 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7039 if (PyDict_SetItemString(d, "unaryop", (PyObject*)unaryop_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7040 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7041 if (PyDict_SetItemString(d, "Invert", (PyObject*)Invert_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7042 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7043 if (PyDict_SetItemString(d, "Not", (PyObject*)Not_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7044 if (PyDict_SetItemString(d, "UAdd", (PyObject*)UAdd_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7045 if (PyDict_SetItemString(d, "USub", (PyObject*)USub_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7046 if (PyDict_SetItemString(d, "cmpop", (PyObject*)cmpop_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7047 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7048 if (PyDict_SetItemString(d, "Eq", (PyObject*)Eq_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7049 if (PyDict_SetItemString(d, "NotEq", (PyObject*)NotEq_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7050 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7051 if (PyDict_SetItemString(d, "Lt", (PyObject*)Lt_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7052 if (PyDict_SetItemString(d, "LtE", (PyObject*)LtE_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7053 if (PyDict_SetItemString(d, "Gt", (PyObject*)Gt_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7054 if (PyDict_SetItemString(d, "GtE", (PyObject*)GtE_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7055 if (PyDict_SetItemString(d, "Is", (PyObject*)Is_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7056 if (PyDict_SetItemString(d, "IsNot", (PyObject*)IsNot_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7057 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7058 if (PyDict_SetItemString(d, "In", (PyObject*)In_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7059 if (PyDict_SetItemString(d, "NotIn", (PyObject*)NotIn_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7060 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7061 if (PyDict_SetItemString(d, "comprehension", (PyObject*)comprehension_type)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7062 < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7063 if (PyDict_SetItemString(d, "excepthandler", (PyObject*)excepthandler_type)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7064 < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7065 if (PyDict_SetItemString(d, "ExceptHandler", (PyObject*)ExceptHandler_type)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7066 < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7067 if (PyDict_SetItemString(d, "arguments", (PyObject*)arguments_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7068 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7069 if (PyDict_SetItemString(d, "arg", (PyObject*)arg_type) < 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7070 if (PyDict_SetItemString(d, "keyword", (PyObject*)keyword_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7071 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7072 if (PyDict_SetItemString(d, "alias", (PyObject*)alias_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7073 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7074 if (PyDict_SetItemString(d, "withitem", (PyObject*)withitem_type) < 0)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7075 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7076 return m;
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
7077 }
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
7078
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
7079
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
7080 PyObject* PyAST_mod2obj(mod_ty t)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
7081 {
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
7082 init_types();
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
7083 return ast2obj_mod(t);
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
7084 }
42013
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41825
diff changeset
7085
46227
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7086 /* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7087 mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7088 {
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7089 mod_ty res;
46227
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7090 PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type,
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7091 (PyObject*)Interactive_type};
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7092 char *req_name[] = {"Module", "Expression", "Interactive"};
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
7093 int isinstance;
46227
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7094 assert(0 <= mode && mode <= 2);
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7095
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7096 init_types();
46227
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7097
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
7098 isinstance = PyObject_IsInstance(ast, req_type[mode]);
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
7099 if (isinstance == -1)
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
7100 return NULL;
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
7101 if (!isinstance) {
46227
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7102 PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s",
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7103 req_name[mode], Py_TYPE(ast)->tp_name);
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7104 return NULL;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7105 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7106 if (obj2ast_mod(ast, &res, arena) != 0)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7107 return NULL;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7108 else
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7109 return res;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7110 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7111
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7112 int PyAST_Check(PyObject* obj)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7113 {
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7114 init_types();
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
7115 return PyObject_IsInstance(obj, (PyObject*)&AST_type);
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7116 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7117
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7118