annotate Python/Python-ast.c @ 87353:c8a84eed9155

Remove a commented-out line
author Brett Cannon <brett@python.org>
date Fri, 22 Nov 2013 12:07:43 -0500
parents 142c62a490ce
children
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 };
80738
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
274 static PyTypeObject *NameConstant_type;
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
275 static char *NameConstant_fields[]={
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
276 "value",
80738
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
277 };
39783
7a0ad110e91e Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents: 39782
diff changeset
278 static PyTypeObject *Ellipsis_type;
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
279 static PyTypeObject *Attribute_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
280 _Py_IDENTIFIER(attr);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
281 _Py_IDENTIFIER(ctx);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
282 static char *Attribute_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
283 "value",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
284 "attr",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
285 "ctx",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
286 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
287 static PyTypeObject *Subscript_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
288 _Py_IDENTIFIER(slice);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
289 static char *Subscript_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
290 "value",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
291 "slice",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
292 "ctx",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
293 };
41699
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
294 static PyTypeObject *Starred_type;
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
295 static char *Starred_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
296 "value",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
297 "ctx",
41699
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
298 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
299 static PyTypeObject *Name_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
300 _Py_IDENTIFIER(id);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
301 static char *Name_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
302 "id",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
303 "ctx",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
304 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
305 static PyTypeObject *List_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
306 static char *List_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
307 "elts",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
308 "ctx",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
309 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
310 static PyTypeObject *Tuple_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
311 static char *Tuple_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
312 "elts",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
313 "ctx",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
314 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
315 static PyTypeObject *expr_context_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
316 static PyObject *Load_singleton, *Store_singleton, *Del_singleton,
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
317 *AugLoad_singleton, *AugStore_singleton, *Param_singleton;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
318 static PyObject* ast2obj_expr_context(expr_context_ty);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
319 static PyTypeObject *Load_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
320 static PyTypeObject *Store_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
321 static PyTypeObject *Del_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
322 static PyTypeObject *AugLoad_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
323 static PyTypeObject *AugStore_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
324 static PyTypeObject *Param_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
325 static PyTypeObject *slice_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
326 static PyObject* ast2obj_slice(void*);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
327 static PyTypeObject *Slice_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
328 _Py_IDENTIFIER(lower);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
329 _Py_IDENTIFIER(upper);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
330 _Py_IDENTIFIER(step);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
331 static char *Slice_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
332 "lower",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
333 "upper",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
334 "step",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
335 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
336 static PyTypeObject *ExtSlice_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
337 _Py_IDENTIFIER(dims);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
338 static char *ExtSlice_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
339 "dims",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
340 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
341 static PyTypeObject *Index_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
342 static char *Index_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
343 "value",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
344 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
345 static PyTypeObject *boolop_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
346 static PyObject *And_singleton, *Or_singleton;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
347 static PyObject* ast2obj_boolop(boolop_ty);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
348 static PyTypeObject *And_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
349 static PyTypeObject *Or_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
350 static PyTypeObject *operator_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
351 static PyObject *Add_singleton, *Sub_singleton, *Mult_singleton,
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
352 *Div_singleton, *Mod_singleton, *Pow_singleton, *LShift_singleton,
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
353 *RShift_singleton, *BitOr_singleton, *BitXor_singleton, *BitAnd_singleton,
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
354 *FloorDiv_singleton;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
355 static PyObject* ast2obj_operator(operator_ty);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
356 static PyTypeObject *Add_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
357 static PyTypeObject *Sub_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
358 static PyTypeObject *Mult_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
359 static PyTypeObject *Div_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
360 static PyTypeObject *Mod_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
361 static PyTypeObject *Pow_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
362 static PyTypeObject *LShift_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
363 static PyTypeObject *RShift_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
364 static PyTypeObject *BitOr_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
365 static PyTypeObject *BitXor_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
366 static PyTypeObject *BitAnd_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
367 static PyTypeObject *FloorDiv_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
368 static PyTypeObject *unaryop_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
369 static PyObject *Invert_singleton, *Not_singleton, *UAdd_singleton,
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
370 *USub_singleton;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
371 static PyObject* ast2obj_unaryop(unaryop_ty);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
372 static PyTypeObject *Invert_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
373 static PyTypeObject *Not_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
374 static PyTypeObject *UAdd_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
375 static PyTypeObject *USub_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
376 static PyTypeObject *cmpop_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
377 static PyObject *Eq_singleton, *NotEq_singleton, *Lt_singleton, *LtE_singleton,
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
378 *Gt_singleton, *GtE_singleton, *Is_singleton, *IsNot_singleton, *In_singleton,
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
379 *NotIn_singleton;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
380 static PyObject* ast2obj_cmpop(cmpop_ty);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
381 static PyTypeObject *Eq_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
382 static PyTypeObject *NotEq_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
383 static PyTypeObject *Lt_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
384 static PyTypeObject *LtE_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
385 static PyTypeObject *Gt_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
386 static PyTypeObject *GtE_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
387 static PyTypeObject *Is_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
388 static PyTypeObject *IsNot_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
389 static PyTypeObject *In_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
390 static PyTypeObject *NotIn_type;
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
391 static PyTypeObject *comprehension_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
392 static PyObject* ast2obj_comprehension(void*);
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
393 _Py_IDENTIFIER(ifs);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
394 static char *comprehension_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
395 "target",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
396 "iter",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
397 "ifs",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
398 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
399 static PyTypeObject *excepthandler_type;
46231
81ee270a6eb5 Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46229
diff changeset
400 static char *excepthandler_attributes[] = {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
401 "lineno",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
402 "col_offset",
46231
81ee270a6eb5 Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46229
diff changeset
403 };
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
404 static PyObject* ast2obj_excepthandler(void*);
46231
81ee270a6eb5 Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46229
diff changeset
405 static PyTypeObject *ExceptHandler_type;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
406 _Py_IDENTIFIER(type);
46231
81ee270a6eb5 Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46229
diff changeset
407 static char *ExceptHandler_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
408 "type",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
409 "name",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
410 "body",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
411 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
412 static PyTypeObject *arguments_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
413 static PyObject* ast2obj_arguments(void*);
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
414 _Py_IDENTIFIER(vararg);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
415 _Py_IDENTIFIER(kwonlyargs);
82732
7c5c678e4164 unify some ast.argument's attrs; change Attribute column offset (closes #16795)
Benjamin Peterson <benjamin@python.org>
parents: 81039
diff changeset
416 _Py_IDENTIFIER(kw_defaults);
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
417 _Py_IDENTIFIER(kwarg);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
418 _Py_IDENTIFIER(defaults);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
419 static char *arguments_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
420 "args",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
421 "vararg",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
422 "kwonlyargs",
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
423 "kw_defaults",
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
424 "kwarg",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
425 "defaults",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
426 };
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
427 static PyTypeObject *arg_type;
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
428 static PyObject* ast2obj_arg(void*);
82732
7c5c678e4164 unify some ast.argument's attrs; change Attribute column offset (closes #16795)
Benjamin Peterson <benjamin@python.org>
parents: 81039
diff changeset
429 static char *arg_attributes[] = {
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
430 "lineno",
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
431 "col_offset",
82732
7c5c678e4164 unify some ast.argument's attrs; change Attribute column offset (closes #16795)
Benjamin Peterson <benjamin@python.org>
parents: 81039
diff changeset
432 };
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
433 _Py_IDENTIFIER(arg);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
434 _Py_IDENTIFIER(annotation);
41717
9ad84070b22d Merged revisions 55328-55341 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41699
diff changeset
435 static char *arg_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
436 "arg",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
437 "annotation",
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
438 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
439 static PyTypeObject *keyword_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
440 static PyObject* ast2obj_keyword(void*);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
441 static char *keyword_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
442 "arg",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
443 "value",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
444 };
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
445 static PyTypeObject *alias_type;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
446 static PyObject* ast2obj_alias(void*);
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
447 _Py_IDENTIFIER(asname);
36743
dbf9cc6c36eb Don't pollute namespace as bad as before. All the types are static now.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36726
diff changeset
448 static char *alias_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
449 "name",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
450 "asname",
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
451 };
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
452 static PyTypeObject *withitem_type;
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
453 static PyObject* ast2obj_withitem(void*);
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
454 _Py_IDENTIFIER(context_expr);
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
455 _Py_IDENTIFIER(optional_vars);
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
456 static char *withitem_fields[]={
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
457 "context_expr",
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
458 "optional_vars",
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
459 };
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
460
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
461
75542
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
462 typedef struct {
75567
6bee4eea1efa Try to fix compilation of Python-ast.c on Visual Studio 2008
Victor Stinner <victor.stinner@gmail.com>
parents: 75542
diff changeset
463 PyObject_HEAD
75542
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
464 PyObject *dict;
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
465 } AST_object;
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
466
75686
9e7f6ddc0d76 free AST's dict
Benjamin Peterson <benjamin@python.org>
parents: 75567
diff changeset
467 static void
9e7f6ddc0d76 free AST's dict
Benjamin Peterson <benjamin@python.org>
parents: 75567
diff changeset
468 ast_dealloc(AST_object *self)
9e7f6ddc0d76 free AST's dict
Benjamin Peterson <benjamin@python.org>
parents: 75567
diff changeset
469 {
9e7f6ddc0d76 free AST's dict
Benjamin Peterson <benjamin@python.org>
parents: 75567
diff changeset
470 Py_CLEAR(self->dict);
77998
048d8d9aecf1 Issue #15291: Fix a memory leak where AST nodes where not properly deallocated.
Antoine Pitrou <solipsis@pitrou.net>
parents: 76964
diff changeset
471 Py_TYPE(self)->tp_free(self);
75686
9e7f6ddc0d76 free AST's dict
Benjamin Peterson <benjamin@python.org>
parents: 75567
diff changeset
472 }
9e7f6ddc0d76 free AST's dict
Benjamin Peterson <benjamin@python.org>
parents: 75567
diff changeset
473
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
474 static int
78006
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
475 ast_traverse(AST_object *self, visitproc visit, void *arg)
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
476 {
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
477 Py_VISIT(self->dict);
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
478 return 0;
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
479 }
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
480
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
481 static void
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
482 ast_clear(AST_object *self)
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
483 {
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
484 Py_CLEAR(self->dict);
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
485 }
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
486
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
487 static int
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
488 ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
489 {
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
490 _Py_IDENTIFIER(_fields);
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
491 Py_ssize_t i, numfields = 0;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
492 int res = -1;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
493 PyObject *key, *value, *fields;
72848
81380082d216 Use identifier API for PyObject_GetAttrString.
Martin v. Löwis <martin@v.loewis.de>
parents: 72195
diff changeset
494 fields = _PyObject_GetAttrId((PyObject*)Py_TYPE(self), &PyId__fields);
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
495 if (!fields)
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
496 PyErr_Clear();
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
497 if (fields) {
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
498 numfields = PySequence_Size(fields);
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
499 if (numfields == -1)
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
500 goto cleanup;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
501 }
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
502 res = 0; /* if no error occurs, this stays 0 to the end */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
503 if (PyTuple_GET_SIZE(args) > 0) {
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
504 if (numfields != PyTuple_GET_SIZE(args)) {
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
505 PyErr_Format(PyExc_TypeError, "%.400s constructor takes %s"
49139
6ae2d4b507a2 Merged revisions 66377 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 47580
diff changeset
506 "%zd positional argument%s",
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
507 Py_TYPE(self)->tp_name,
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
508 numfields == 0 ? "" : "either 0 or ",
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
509 numfields, numfields == 1 ? "" : "s");
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
510 res = -1;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
511 goto cleanup;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
512 }
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
513 for (i = 0; i < PyTuple_GET_SIZE(args); i++) {
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
514 /* cannot be reached when fields is NULL */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
515 PyObject *name = PySequence_GetItem(fields, i);
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
516 if (!name) {
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
517 res = -1;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
518 goto cleanup;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
519 }
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
520 res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i));
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
521 Py_DECREF(name);
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
522 if (res < 0)
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
523 goto cleanup;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
524 }
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
525 }
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
526 if (kw) {
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
527 i = 0; /* needed by PyDict_Next */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
528 while (PyDict_Next(kw, &i, &key, &value)) {
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
529 res = PyObject_SetAttr(self, key, value);
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
530 if (res < 0)
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
531 goto cleanup;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
532 }
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
533 }
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
534 cleanup:
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
535 Py_XDECREF(fields);
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
536 return res;
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
537 }
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
538
46233
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
539 /* Pickling support */
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
540 static PyObject *
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
541 ast_type_reduce(PyObject *self, PyObject *unused)
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
542 {
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
543 PyObject *res;
72925
7109f31300fb Rename _Py_identifier to _Py_IDENTIFIER.
Martin v. Löwis <martin@v.loewis.de>
parents: 72848
diff changeset
544 _Py_IDENTIFIER(__dict__);
72848
81380082d216 Use identifier API for PyObject_GetAttrString.
Martin v. Löwis <martin@v.loewis.de>
parents: 72195
diff changeset
545 PyObject *dict = _PyObject_GetAttrId(self, &PyId___dict__);
46233
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
546 if (dict == NULL) {
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
547 if (PyErr_ExceptionMatches(PyExc_AttributeError))
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
548 PyErr_Clear();
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
549 else
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
550 return NULL;
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
551 }
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
552 if (dict) {
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
553 res = Py_BuildValue("O()O", Py_TYPE(self), dict);
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
554 Py_DECREF(dict);
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
555 return res;
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
556 }
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
557 return Py_BuildValue("O()", Py_TYPE(self));
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
558 }
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
559
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
560 static PyMethodDef ast_type_methods[] = {
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
561 {"__reduce__", ast_type_reduce, METH_NOARGS, NULL},
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
562 {NULL}
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
563 };
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
564
75542
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
565 static PyGetSetDef ast_type_getsets[] = {
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
566 {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
567 {NULL}
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
568 };
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
569
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
570 static PyTypeObject AST_type = {
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
571 PyVarObject_HEAD_INIT(&PyType_Type, 0)
46233
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
572 "_ast.AST",
75542
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
573 sizeof(AST_object),
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
574 0,
75686
9e7f6ddc0d76 free AST's dict
Benjamin Peterson <benjamin@python.org>
parents: 75567
diff changeset
575 (destructor)ast_dealloc, /* tp_dealloc */
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
576 0, /* tp_print */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
577 0, /* tp_getattr */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
578 0, /* tp_setattr */
51270
debd14c489b9 Issue #1717: rename tp_compare to tp_reserved. I'll change the
Mark Dickinson <dickinsm@gmail.com>
parents: 50076
diff changeset
579 0, /* tp_reserved */
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
580 0, /* tp_repr */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
581 0, /* tp_as_number */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
582 0, /* tp_as_sequence */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
583 0, /* tp_as_mapping */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
584 0, /* tp_hash */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
585 0, /* tp_call */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
586 0, /* tp_str */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
587 PyObject_GenericGetAttr, /* tp_getattro */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
588 PyObject_GenericSetAttr, /* tp_setattro */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
589 0, /* tp_as_buffer */
78006
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
590 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
591 0, /* tp_doc */
78006
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
592 (traverseproc)ast_traverse, /* tp_traverse */
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
593 (inquiry)ast_clear, /* tp_clear */
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
594 0, /* tp_richcompare */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
595 0, /* tp_weaklistoffset */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
596 0, /* tp_iter */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
597 0, /* tp_iternext */
46233
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
598 ast_type_methods, /* tp_methods */
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
599 0, /* tp_members */
75542
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
600 ast_type_getsets, /* tp_getset */
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
601 0, /* tp_base */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
602 0, /* tp_dict */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
603 0, /* tp_descr_get */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
604 0, /* tp_descr_set */
75542
3877bf2e3235 give the AST class a __dict__
Benjamin Peterson <benjamin@python.org>
parents: 74391
diff changeset
605 offsetof(AST_object, dict),/* tp_dictoffset */
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
606 (initproc)ast_type_init, /* tp_init */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
607 PyType_GenericAlloc, /* tp_alloc */
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
608 PyType_GenericNew, /* tp_new */
78006
85cccc38d01c add gc support to the AST base type (closes #15293)
Benjamin Peterson <benjamin@python.org>
parents: 77998
diff changeset
609 PyObject_GC_Del, /* tp_free */
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
610 };
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
611
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
612
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
613 static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int num_fields)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
614 {
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
615 PyObject *fnames, *result;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
616 int i;
46233
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
617 fnames = PyTuple_New(num_fields);
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
618 if (!fnames) return NULL;
61c92923cf7f Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62048,62050-62051,62055-62066,62068-62074,62076-62078 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46231
diff changeset
619 for (i = 0; i < num_fields; i++) {
42816
872c7c3f0af3 Use unicode for AST attributes
Neal Norwitz <nnorwitz@gmail.com>
parents: 42206
diff changeset
620 PyObject *field = PyUnicode_FromString(fields[i]);
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
621 if (!field) {
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
622 Py_DECREF(fnames);
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
623 return NULL;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
624 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
625 PyTuple_SET_ITEM(fnames, i, field);
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
626 }
62155
600c23127207 Issue #8848: U / U# formats of Py_BuildValue() are just alias to s / s#
Victor Stinner <victor.stinner@haypocalc.com>
parents: 57676
diff changeset
627 result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}",
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
628 type, base, "_fields", fnames, "__module__", "_ast");
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
629 Py_DECREF(fnames);
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
630 return (PyTypeObject*)result;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
631 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
632
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
633 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
634 {
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36794
diff changeset
635 int i, result;
72926
db4aa878cea2 Port SetAttrString/HasAttrString to SetAttrId/GetAttrId.
Martin v. Löwis <martin@v.loewis.de>
parents: 72925
diff changeset
636 _Py_IDENTIFIER(_attributes);
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
637 PyObject *s, *l = PyTuple_New(num_fields);
62566
504c499e8c95 Merged revisions 81465-81466,81468,81679,81735,81760,81868,82183 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 62464
diff changeset
638 if (!l)
504c499e8c95 Merged revisions 81465-81466,81468,81679,81735,81760,81868,82183 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 62464
diff changeset
639 return 0;
504c499e8c95 Merged revisions 81465-81466,81468,81679,81735,81760,81868,82183 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 62464
diff changeset
640 for (i = 0; i < num_fields; i++) {
42816
872c7c3f0af3 Use unicode for AST attributes
Neal Norwitz <nnorwitz@gmail.com>
parents: 42206
diff changeset
641 s = PyUnicode_FromString(attrs[i]);
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
642 if (!s) {
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
643 Py_DECREF(l);
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
644 return 0;
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
645 }
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
646 PyTuple_SET_ITEM(l, i, s);
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
647 }
72926
db4aa878cea2 Port SetAttrString/HasAttrString to SetAttrId/GetAttrId.
Martin v. Löwis <martin@v.loewis.de>
parents: 72925
diff changeset
648 result = _PyObject_SetAttrId((PyObject*)type, &PyId__attributes, l) >= 0;
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36794
diff changeset
649 Py_DECREF(l);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36794
diff changeset
650 return result;
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
651 }
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
652
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
653 /* Conversion AST -> Python */
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
654
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
655 static PyObject* ast2obj_list(asdl_seq *seq, PyObject* (*func)(void*))
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
656 {
76964
c18a1a82bb07 use Py_ssize_t for ast sequence lengths
Benjamin Peterson <benjamin@python.org>
parents: 76948
diff changeset
657 Py_ssize_t i, n = asdl_seq_LEN(seq);
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
658 PyObject *result = PyList_New(n);
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
659 PyObject *value;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
660 if (!result)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
661 return NULL;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
662 for (i = 0; i < n; i++) {
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
663 value = func(asdl_seq_GET(seq, i));
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
664 if (!value) {
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
665 Py_DECREF(result);
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
666 return NULL;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
667 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
668 PyList_SET_ITEM(result, i, value);
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
669 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
670 return result;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
671 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
672
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
673 static PyObject* ast2obj_object(void *o)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
674 {
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
675 if (!o)
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
676 o = Py_None;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
677 Py_INCREF((PyObject*)o);
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
678 return (PyObject*)o;
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
679 }
80738
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
680 #define ast2obj_singleton ast2obj_object
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
681 #define ast2obj_identifier ast2obj_object
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
682 #define ast2obj_string ast2obj_object
71792
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
683 #define ast2obj_bytes ast2obj_object
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
684
40937
6aa1be5dd009 Merged revisions 53912-53951 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40896
diff changeset
685 static PyObject* ast2obj_int(long b)
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
686 {
44099
f324631462a2 Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents: 43755
diff changeset
687 return PyLong_FromLong(b);
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
688 }
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
689
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
690 /* Conversion Python -> AST */
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
691
80738
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
692 static int obj2ast_singleton(PyObject *obj, PyObject** out, PyArena* arena)
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
693 {
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
694 if (obj != Py_None && obj != Py_True && obj != Py_False) {
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
695 PyErr_SetString(PyExc_ValueError,
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
696 "AST singleton must be True, False, or None");
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
697 return 1;
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
698 }
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
699 *out = obj;
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
700 return 0;
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
701 }
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
702
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
703 static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
704 {
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
705 if (obj == Py_None)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
706 obj = NULL;
84855
65121aa79ab3 Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
Christian Heimes <christian@cheimes.de>
parents: 84852
diff changeset
707 if (obj) {
65121aa79ab3 Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
Christian Heimes <christian@cheimes.de>
parents: 84852
diff changeset
708 if (PyArena_AddPyObject(arena, obj) < 0) {
65121aa79ab3 Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
Christian Heimes <christian@cheimes.de>
parents: 84852
diff changeset
709 *out = NULL;
65121aa79ab3 Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
Christian Heimes <christian@cheimes.de>
parents: 84852
diff changeset
710 return -1;
65121aa79ab3 Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
Christian Heimes <christian@cheimes.de>
parents: 84852
diff changeset
711 }
65121aa79ab3 Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
Christian Heimes <christian@cheimes.de>
parents: 84852
diff changeset
712 Py_INCREF(obj);
65121aa79ab3 Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
Christian Heimes <christian@cheimes.de>
parents: 84852
diff changeset
713 }
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
714 *out = obj;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
715 return 0;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
716 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
717
71458
c9ebae3285e3 None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents: 71455
diff changeset
718 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
719 {
71458
c9ebae3285e3 None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents: 71455
diff changeset
720 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
721 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
722 return 1;
3301689bd78d type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents: 68257
diff changeset
723 }
3301689bd78d type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents: 68257
diff changeset
724 return obj2ast_object(obj, out, arena);
3301689bd78d type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents: 68257
diff changeset
725 }
3301689bd78d type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents: 68257
diff changeset
726
3301689bd78d type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents: 68257
diff changeset
727 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
728 {
72154
c8b6d4417274 accept bytes for the AST 'string' type
Benjamin Peterson <benjamin@python.org>
parents: 71458
diff changeset
729 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
730 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
731 return 1;
c9ebae3285e3 None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents: 71455
diff changeset
732 }
c9ebae3285e3 None is ok for identifiers but not strings
Benjamin Peterson <benjamin@python.org>
parents: 71455
diff changeset
733 return obj2ast_object(obj, out, arena);
71454
3301689bd78d type check AST strings and identifiers
Benjamin Peterson <benjamin@python.org>
parents: 68257
diff changeset
734 }
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
735
71792
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
736 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
737 {
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
738 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
739 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
740 return 1;
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
741 }
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
742 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
743 }
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
744
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
745 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
746 {
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
747 int i;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
748 if (!PyLong_Check(obj)) {
73700
470f7d7c57ce Issue #13436: commit regenerated Python-ast.c
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 72154
diff changeset
749 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
750 return 1;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
751 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
752
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
753 i = (int)PyLong_AsLong(obj);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
754 if (i == -1 && PyErr_Occurred())
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
755 return 1;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
756 *out = i;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
757 return 0;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
758 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
759
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
760 static int add_ast_fields(void)
49583
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
761 {
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
762 PyObject *empty_tuple, *d;
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
763 if (PyType_Ready(&AST_type) < 0)
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
764 return -1;
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
765 d = AST_type.tp_dict;
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
766 empty_tuple = PyTuple_New(0);
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
767 if (!empty_tuple ||
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
768 PyDict_SetItemString(d, "_fields", empty_tuple) < 0 ||
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
769 PyDict_SetItemString(d, "_attributes", empty_tuple) < 0) {
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
770 Py_XDECREF(empty_tuple);
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
771 return -1;
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
772 }
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
773 Py_DECREF(empty_tuple);
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
774 return 0;
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
775 }
2a38771cecdd update Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 49139
diff changeset
776
82747
c8ccc0519247 refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents: 82732
diff changeset
777 static int exists_not_none(PyObject *obj, _Py_Identifier *id)
c8ccc0519247 refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents: 82732
diff changeset
778 {
82750
cc7a94efb1b7 bump Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 82747
diff changeset
779 int isnone;
82747
c8ccc0519247 refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents: 82732
diff changeset
780 PyObject *attr = _PyObject_GetAttrId(obj, id);
c8ccc0519247 refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents: 82732
diff changeset
781 if (!attr) {
c8ccc0519247 refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents: 82732
diff changeset
782 PyErr_Clear();
c8ccc0519247 refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents: 82732
diff changeset
783 return 0;
c8ccc0519247 refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents: 82732
diff changeset
784 }
82750
cc7a94efb1b7 bump Python-ast.c
Benjamin Peterson <benjamin@python.org>
parents: 82747
diff changeset
785 isnone = attr == Py_None;
82747
c8ccc0519247 refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents: 82732
diff changeset
786 Py_DECREF(attr);
c8ccc0519247 refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents: 82732
diff changeset
787 return !isnone;
c8ccc0519247 refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents: 82732
diff changeset
788 }
c8ccc0519247 refactor to fix refleaks
Benjamin Peterson <benjamin@python.org>
parents: 82732
diff changeset
789
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
790
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
791 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
792 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
793 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
794 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
795 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
796 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
797 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
798 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
799 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
800 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
801 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
802 1);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
803 if (!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
804 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
805 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
806 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
807 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
808 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
809 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
810 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
811 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
812 5);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
813 if (!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
814 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
815 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
816 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
817 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
818 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
819 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
820 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
821 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
822 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
823 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
824 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
825 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
826 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
827 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
828 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
829 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
830 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
831 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
832 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
833 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
834 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
835 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
836 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
837 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
838 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
839 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
840 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
841 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
842 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
843 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
844 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
845 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
846 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
847 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
848 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
849 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
850 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
851 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
852 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
853 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
854 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
855 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
856 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
857 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
858 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
859 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
860 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
861 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
862 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
863 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
864 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
865 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
866 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
867 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
868 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
869 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
870 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
871 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
872 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
873 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
874 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
875 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
876 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
877 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
878 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
879 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
880 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
881 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
882 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
883 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
884 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
885 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
886 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
887 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
888 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
889 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
890 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
891 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
892 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
893 if (!Bytes_type) return 0;
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
894 NameConstant_type = make_type("NameConstant", expr_type,
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
895 NameConstant_fields, 1);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
896 if (!NameConstant_type) return 0;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
897 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
898 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
899 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
900 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
901 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
902 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
903 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
904 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
905 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
906 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
907 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
908 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
909 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
910 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
911 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
912 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
913 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
914 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
915 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
916 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
917 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
918 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
919 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
920 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
921 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
922 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
923 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
924 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
925 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
926 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
927 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
928 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
929 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
930 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
931 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
932 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
933 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
934 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
935 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
936 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
937 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
938 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
939 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
940 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
941 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
942 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
943 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
944 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
945 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
946 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
947 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
948 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
949 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
950 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
951 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
952 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
953 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
954 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
955 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
956 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
957 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
958 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
959 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
960 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
961 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
962 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
963 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
964 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
965 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
966 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
967 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
968 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
969 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
970 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
971 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
972 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
973 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
974 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
975 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
976 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
977 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
978 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
979 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
980 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
981 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
982 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
983 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
984 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
985 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
986 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
987 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
988 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
989 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
990 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
991 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
992 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
993 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
994 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
995 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
996 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
997 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
998 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
999 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
1000 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
1001 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
1002 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
1003 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
1004 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
1005 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
1006 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
1007 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
1008 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
1009 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
1010 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
1011 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
1012 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
1013 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
1014 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
1015 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
1016 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
1017 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
1018 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
1019 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
1020 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
1021 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
1022 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
1023 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
1024 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
1025 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
1026 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
1027 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
1028 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
1029 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
1030 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
1031 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
1032 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
1033 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
1034 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
1035 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
1036 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
1037 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
1038 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
1039 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
1040 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
1041 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
1042 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
1043 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
1044 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
1045 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
1046 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
1047 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
1048 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
1049 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
1050 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
1051 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
1052 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
1053 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
1054 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
1055 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
1056 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
1057 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
1058 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
1059 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
1060 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
1061 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
1062 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
1063 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
1064 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
1065 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
1066 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
1067 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
1068 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
1069 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
1070 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
1071 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
1072 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
1073 if (!comprehension_type) return 0;
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1074 if (!add_attributes(comprehension_type, NULL, 0)) return 0;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1075 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
1076 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
1077 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
1078 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1079 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
1080 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
1081 if (!ExceptHandler_type) return 0;
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1082 arguments_type = make_type("arguments", &AST_type, arguments_fields, 6);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1083 if (!arguments_type) return 0;
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1084 if (!add_attributes(arguments_type, NULL, 0)) return 0;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1085 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
1086 if (!arg_type) return 0;
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1087 if (!add_attributes(arg_type, arg_attributes, 2)) return 0;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1088 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
1089 if (!keyword_type) return 0;
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1090 if (!add_attributes(keyword_type, NULL, 0)) return 0;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1091 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
1092 if (!alias_type) return 0;
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1093 if (!add_attributes(alias_type, NULL, 0)) return 0;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1094 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
1095 if (!withitem_type) return 0;
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1096 if (!add_attributes(withitem_type, NULL, 0)) return 0;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1097 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
1098 return 1;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
1099 }
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
1100
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1101 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
1102 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
1103 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
1104 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
1105 arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1106 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
1107 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
1108 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
1109 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
1110 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
1111 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
1112 arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1113 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
1114 arena);
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
1115 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
1116 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
1117 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
1118 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
1119 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
1120
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1121 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
1122 Module(asdl_seq * body, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1123 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1124 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
1125 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
1126 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
1127 return NULL;
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->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
1129 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
1130 return p;
35742
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
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1133 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
1134 Interactive(asdl_seq * body, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1135 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1136 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
1137 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
1138 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
1139 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1140 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
1141 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
1142 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1143 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1144
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1145 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
1146 Expression(expr_ty body, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1147 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1148 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
1149 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
1150 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
1151 "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
1152 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1153 }
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 = (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
1155 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
1156 return NULL;
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->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
1158 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
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 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
1163 Suite(asdl_seq * body, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1164 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1165 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
1166 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
1167 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
1168 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1169 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
1170 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
1171 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1172 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1173
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1174 stmt_ty
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1175 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
1176 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
1177 PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1178 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1179 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
1180 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
1181 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
1182 "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
1183 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1184 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1185 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
1186 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
1187 "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
1188 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1189 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1190 p = (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
1191 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
1192 return NULL;
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->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
1194 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
1195 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
1196 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
1197 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
1198 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
1199 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
1200 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
1201 return p;
35742
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
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1204 stmt_ty
41226
19f7ff443718 Implement PEP 3115 -- new metaclass syntax and semantics.
Guido van Rossum <guido@python.org>
parents: 40980
diff changeset
1205 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
1206 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
1207 int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1208 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1209 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
1210 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
1211 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
1212 "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
1213 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1214 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1215 p = (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
1216 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
1217 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1218 p->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
1219 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
1220 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
1221 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
1222 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
1223 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
1224 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
1225 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
1226 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
1227 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
1228 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1229 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1230
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1231 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
1232 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
1233 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1234 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
1235 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
1236 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
1237 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1238 p->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
1239 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
1240 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
1241 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
1242 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1243 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1244
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1245 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
1246 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
1247 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1248 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
1249 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
1250 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
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 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
1253 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
1254 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
1255 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
1256 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1257 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1258
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1259 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
1260 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
1261 *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1262 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1263 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
1264 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
1265 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
1266 "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
1267 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1268 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1269 p = (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
1270 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
1271 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1272 p->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
1273 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
1274 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
1275 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
1276 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
1277 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1278 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1279
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1280 stmt_ty
36786
57322cb2ca11 Patch #1440601: Add col_offset attribute to AST nodes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36743
diff changeset
1281 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
1282 col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1283 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1284 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
1285 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
1286 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
1287 "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
1288 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1289 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1290 if (!op) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1291 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
1292 "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
1293 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1294 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1295 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
1296 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
1297 "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
1298 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1299 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1300 p = (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
1301 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
1302 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1303 p->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
1304 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
1305 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
1306 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
1307 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
1308 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
1309 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1310 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1311
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1312 stmt_ty
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1313 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
1314 lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1315 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1316 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
1317 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
1318 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
1319 "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
1320 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1321 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1322 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
1323 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
1324 "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
1325 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1326 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1327 p = (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
1328 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
1329 return NULL;
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->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
1331 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
1332 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
1333 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
1334 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
1335 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
1336 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
1337 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1338 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1339
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1340 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
1341 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
1342 col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1343 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1344 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
1345 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
1346 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
1347 "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
1348 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1349 }
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 = (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
1351 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
1352 return NULL;
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->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
1354 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
1355 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
1356 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
1357 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1358 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1359 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1360 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1361
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1362 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
1363 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
1364 col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1365 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1366 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
1367 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
1368 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
1369 "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
1370 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1371 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1372 p = (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
1373 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
1374 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1375 p->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
1376 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
1377 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
1378 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
1379 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
1380 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
1381 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1382 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1383
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1384 stmt_ty
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
1385 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
1386 *arena)
36695
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 36669
diff changeset
1387 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1388 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
1389 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
1390 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
1391 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1392 p->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
1393 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
1394 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
1395 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
1396 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
1397 return p;
36695
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 36669
diff changeset
1398 }
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 36669
diff changeset
1399
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 36669
diff changeset
1400 stmt_ty
43102
981ecc526703 Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Collin Winter <collinw@gmail.com>
parents: 42844
diff changeset
1401 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
1402 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1403 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
1404 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1405 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1406 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1407 p->kind = 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
1408 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
1409 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
1410 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1411 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1412 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1413 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1414
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1415 stmt_ty
70499
e0e663132363 unify TryExcept and TryFinally (closes #12199)
Benjamin Peterson <benjamin@python.org>
parents: 70439
diff changeset
1416 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
1417 finalbody, int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1418 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1419 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
1420 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
1421 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
1422 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1423 p->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
1424 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
1425 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
1426 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
1427 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
1428 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
1429 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
1430 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1431 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1432
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1433 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
1434 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
1435 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1436 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
1437 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
1438 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
1439 "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
1440 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1441 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1442 p = (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
1443 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
1444 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1445 p->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
1446 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
1447 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
1448 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
1449 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
1450 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1451 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1452
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1453 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
1454 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
1455 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1456 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
1457 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
1458 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
1459 return NULL;
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->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
1461 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
1462 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
1463 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
1464 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1465 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1466
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1467 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
1468 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
1469 col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1470 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1471 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
1472 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
1473 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
1474 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1475 p->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
1476 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
1477 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
1478 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
1479 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
1480 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
1481 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1482 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1483
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1484 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
1485 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
1486 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1487 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
1488 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
1489 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
1490 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1491 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
1492 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
1493 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
1494 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
1495 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1496 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1497
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1498 stmt_ty
40965
30e5cb3a55ac Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 40941
diff changeset
1499 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
1500 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1501 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
1502 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
1503 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
1504 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1505 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
1506 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
1507 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
1508 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
1509 return p;
40965
30e5cb3a55ac Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 40941
diff changeset
1510 }
30e5cb3a55ac Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 40941
diff changeset
1511
30e5cb3a55ac Provisional implementation of PEP 3104.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 40941
diff changeset
1512 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
1513 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
1514 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1515 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
1516 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
1517 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
1518 "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
1519 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1520 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1521 p = (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
1522 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
1523 return NULL;
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->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
1525 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
1526 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
1527 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
1528 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1529 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1530
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1531 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
1532 Pass(int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1533 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1534 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
1535 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
1536 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
1537 return NULL;
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->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
1539 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
1540 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
1541 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1542 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1543
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1544 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
1545 Break(int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1546 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1547 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
1548 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
1549 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
1550 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1551 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
1552 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
1553 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
1554 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1555 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1556
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1557 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
1558 Continue(int lineno, int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1559 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1560 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
1561 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
1562 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
1563 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1564 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
1565 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
1566 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
1567 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1568 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1569
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1570 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
1571 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
1572 *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1573 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1574 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
1575 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
1576 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
1577 "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
1578 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1579 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1580 p = (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
1581 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
1582 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1583 p->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
1584 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
1585 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
1586 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
1587 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
1588 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1589 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1590
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1591 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
1592 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
1593 PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1594 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1595 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
1596 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
1597 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
1598 "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
1599 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1600 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1601 if (!op) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1602 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
1603 "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
1604 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1605 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1606 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
1607 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
1608 "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
1609 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1610 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1611 p = (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
1612 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
1613 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1614 p->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
1615 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
1616 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
1617 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
1618 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
1619 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
1620 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1621 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1622
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1623 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
1624 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
1625 *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1626 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1627 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
1628 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
1629 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
1630 "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
1631 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1632 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1633 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
1634 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
1635 "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
1636 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1637 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1638 p = (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
1639 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
1640 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1641 p->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
1642 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
1643 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
1644 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
1645 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
1646 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1647 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1648
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1649 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
1650 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
1651 *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1652 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1653 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
1654 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
1655 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
1656 "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
1657 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1658 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1659 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
1660 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
1661 "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
1662 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1663 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1664 p = (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
1665 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
1666 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1667 p->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
1668 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
1669 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
1670 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
1671 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
1672 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1673 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1674
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1675 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
1676 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
1677 PyArena *arena)
36666
6165927431d6 PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents: 36665
diff changeset
1678 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1679 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
1680 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
1681 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
1682 "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
1683 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1684 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1685 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
1686 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
1687 "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
1688 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1689 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1690 if (!orelse) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1691 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
1692 "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
1693 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1694 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1695 p = (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
1696 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
1697 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1698 p->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
1699 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
1700 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
1701 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
1702 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
1703 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
1704 return p;
36666
6165927431d6 PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents: 36665
diff changeset
1705 }
6165927431d6 PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents: 36665
diff changeset
1706
6165927431d6 PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents: 36665
diff changeset
1707 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
1708 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
1709 *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1710 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1711 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
1712 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
1713 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
1714 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1715 p->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
1716 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
1717 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
1718 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
1719 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
1720 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1721 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1722
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1723 expr_ty
39693
d0b83c4630c0 SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents: 39691
diff changeset
1724 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
1725 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1726 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
1727 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
1728 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
1729 return NULL;
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->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
1731 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
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;
39693
d0b83c4630c0 SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents: 39691
diff changeset
1735 }
d0b83c4630c0 SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents: 39691
diff changeset
1736
d0b83c4630c0 SF patch 1547796 by Georg Brandl -- set literals.
Guido van Rossum <guido@python.org>
parents: 39691
diff changeset
1737 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
1738 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
1739 PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
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 (!elt) {
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 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
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 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
1748 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
1749 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1750 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
1751 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
1752 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
1753 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
1754 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
1755 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1756 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1757
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1758 expr_ty
41464
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 41227
diff changeset
1759 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
1760 *arena)
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 41227
diff changeset
1761 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1762 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
1763 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
1764 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
1765 "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
1766 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1767 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1768 p = (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
1769 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
1770 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1771 p->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
1772 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
1773 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
1774 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
1775 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
1776 return p;
41464
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 41227
diff changeset
1777 }
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 41227
diff changeset
1778
060c79f6d919 Hide list comp variables and support set comprehensions
Nick Coghlan <ncoghlan@gmail.com>
parents: 41227
diff changeset
1779 expr_ty
42193
090588a17490 Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42013
diff changeset
1780 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
1781 col_offset, PyArena *arena)
090588a17490 Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42013
diff changeset
1782 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1783 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
1784 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
1785 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
1786 "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
1787 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1788 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1789 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
1790 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
1791 "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
1792 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1793 }
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 = (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
1795 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
1796 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1797 p->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
1798 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
1799 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
1800 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
1801 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
1802 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
1803 return p;
42193
090588a17490 Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42013
diff changeset
1804 }
090588a17490 Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42013
diff changeset
1805
090588a17490 Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42013
diff changeset
1806 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
1807 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
1808 PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1809 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1810 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
1811 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
1812 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
1813 "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
1814 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1815 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1816 p = (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
1817 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
1818 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1819 p->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
1820 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
1821 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
1822 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
1823 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
1824 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1825 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1826
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1827 expr_ty
74391
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
1828 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
1829 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1830 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
1831 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
1832 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
1833 return NULL;
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->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
1835 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
1836 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
1837 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
1838 return p;
35742
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
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1841 expr_ty
74391
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
1842 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
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 (!value) {
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 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
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 = 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
1854 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
1855 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
1856 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
1857 return p;
74391
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
1858 }
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
1859
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
1860 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
1861 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
1862 int col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1863 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1864 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
1865 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
1866 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
1867 "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
1868 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1869 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1870 p = (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
1871 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
1872 return NULL;
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->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
1874 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
1875 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
1876 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
1877 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
1878 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
1879 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1880 }
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 expr_ty
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1883 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
1884 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
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 (!func) {
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 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
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 = 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
1896 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
1897 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
1898 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
1899 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
1900 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
1901 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1902 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1903 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1904 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1905
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1906 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
1907 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
1908 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1909 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1910 if (!n) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1911 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1912 "field 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
1913 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1914 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1915 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1916 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1917 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1918 p->kind = 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
1919 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
1920 p->lineno = lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1921 p->col_offset = col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1922 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1923 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1924
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1925 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
1926 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
1927 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1928 expr_ty p;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1929 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
1930 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
1931 "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
1932 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1933 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1934 p = (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
1935 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
1936 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1937 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
1938 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
1939 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
1940 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
1941 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1942 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1943
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1944 expr_ty
71792
f578ca44193d add a asdl bytes type, so Bytes.s be properly typechecked
Benjamin Peterson <benjamin@python.org>
parents: 71459
diff changeset
1945 Bytes(bytes s, int lineno, int col_offset, PyArena *arena)
40894
0ea24f4f2467 Bytes literal.
Thomas Wouters <thomas@python.org>
parents: 40893
diff changeset
1946 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1947 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
1948 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
1949 PyErr_SetString(PyExc_ValueError,
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1950 "field 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
1951 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1952 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1953 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
1954 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
1955 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1956 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
1957 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
1958 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
1959 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
1960 return p;
40894
0ea24f4f2467 Bytes literal.
Thomas Wouters <thomas@python.org>
parents: 40893
diff changeset
1961 }
0ea24f4f2467 Bytes literal.
Thomas Wouters <thomas@python.org>
parents: 40893
diff changeset
1962
0ea24f4f2467 Bytes literal.
Thomas Wouters <thomas@python.org>
parents: 40893
diff changeset
1963 expr_ty
80738
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
1964 NameConstant(singleton value, int lineno, int col_offset, PyArena *arena)
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
1965 {
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1966 expr_ty p;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1967 if (!value) {
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1968 PyErr_SetString(PyExc_ValueError,
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1969 "field value is required for NameConstant");
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1970 return NULL;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1971 }
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1972 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1973 if (!p)
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1974 return NULL;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1975 p->kind = NameConstant_kind;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1976 p->v.NameConstant.value = value;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1977 p->lineno = lineno;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1978 p->col_offset = col_offset;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
1979 return p;
80738
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
1980 }
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
1981
03f92a9f0875 create NameConstant AST class for None, True, and False literals (closes #16619)
Benjamin Peterson <benjamin@python.org>
parents: 80589
diff changeset
1982 expr_ty
39783
7a0ad110e91e Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents: 39782
diff changeset
1983 Ellipsis(int lineno, int col_offset, PyArena *arena)
7a0ad110e91e Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents: 39782
diff changeset
1984 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1985 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
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 = 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
1990 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
1991 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
1992 return p;
39783
7a0ad110e91e Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents: 39782
diff changeset
1993 }
7a0ad110e91e Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents: 39782
diff changeset
1994
7a0ad110e91e Patch #1550786: ellipsis literal.
Georg Brandl <georg@python.org>
parents: 39782
diff changeset
1995 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
1996 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
1997 col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1998 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
1999 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
2000 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
2001 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
2002 "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
2003 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2004 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2005 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
2006 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
2007 "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
2008 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2009 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2010 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
2011 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
2012 "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
2013 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2014 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2015 p = (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
2016 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
2017 return NULL;
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->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
2019 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
2020 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
2021 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
2022 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
2023 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
2024 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2025 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2026
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2027 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
2028 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
2029 col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2030 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2031 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
2032 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
2033 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
2034 "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
2035 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2036 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2037 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
2038 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
2039 "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
2040 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2041 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2042 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
2043 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
2044 "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
2045 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2046 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2047 p = (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
2048 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
2049 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2050 p->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
2051 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
2052 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
2053 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
2054 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
2055 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
2056 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2057 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2058
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2059 expr_ty
41699
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
2060 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
2061 *arena)
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
2062 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2063 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
2064 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
2065 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
2066 "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
2067 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2068 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2069 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
2070 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
2071 "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
2072 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2073 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2074 p = (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
2075 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
2076 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2077 p->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
2078 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
2079 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
2080 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
2081 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
2082 return p;
41699
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
2083 }
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
2084
e16c8e5c5ca4 Merged revisions 55225-55227,55229-55269 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41471
diff changeset
2085 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
2086 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
2087 *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2088 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2089 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
2090 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
2091 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
2092 "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
2093 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2094 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2095 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
2096 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
2097 "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
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 }
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 = (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
2101 if (!p)
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2102 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2103 p->kind = 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
2104 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
2105 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
2106 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
2107 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
2108 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2109 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2110
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2111 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
2112 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
2113 *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2114 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2115 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
2116 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
2117 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
2118 "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
2119 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2120 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2121 p = (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
2122 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
2123 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2124 p->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
2125 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
2126 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
2127 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
2128 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
2129 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2130 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2131
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2132 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
2133 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
2134 *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2135 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2136 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
2137 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
2138 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
2139 "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
2140 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2141 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2142 p = (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
2143 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
2144 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2145 p->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
2146 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
2147 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
2148 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
2149 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
2150 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2151 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2152
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2153 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
2154 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
2155 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2156 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
2157 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
2158 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
2159 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2160 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
2161 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
2162 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
2163 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
2164 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2165 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2166
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2167 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
2168 ExtSlice(asdl_seq * dims, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2169 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2170 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
2171 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
2172 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
2173 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2174 p->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
2175 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
2176 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2177 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2178
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2179 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
2180 Index(expr_ty value, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2181 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2182 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
2183 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
2184 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
2185 "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
2186 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2187 }
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 = (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
2189 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
2190 return NULL;
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->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
2192 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
2193 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2194 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2195
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2196 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
2197 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
2198 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2199 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
2200 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
2201 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
2202 "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
2203 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2204 }
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 (!iter) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2206 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
2207 "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
2208 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2209 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2210 p = (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
2211 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
2212 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2213 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
2214 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
2215 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
2216 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2217 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2218
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2219 excepthandler_ty
46231
81ee270a6eb5 Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46229
diff changeset
2220 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
2221 col_offset, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2222 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2223 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
2224 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
2225 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
2226 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2227 p->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
2228 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
2229 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
2230 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
2231 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
2232 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
2233 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2234 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2235
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2236 arguments_ty
82732
7c5c678e4164 unify some ast.argument's attrs; change Attribute column offset (closes #16795)
Benjamin Peterson <benjamin@python.org>
parents: 81039
diff changeset
2237 arguments(asdl_seq * args, arg_ty vararg, asdl_seq * kwonlyargs, asdl_seq *
7c5c678e4164 unify some ast.argument's attrs; change Attribute column offset (closes #16795)
Benjamin Peterson <benjamin@python.org>
parents: 81039
diff changeset
2238 kw_defaults, arg_ty kwarg, asdl_seq * defaults, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2239 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2240 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
2241 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
2242 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
2243 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2244 p->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
2245 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
2246 p->kwonlyargs = kwonlyargs;
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
2247 p->kw_defaults = kw_defaults;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2248 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
2249 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
2250 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2251 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2252
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
2253 arg_ty
41717
9ad84070b22d Merged revisions 55328-55341 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41699
diff changeset
2254 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
2255 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2256 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
2257 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
2258 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
2259 "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
2260 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2261 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2262 p = (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
2263 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
2264 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2265 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
2266 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
2267 return p;
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
2268 }
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
2269
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2270 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
2271 keyword(identifier arg, expr_ty value, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2272 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2273 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
2274 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
2275 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
2276 "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
2277 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2278 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2279 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
2280 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
2281 "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
2282 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2283 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2284 p = (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
2285 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
2286 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2287 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
2288 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
2289 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2290 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2291
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2292 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
2293 alias(identifier name, identifier asname, PyArena *arena)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2294 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2295 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
2296 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
2297 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
2298 "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
2299 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2300 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2301 p = (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
2302 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
2303 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2304 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
2305 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
2306 return p;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2307 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2308
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
2309 withitem_ty
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
2310 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
2311 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2312 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
2313 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
2314 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
2315 "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
2316 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2317 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2318 p = (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
2319 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
2320 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2321 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
2322 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
2323 return p;
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
2324 }
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
2325
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
2326
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2327 PyObject*
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2328 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
2329 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2330 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
2331 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
2332 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
2333 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
2334 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
2335 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2336
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2337 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
2338 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
2339 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
2340 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
2341 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
2342 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2343 if (_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
2344 goto 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 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2346 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2347 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
2348 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
2349 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
2350 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
2351 if (!value) goto 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 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
2353 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2354 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2355 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2356 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
2357 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
2358 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
2359 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
2360 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2361 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
2362 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2363 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2364 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2365 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
2366 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
2367 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
2368 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
2369 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2370 if (_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
2371 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2372 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2373 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2374 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2375 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2376 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
2377 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
2378 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
2379 return NULL;
36174
85b2d804ac0a Regenerate.
Martin v. Löwis <martin@v.loewis.de>
parents: 36065
diff changeset
2380 }
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
2381
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2382 PyObject*
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2383 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
2384 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2385 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
2386 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
2387 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
2388 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
2389 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
2390 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2391
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2392 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
2393 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
2394 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
2395 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
2396 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
2397 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2398 if (_PyObject_SetAttrId(result, &PyId_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
2399 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2400 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2401 value = ast2obj_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
2402 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2403 if (_PyObject_SetAttrId(result, &PyId_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
2404 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2405 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2406 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
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_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
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 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
2412 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2413 if (_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
2414 goto 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 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2416 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
2417 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2418 if (_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
2419 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2420 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2421 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2422 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
2423 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
2424 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
2425 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
2426 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2427 if (_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
2428 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2429 Py_DECREF(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 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
2431 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2432 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
2433 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2434 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2435 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
2436 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2437 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
2438 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2439 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2440 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
2441 if (!value) goto 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 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
2443 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2444 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2445 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
2446 if (!value) goto 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 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
2448 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2449 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2450 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
2451 if (!value) goto 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 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
2453 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2454 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2455 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
2456 if (!value) goto 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 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
2458 goto 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 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2460 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2461 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
2462 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
2463 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
2464 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
2465 if (!value) goto 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 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
2467 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2468 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2469 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2470 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
2471 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
2472 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
2473 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
2474 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2475 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
2476 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2477 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2478 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2479 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
2480 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
2481 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
2482 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
2483 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2484 if (_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
2485 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2486 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2487 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
2488 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2489 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
2490 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2491 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2492 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2493 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
2494 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
2495 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
2496 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
2497 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2498 if (_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
2499 goto 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 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2501 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
2502 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2503 if (_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
2504 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2505 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2506 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
2507 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2508 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
2509 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2510 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2511 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2512 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
2513 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
2514 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
2515 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
2516 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2517 if (_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
2518 goto 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 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2520 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
2521 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2522 if (_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
2523 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2524 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2525 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
2526 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2527 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
2528 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2529 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2530 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
2531 if (!value) goto failed;
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 (_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
2533 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2534 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2535 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2536 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
2537 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
2538 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
2539 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
2540 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2541 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
2542 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2543 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2544 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
2545 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2546 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
2547 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2548 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2549 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
2550 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
2551 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
2552 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2553 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2554 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2555 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
2556 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
2557 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
2558 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
2559 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2560 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
2561 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2562 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2563 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
2564 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2565 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
2566 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2567 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2568 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
2569 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2570 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
2571 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2572 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2573 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2574 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
2575 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
2576 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
2577 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
2578 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2579 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
2580 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2581 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2582 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
2583 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2584 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
2585 goto failed;
36794
df843b07f5fe Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36786
diff changeset
2586 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
2587 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2588 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
2589 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
2590 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
2591 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
2592 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2593 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
2594 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2595 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2596 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
2597 if (!value) goto 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 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
2599 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2600 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2601 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2602 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
2603 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
2604 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
2605 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
2606 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2607 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
2608 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2609 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2610 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
2611 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2612 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
2613 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2614 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2615 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
2616 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2617 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
2618 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2619 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2620 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
2621 if (!value) goto 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 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
2623 goto 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 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2625 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2626 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
2627 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
2628 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
2629 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
2630 if (!value) goto 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 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
2632 goto 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 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2634 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
2635 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
2636 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
2637 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2638 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2639 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2640 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
2641 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
2642 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
2643 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
2644 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2645 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
2646 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2647 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2648 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2649 case 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
2650 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
2651 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2652 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
2653 if (!value) goto 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 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
2655 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2656 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2657 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
2658 if (!value) goto 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 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
2660 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2661 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2662 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
2663 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2664 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
2665 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2666 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2667 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2668 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
2669 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
2670 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
2671 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
2672 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2673 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
2674 goto failed;
36794
df843b07f5fe Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36786
diff changeset
2675 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
2676 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2677 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
2678 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
2679 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
2680 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
2681 if (!value) goto failed;
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 (_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
2683 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2684 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2685 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2686 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
2687 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
2688 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
2689 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
2690 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2691 if (_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
2692 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2693 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2694 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2695 case 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
2696 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
2697 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2698 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2699 case 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
2700 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
2701 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2702 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2703 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
2704 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
2705 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
2706 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2707 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2708 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
2709 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2710 if (_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
2711 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2712 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2713 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
2714 if (!value) goto failed;
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 (_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
2716 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2717 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2718 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2719 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
2720 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
2721 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
2722 return NULL;
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
2723 }
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
2724
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2725 PyObject*
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
2726 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
2727 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2728 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
2729 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
2730 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
2731 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
2732 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
2733 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2734
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2735 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
2736 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
2737 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
2738 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
2739 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
2740 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2741 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
2742 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2743 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2744 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
2745 if (!value) goto 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 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
2747 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2748 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2749 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2750 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
2751 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
2752 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
2753 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
2754 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2755 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
2756 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2757 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2758 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
2759 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2760 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
2761 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2762 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2763 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
2764 if (!value) goto 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 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
2766 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2767 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2768 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2769 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
2770 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
2771 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
2772 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
2773 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2774 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
2775 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2776 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2777 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
2778 if (!value) goto 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 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
2780 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2781 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2782 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2783 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
2784 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
2785 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
2786 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
2787 if (!value) goto 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 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
2789 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2790 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2791 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
2792 if (!value) goto 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 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
2794 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2795 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2796 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2797 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
2798 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
2799 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
2800 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
2801 if (!value) goto 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 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
2803 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2804 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2805 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
2806 if (!value) goto 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 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
2808 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2809 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2810 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
2811 if (!value) goto 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 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
2813 goto 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 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2815 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2816 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
2817 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
2818 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
2819 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
2820 if (!value) goto 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 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
2822 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2823 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2824 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
2825 if (!value) goto 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 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
2827 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2828 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2829 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2830 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
2831 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
2832 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
2833 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
2834 if (!value) goto 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 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
2836 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2837 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2838 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2839 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
2840 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
2841 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
2842 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
2843 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2844 if (_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
2845 goto 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 Py_DECREF(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 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
2848 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2849 if (_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
2850 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2851 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2852 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2853 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
2854 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
2855 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
2856 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
2857 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2858 if (_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
2859 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2860 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2861 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
2862 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2863 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
2864 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2865 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2866 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2867 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
2868 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
2869 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
2870 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
2871 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2872 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
2873 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2874 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2875 value = 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
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_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
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.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
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_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
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 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
2887 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
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.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
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_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
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.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
2895 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
2896 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2897 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
2898 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2899 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2900 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2901 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
2902 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
2903 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
2904 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
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_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
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 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2910 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
2911 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
2912 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
2913 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
2914 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2915 if (_PyObject_SetAttrId(result, &PyId_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
2916 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2917 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2918 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2919 case 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
2920 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
2921 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2922 value = ast2obj_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
2923 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2924 if (_PyObject_SetAttrId(result, &PyId_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
2925 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2926 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2927 {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2928 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
2929 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
2930 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2931 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
2932 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
2933 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2934 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2935 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
2936 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2937 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2938 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
2939 if (!value) goto 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 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
2941 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2942 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2943 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2944 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
2945 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
2946 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
2947 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
2948 if (!value) goto 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 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
2950 goto 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 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2952 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
2953 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2954 if (_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
2955 goto 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 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2957 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
2958 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2959 if (_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
2960 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2961 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2962 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
2963 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2964 if (_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
2965 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2966 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2967 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
2968 if (!value) goto failed;
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 (_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
2970 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2971 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2972 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2973 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
2974 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
2975 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
2976 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
2977 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2978 if (_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
2979 goto 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 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2981 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2982 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
2983 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
2984 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
2985 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
2986 if (!value) goto 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 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
2988 goto 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 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2990 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2991 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
2992 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
2993 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
2994 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
2995 if (!value) goto 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 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
2997 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2998 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
2999 break;
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3000 case NameConstant_kind:
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3001 result = PyType_GenericNew(NameConstant_type, NULL, NULL);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3002 if (!result) goto failed;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3003 value = ast2obj_singleton(o->v.NameConstant.value);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3004 if (!value) goto failed;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3005 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3006 goto failed;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3007 Py_DECREF(value);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3008 break;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3009 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
3010 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
3011 if (!result) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3012 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3013 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
3014 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
3015 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
3016 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
3017 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3018 if (_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
3019 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3020 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3021 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
3022 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3023 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
3024 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3025 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3026 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
3027 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
3028 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
3029 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3030 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3031 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3032 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
3033 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
3034 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
3035 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
3036 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3037 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
3038 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3039 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3040 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
3041 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3042 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
3043 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3044 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3045 value = ast2obj_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
3046 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3047 if (_PyObject_SetAttrId(result, &PyId_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
3048 goto failed;
36794
df843b07f5fe Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36786
diff changeset
3049 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
3050 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3051 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
3052 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
3053 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
3054 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
3055 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3056 if (_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
3057 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3058 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3059 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
3060 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3061 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
3062 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3063 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3064 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3065 case 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
3066 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
3067 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
3068 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
3069 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3070 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
3071 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3072 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3073 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
3074 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
3075 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
3076 goto failed;
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_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3078 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3079 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
3080 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
3081 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
3082 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
3083 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3084 if (_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
3085 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3086 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3087 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
3088 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3089 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
3090 goto failed;
36794
df843b07f5fe Fix memory leak on attributes.
Martin v. Löwis <martin@v.loewis.de>
parents: 36786
diff changeset
3091 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
3092 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3093 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
3094 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
3095 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
3096 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
3097 if (!value) goto failed;
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 (_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
3099 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3100 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3101 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
3102 if (!value) goto 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 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
3104 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3105 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3106 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3107 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3108 value = ast2obj_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
3109 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3110 if (_PyObject_SetAttrId(result, &PyId_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
3111 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3112 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3113 value = ast2obj_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
3114 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3115 if (_PyObject_SetAttrId(result, &PyId_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
3116 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3117 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3118 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3119 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
3120 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
3121 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
3122 return NULL;
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3123 }
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3124
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3125 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
3126 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3127 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
3128 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
3129 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
3130 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
3131 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
3132 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
3133 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
3134 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
3135 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
3136 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
3137 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
3138 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
3139 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
3140 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
3141 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
3142 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
3143 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
3144 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
3145 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
3146 default:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3147 /* 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
3148 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
3149 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3150 }
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3151 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3152 PyObject*
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3153 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
3154 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3155 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
3156 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
3157 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
3158 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
3159 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
3160 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3161
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3162 switch (o->kind) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3163 case 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
3164 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
3165 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
3166 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
3167 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3168 if (_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
3169 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3170 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3171 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
3172 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3173 if (_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
3174 goto failed;
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_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3176 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
3177 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3178 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
3179 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3180 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3181 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3182 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
3183 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
3184 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
3185 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
3186 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3187 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
3188 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3189 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3190 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3191 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
3192 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
3193 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
3194 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
3195 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3196 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
3197 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3198 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3199 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3200 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3201 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3202 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
3203 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
3204 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
3205 return NULL;
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3206 }
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3207
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3208 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
3209 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3210 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
3211 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
3212 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
3213 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
3214 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
3215 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
3216 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
3217 default:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3218 /* 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
3219 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
3220 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3221 }
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3222 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3223 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
3224 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3225 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
3226 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
3227 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
3228 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
3229 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
3230 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
3231 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
3232 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
3233 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
3234 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
3235 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
3236 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
3237 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
3238 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
3239 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
3240 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
3241 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
3242 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
3243 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
3244 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
3245 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
3246 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
3247 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
3248 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
3249 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
3250 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
3251 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
3252 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
3253 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
3254 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
3255 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
3256 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
3257 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
3258 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
3259 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
3260 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
3261 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
3262 default:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3263 /* 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
3264 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
3265 return 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 }
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3267 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3268 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
3269 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3270 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
3271 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
3272 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
3273 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
3274 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
3275 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
3276 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
3277 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
3278 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
3279 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
3280 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
3281 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
3282 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
3283 default:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3284 /* 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
3285 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
3286 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3287 }
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3288 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3289 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
3290 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3291 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
3292 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
3293 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
3294 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
3295 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
3296 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
3297 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
3298 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
3299 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
3300 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
3301 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
3302 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
3303 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
3304 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
3305 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
3306 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
3307 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
3308 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
3309 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
3310 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
3311 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
3312 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
3313 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
3314 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
3315 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
3316 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
3317 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
3318 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
3319 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
3320 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
3321 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
3322 default:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3323 /* 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
3324 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
3325 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3326 }
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3327 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3328 PyObject*
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3329 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
3330 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3331 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
3332 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
3333 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
3334 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
3335 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
3336 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3337
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3338 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
3339 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
3340 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
3341 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3342 if (_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
3343 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3344 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3345 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
3346 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3347 if (_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
3348 goto failed;
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_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3350 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
3351 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3352 if (_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
3353 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3354 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3355 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3356 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
3357 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
3358 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
3359 return NULL;
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3360 }
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3361
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3362 PyObject*
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3363 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
3364 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3365 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
3366 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
3367 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
3368 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
3369 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
3370 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3371
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3372 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
3373 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
3374 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
3375 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
3376 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
3377 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3378 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
3379 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3380 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3381 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
3382 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
3383 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
3384 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
3385 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
3386 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
3387 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
3388 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
3389 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
3390 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
3391 break;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3392 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3393 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
3394 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3395 if (_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
3396 goto failed;
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_DECREF(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 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
3399 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3400 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
3401 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3402 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3403 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3404 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
3405 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
3406 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
3407 return NULL;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3408 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3409
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3410 PyObject*
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3411 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
3412 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3413 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
3414 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
3415 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
3416 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
3417 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
3418 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3419
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3420 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
3421 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
3422 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
3423 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3424 if (_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
3425 goto failed;
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_DECREF(value);
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3427 value = ast2obj_arg(o->vararg);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3428 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3429 if (_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
3430 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3431 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3432 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
3433 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3434 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
3435 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3436 Py_DECREF(value);
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3437 value = ast2obj_list(o->kw_defaults, ast2obj_expr);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3438 if (!value) goto failed;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3439 if (_PyObject_SetAttrId(result, &PyId_kw_defaults, value) == -1)
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3440 goto failed;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3441 Py_DECREF(value);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3442 value = ast2obj_arg(o->kwarg);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3443 if (!value) goto failed;
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 (_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
3445 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3446 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3447 value = ast2obj_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
3448 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3449 if (_PyObject_SetAttrId(result, &PyId_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
3450 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3451 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3452 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3453 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
3454 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
3455 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
3456 return NULL;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3457 }
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 PyObject*
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
3460 ast2obj_arg(void* _o)
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
3461 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3462 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
3463 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
3464 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
3465 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
3466 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
3467 }
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 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
3470 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
3471 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
3472 if (!value) goto failed;
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 (_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
3474 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3475 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3476 value = ast2obj_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
3477 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3478 if (_PyObject_SetAttrId(result, &PyId_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
3479 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3480 Py_DECREF(value);
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3481 value = ast2obj_int(o->lineno);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3482 if (!value) goto failed;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3483 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0)
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3484 goto failed;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3485 Py_DECREF(value);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3486 value = ast2obj_int(o->col_offset);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3487 if (!value) goto failed;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3488 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0)
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3489 goto failed;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3490 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
3491 return result;
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
3492 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
3493 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
3494 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
3495 return NULL;
40529
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
3496 }
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
3497
54cd47788811 PEP 3107 - Function Annotations thanks to Tony Lownds
Neal Norwitz <nnorwitz@gmail.com>
parents: 40215
diff changeset
3498 PyObject*
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3499 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
3500 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3501 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
3502 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
3503 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
3504 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
3505 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
3506 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3507
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3508 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
3509 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
3510 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
3511 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3512 if (_PyObject_SetAttrId(result, &PyId_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
3513 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3514 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3515 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
3516 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3517 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
3518 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3519 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3520 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3521 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
3522 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
3523 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
3524 return NULL;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3525 }
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3526
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3527 PyObject*
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3528 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
3529 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3530 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
3531 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
3532 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
3533 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
3534 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
3535 }
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 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
3538 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
3539 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
3540 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3541 if (_PyObject_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
3542 goto 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 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3544 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
3545 if (!value) goto 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 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
3547 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3548 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3549 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3550 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
3551 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
3552 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
3553 return NULL;
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3554 }
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3555
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
3556 PyObject*
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
3557 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
3558 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3559 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
3560 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
3561 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
3562 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
3563 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
3564 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3565
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3566 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
3567 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
3568 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
3569 if (!value) goto failed;
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 (_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
3571 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3572 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3573 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
3574 if (!value) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3575 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
3576 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3577 Py_DECREF(value);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3578 return result;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
3579 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
3580 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
3581 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
3582 return NULL;
35866
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3583 }
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3584
9f73dc0953d2 Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents: 35862
diff changeset
3585
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3586 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3587 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
3588 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3589 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
3590
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3591 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
3592
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3593 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
3594 *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
3595 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3596 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3597 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
3598 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3599 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3600 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3601 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3602 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
3603
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3604 if (_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
3605 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3606 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
3607 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
3608 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
3609 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3610 if (!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
3611 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
3612 goto 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 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3614 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
3615 body = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3616 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
3617 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
3618 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
3619 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
3620 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3621 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
3622 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3623 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3624 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3625 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
3626 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
3627 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3628 *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
3629 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
3630 return 0;
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 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
3633 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3634 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3635 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3636 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3637 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
3638
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3639 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
3640 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3641 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
3642 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
3643 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
3644 if (tmp == NULL) goto 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 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
3646 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
3647 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3648 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3649 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
3650 body = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3651 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
3652 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
3653 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
3654 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
3655 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3656 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
3657 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3658 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3659 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3660 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
3661 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
3662 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3663 *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
3664 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
3665 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3666 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3667 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
3668 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3669 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3670 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3671 if (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 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
3673
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3674 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
3675 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3676 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
3677 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3678 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
3679 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3680 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3681 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3682 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
3683 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
3684 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3685 *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
3686 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
3687 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3688 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3689 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
3690 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3691 return 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 (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3694 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
3695
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 (_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
3697 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3698 Py_ssize_t len;
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_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
3700 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
3701 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3702 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
3703 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
3704 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3705 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3706 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
3707 body = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3708 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
3709 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
3710 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
3711 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
3712 if (res != 0) goto failed;
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_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
3714 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3715 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3716 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3717 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Suite");
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3718 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3719 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3720 *out = Suite(body, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3721 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3722 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3723 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3724
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3725 PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3726 failed:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3727 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3728 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3729 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3730
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3731 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3732 obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3733 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3734 int isinstance;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3735
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3736 PyObject *tmp = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3737 int lineno;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3738 int col_offset;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3739
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3740 if (obj == Py_None) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3741 *out = NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3742 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3743 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3744 if (_PyObject_HasAttrId(obj, &PyId_lineno)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3745 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3746 tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3747 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3748 res = obj2ast_int(tmp, &lineno, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3749 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3750 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3751 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3752 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
3753 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3754 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3755 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
3756 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3757 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
3758 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3759 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
3760 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3761 Py_CLEAR(tmp);
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 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3763 PyErr_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
3764 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3765 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3766 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
3767 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3768 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3769 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3770 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3771 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
3772 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
3773 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
3774 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
3775 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
3776
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 (_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
3778 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3779 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
3780 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3781 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
3782 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3783 Py_CLEAR(tmp);
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3784 } 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
3785 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
3786 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3787 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3788 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
3789 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3790 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
3791 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3792 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
3793 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3794 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3795 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3796 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
3797 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3798 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3799 if (_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
3800 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3801 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
3802 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
3803 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
3804 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3805 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
3806 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
3807 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3808 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3809 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
3810 body = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3811 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
3812 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
3813 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
3814 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
3815 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
3816 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
3817 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3818 Py_CLEAR(tmp);
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3819 } 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
3820 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
3821 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3822 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3823 if (_PyObject_HasAttrId(obj, &PyId_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
3824 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3825 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3826 Py_ssize_t i;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3827 tmp = _PyObject_GetAttrId(obj, &PyId_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
3828 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3829 if (!PyList_Check(tmp)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3830 PyErr_Format(PyExc_TypeError, "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
3831 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3832 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3833 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
3834 decorator_list = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3835 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
3836 for (i = 0; i < len; i++) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3837 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3838 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3839 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3840 asdl_seq_SET(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
3841 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3842 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3843 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3844 PyErr_SetString(PyExc_TypeError, "required field \"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
3845 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3846 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3847 if (exists_not_none(obj, &PyId_returns)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3848 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3849 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
3850 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3851 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
3852 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3853 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3854 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3855 returns = NULL;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
3856 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3857 *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
3858 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
3859 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
3860 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3861 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3862 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
3863 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3864 return 1;
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 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3867 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
3868 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
3869 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
3870 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
3871 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
3872 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
3873 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
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 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
3876 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3877 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
3878 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3879 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
3880 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3881 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3882 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3883 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
3884 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3885 }
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 (_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
3887 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3888 Py_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
3889 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
3890 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
3891 if (tmp == NULL) goto failed;
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 (!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
3893 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
3894 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3895 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3896 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
3897 bases = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3898 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
3899 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
3900 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
3901 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
3902 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3903 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
3904 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3905 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3906 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3907 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
3908 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
3909 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3910 if (_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
3911 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3912 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
3913 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
3914 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
3915 if (tmp == NULL) goto 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 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
3917 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
3918 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3919 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3920 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
3921 keywords = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3922 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
3923 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
3924 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
3925 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
3926 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3927 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
3928 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3929 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3930 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3931 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
3932 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3933 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3934 if (exists_not_none(obj, &PyId_starargs)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3935 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3936 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
3937 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3938 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
3939 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3940 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3941 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3942 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
3943 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
3944 if (exists_not_none(obj, &PyId_kwargs)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3945 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3946 tmp = _PyObject_GetAttrId(obj, &PyId_kwargs);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3947 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3948 res = obj2ast_expr(tmp, &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
3949 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3950 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3951 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3952 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
3953 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3954 if (_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
3955 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3956 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
3957 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
3958 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
3959 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3960 if (!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
3961 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
3962 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3963 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3964 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
3965 body = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3966 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
3967 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
3968 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
3969 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
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 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
3972 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3973 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3974 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3975 PyErr_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
3976 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3977 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3978 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
3979 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3980 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
3981 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
3982 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
3983 if (tmp == NULL) goto failed;
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 (!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
3985 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
3986 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3987 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3988 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
3989 decorator_list = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3990 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
3991 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
3992 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
3993 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
3994 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3995 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
3996 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
3997 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3998 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
3999 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
4000 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4001 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4002 *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
4003 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
4004 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
4005 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4006 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4007 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
4008 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4009 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4010 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4011 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4012 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
4013
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
4014 if (exists_not_none(obj, &PyId_value)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4015 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4016 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
4017 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4018 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
4019 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4020 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4021 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4022 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
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 *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
4025 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
4026 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4027 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4028 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
4029 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4030 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4031 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4032 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4033 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
4034
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4035 if (_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
4036 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4037 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
4038 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
4039 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
4040 if (tmp == NULL) goto 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 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
4042 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
4043 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4044 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4045 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4046 targets = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4047 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
4048 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
4049 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
4050 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
4051 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4052 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
4053 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4054 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4055 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4056 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
4057 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4058 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4059 *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
4060 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
4061 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4062 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4063 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
4064 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4065 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4066 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4067 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4068 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
4069 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
4070
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4071 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
4072 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4073 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
4074 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
4075 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
4076 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4077 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
4078 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
4079 goto 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 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4081 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4082 targets = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4083 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
4084 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
4085 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
4086 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
4087 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4088 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
4089 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4090 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4091 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4092 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
4093 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4094 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4095 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
4096 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4097 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
4098 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4099 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
4100 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4101 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4102 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4103 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
4104 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4105 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4106 *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
4107 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
4108 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4109 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4110 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
4111 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4112 return 1;
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 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4115 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
4116 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
4117 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
4118
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4119 if (_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
4120 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4121 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
4122 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4123 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
4124 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4125 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4126 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4127 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
4128 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4129 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4130 if (_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
4131 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4132 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
4133 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4134 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
4135 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4136 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4137 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4138 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
4139 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4140 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4141 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
4142 int res;
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 = _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
4144 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4145 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
4146 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4147 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4148 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4149 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
4150 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4151 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4152 *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
4153 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
4154 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4155 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4156 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
4157 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4158 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4159 }
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 (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4161 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
4162 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
4163 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
4164 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
4165
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4166 if (_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
4167 int res;
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 = _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
4169 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4170 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
4171 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4172 Py_CLEAR(tmp);
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 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4174 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
4175 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4176 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4177 if (_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
4178 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4179 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
4180 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4181 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
4182 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4183 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4184 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4185 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
4186 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4187 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4188 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
4189 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4190 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
4191 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
4192 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
4193 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4194 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
4195 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
4196 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4197 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4198 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4199 body = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4200 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
4201 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
4202 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
4203 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
4204 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4205 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
4206 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4207 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4208 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4209 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
4210 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4211 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4212 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
4213 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4214 Py_ssize_t len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4215 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
4216 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
4217 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4218 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
4219 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
4220 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4221 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4222 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4223 orelse = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4224 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
4225 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
4226 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
4227 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
4228 if (res != 0) goto 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 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
4230 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4231 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4232 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4233 PyErr_SetString(PyExc_TypeError, "required field \"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
4234 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4235 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4236 *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
4237 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
4238 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4239 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4240 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
4241 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4242 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4243 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4244 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4245 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
4246 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
4247 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
4248
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4249 if (_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
4250 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4251 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
4252 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4253 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
4254 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4255 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4256 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4257 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
4258 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4259 }
84850
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 (_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
4261 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4262 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
4263 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
4264 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
4265 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4266 if (!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
4267 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
4268 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4269 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4270 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4271 body = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4272 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
4273 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
4274 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
4275 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
4276 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4277 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
4278 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4279 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4280 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4281 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
4282 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4283 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4284 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
4285 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4286 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
4287 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
4288 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
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 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
4291 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
4292 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4293 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4294 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4295 orelse = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4296 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
4297 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
4298 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
4299 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
4300 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4301 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
4302 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4303 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4304 } else {
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_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
4306 return 1;
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 *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
4309 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
4310 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4311 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4312 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
4313 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4314 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4315 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4316 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4317 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
4318 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
4319 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
4320
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4321 if (_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
4322 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4323 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
4324 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4325 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
4326 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4327 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4328 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4329 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
4330 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4331 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4332 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
4333 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4334 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
4335 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
4336 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
4337 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4338 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
4339 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
4340 goto failed;
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 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4343 body = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4344 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
4345 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
4346 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
4347 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
4348 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4349 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
4350 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4351 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4352 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4353 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
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 (_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
4357 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4358 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
4359 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
4360 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
4361 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4362 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
4363 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
4364 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4365 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4366 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4367 orelse = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4368 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
4369 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
4370 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
4371 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
4372 if (res != 0) goto 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 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
4374 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4375 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4376 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4377 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
4378 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4379 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4380 *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
4381 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
4382 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4383 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4384 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
4385 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4386 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4387 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4388 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4389 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
4390 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
4391
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4392 if (_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
4393 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4394 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
4395 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
4396 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
4397 if (tmp == NULL) goto 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 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
4399 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
4400 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4401 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4402 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4403 items = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4404 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
4405 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
4406 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
4407 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
4408 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4409 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
4410 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4411 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4412 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4413 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
4414 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4415 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4416 if (_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
4417 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4418 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
4419 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
4420 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
4421 if (tmp == NULL) goto failed;
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 (!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
4423 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
4424 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4425 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4426 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4427 body = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4428 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
4429 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
4430 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
4431 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
4432 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4433 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
4434 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4435 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4436 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4437 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
4438 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4439 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4440 *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
4441 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
4442 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4443 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4444 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
4445 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4446 return 1;
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 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4449 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
4450 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
4451
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
4452 if (exists_not_none(obj, &PyId_exc)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4453 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4454 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
4455 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4456 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
4457 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4458 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4459 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4460 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
4461 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
4462 if (exists_not_none(obj, &PyId_cause)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4463 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4464 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
4465 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4466 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
4467 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4468 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4469 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4470 cause = NULL;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4471 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4472 *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
4473 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
4474 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4475 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4476 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
4477 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4478 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4479 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4480 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4481 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
4482 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
4483 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
4484 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
4485
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4486 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
4487 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4488 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
4489 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
4490 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
4491 if (tmp == NULL) goto 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 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
4493 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
4494 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4495 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4496 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4497 body = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4498 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
4499 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
4500 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
4501 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
4502 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4503 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
4504 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4505 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4506 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4507 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
4508 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4509 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4510 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
4511 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4512 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
4513 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
4514 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
4515 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4516 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
4517 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
4518 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4519 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4520 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4521 handlers = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4522 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
4523 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
4524 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
4525 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
4526 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4527 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
4528 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4529 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4530 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4531 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
4532 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4533 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4534 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
4535 int res;
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 len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4537 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
4538 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
4539 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4540 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
4541 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
4542 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4543 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4544 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4545 orelse = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4546 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
4547 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
4548 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
4549 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
4550 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4551 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
4552 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4553 Py_CLEAR(tmp);
84850
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 \"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
4556 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4557 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4558 if (_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
4559 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4560 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
4561 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
4562 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
4563 if (tmp == NULL) goto failed;
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 (!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
4565 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
4566 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4567 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4568 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4569 finalbody = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4570 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
4571 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
4572 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
4573 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
4574 if (res != 0) goto 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 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
4576 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4577 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4578 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4579 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
4580 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4581 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4582 *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
4583 arena);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4584 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
4585 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4586 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4587 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
4588 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4589 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4590 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4591 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4592 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
4593 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
4594
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 (_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
4596 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4597 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
4598 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4599 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
4600 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4601 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4602 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4603 PyErr_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
4604 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4605 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
4606 if (exists_not_none(obj, &PyId_msg)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4607 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4608 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
4609 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4610 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
4611 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4612 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4613 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4614 msg = NULL;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4615 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4616 *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
4617 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
4618 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4619 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4620 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
4621 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4622 return 1;
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 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4625 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
4626
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4627 if (_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
4628 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4629 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
4630 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
4631 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
4632 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4633 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
4634 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
4635 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4636 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4637 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4638 names = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4639 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
4640 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
4641 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
4642 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
4643 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4644 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
4645 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4646 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4647 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4648 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
4649 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4650 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4651 *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
4652 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
4653 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4654 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4655 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
4656 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4657 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4658 }
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 (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4660 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
4661 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
4662 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
4663
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
4664 if (exists_not_none(obj, &PyId_module)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4665 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4666 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
4667 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4668 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
4669 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4670 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4671 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4672 module = NULL;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4673 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4674 if (_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
4675 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4676 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
4677 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
4678 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
4679 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4680 if (!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
4681 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
4682 goto 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 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4684 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4685 names = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4686 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
4687 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
4688 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
4689 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
4690 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4691 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
4692 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4693 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4694 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4695 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
4696 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4697 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
4698 if (exists_not_none(obj, &PyId_level)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4699 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4700 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
4701 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4702 res = obj2ast_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
4703 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4704 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4705 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4706 level = 0;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4707 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4708 *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
4709 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
4710 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4711 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4712 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
4713 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4714 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4715 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4716 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4717 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
4718
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4719 if (_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
4720 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4721 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
4722 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
4723 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
4724 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4725 if (!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
4726 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
4727 goto 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 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4729 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4730 names = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4731 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
4732 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
4733 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
4734 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
4735 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4736 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
4737 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4738 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4739 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4740 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
4741 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4742 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4743 *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
4744 if (*out == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4745 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4746 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4747 isinstance = PyObject_IsInstance(obj, (PyObject*)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
4748 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4749 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4750 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4751 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4752 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
4753
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4754 if (_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
4755 int res;
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_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
4757 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
4758 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
4759 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4760 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
4761 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
4762 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4763 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4764 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4765 names = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4766 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
4767 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
4768 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
4769 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
4770 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4771 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
4772 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4773 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4774 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4775 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
4776 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4777 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4778 *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
4779 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
4780 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4781 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4782 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
4783 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4784 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4785 }
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 (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4787 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
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 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
4790 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4791 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
4792 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4793 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
4794 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4795 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4796 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4797 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
4798 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4799 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4800 *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
4801 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
4802 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4803 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4804 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
4805 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4806 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4807 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4808 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4809
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4810 *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
4811 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
4812 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4813 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4814 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
4815 if (isinstance == -1) {
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4816 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
4817 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4818 if (isinstance) {
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 *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
4821 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
4822 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4823 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4824 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
4825 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4826 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4827 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4828 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4829
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4830 *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
4831 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
4832 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4833 }
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 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
4836 failed:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4837 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4838 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4839 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4840
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4841 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4842 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
4843 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4844 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
4845
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4846 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
4847 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
4848 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
4849
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4850 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
4851 *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
4852 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4853 }
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 (_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
4855 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4856 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
4857 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4858 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
4859 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4860 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4861 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4862 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
4863 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4864 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4865 if (_PyObject_HasAttrId(obj, &PyId_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
4866 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4867 tmp = _PyObject_GetAttrId(obj, &PyId_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
4868 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4869 res = obj2ast_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
4870 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4871 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4872 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4873 PyErr_SetString(PyExc_TypeError, "required field \"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
4874 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4875 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4876 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
4877 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4878 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4879 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4880 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4881 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
4882 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
4883
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4884 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
4885 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4886 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
4887 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4888 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
4889 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4890 Py_CLEAR(tmp);
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4891 } 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
4892 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
4893 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4894 }
84850
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 (_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
4896 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4897 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
4898 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
4899 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
4900 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4901 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
4902 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
4903 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4904 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4905 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
4906 values = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4907 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
4908 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
4909 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
4910 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
4911 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4912 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
4913 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4914 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4915 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4916 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
4917 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4918 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4919 *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
4920 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
4921 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4922 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4923 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
4924 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4925 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4926 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4927 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4928 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
4929 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
4930 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
4931
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4932 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
4933 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4934 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
4935 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4936 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
4937 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4938 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4939 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4940 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
4941 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4942 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4943 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
4944 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4945 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
4946 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4947 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
4948 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4949 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4950 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4951 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
4952 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4953 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4954 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
4955 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4956 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
4957 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4958 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
4959 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4960 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4961 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4962 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
4963 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4964 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4965 *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
4966 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
4967 return 0;
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 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
4970 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4971 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4972 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4973 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4974 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
4975 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
4976
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4977 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
4978 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4979 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
4980 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4981 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
4982 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4983 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4984 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4985 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
4986 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
4987 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4988 if (_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
4989 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4990 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
4991 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4992 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
4993 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
4994 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4995 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4996 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
4997 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
4998 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
4999 *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
5000 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
5001 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5002 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5003 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
5004 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5005 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5006 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5007 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5008 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
5009 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
5010
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5011 if (_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
5012 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5013 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
5014 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5015 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
5016 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5017 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5018 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5019 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
5020 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5021 }
84850
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 (_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
5023 int res;
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 = _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
5025 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5026 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
5027 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5028 Py_CLEAR(tmp);
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 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5030 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
5031 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5032 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5033 *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
5034 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
5035 return 0;
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 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
5038 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5039 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5040 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5041 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5042 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
5043 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
5044 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
5045
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5046 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
5047 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5048 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
5049 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5050 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
5051 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5052 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5053 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5054 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
5055 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5056 }
84850
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 (_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
5058 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5059 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
5060 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5061 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
5062 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5063 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5064 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5065 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
5066 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5067 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5068 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
5069 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5070 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5071 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5072 res = obj2ast_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
5073 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5074 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5075 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5076 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
5077 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5078 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5079 *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
5080 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
5081 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5082 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5083 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
5084 if (isinstance == -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 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5086 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5087 if (isinstance) {
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* keys;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5089 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
5090
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5091 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
5092 int res;
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 len;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5094 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
5095 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
5096 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5097 if (!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
5098 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
5099 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5100 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5101 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
5102 keys = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5103 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
5104 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
5105 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
5106 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
5107 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5108 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
5109 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5110 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5111 } 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);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
5126 values = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
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 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5134 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5135 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5136 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
5137 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5138 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5139 *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
5140 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
5141 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5142 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5143 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
5144 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5145 return 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 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5147 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5148 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
5149
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5150 if (_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
5151 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5152 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
5153 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
5154 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
5155 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5156 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
5157 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
5158 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5159 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5160 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
5161 elts = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5162 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
5163 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
5164 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
5165 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
5166 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5167 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
5168 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5169 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5170 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5171 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
5172 return 1;
74391
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
5173 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5174 *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
5175 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
5176 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5177 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5178 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
5179 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5180 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5181 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5182 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5183 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
5184 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
5185
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5186 if (_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
5187 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5188 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
5189 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5190 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
5191 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5192 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5193 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5194 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
5195 return 1;
74391
e1177b9167ce make YieldFrom its own distinct from Yield (closes #13780)
Benjamin Peterson <benjamin@python.org>
parents: 74358
diff changeset
5196 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5197 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
5198 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5199 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
5200 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
5201 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
5202 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5203 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
5204 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
5205 goto 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 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5207 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
5208 generators = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5209 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
5210 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
5211 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
5212 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
5213 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5214 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
5215 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5216 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5217 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5218 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
5219 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5220 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5221 *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
5222 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
5223 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5224 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5225 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
5226 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5227 return 1;
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 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5230 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
5231 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
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 (_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
5234 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5235 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
5236 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5237 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
5238 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5239 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5240 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5241 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
5242 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5243 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5244 if (_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
5245 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5246 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
5247 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
5248 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
5249 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5250 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
5251 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
5252 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5253 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5254 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
5255 generators = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5256 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
5257 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
5258 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
5259 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
5260 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5261 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
5262 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5263 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5264 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5265 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
5266 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5267 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5268 *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
5269 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
5270 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5271 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5272 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
5273 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5274 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5275 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5276 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5277 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
5278 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
5279 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
5280
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5281 if (_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
5282 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5283 tmp = _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
5284 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5285 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
5286 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5287 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5288 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5289 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
5290 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5291 }
84850
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 (_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
5293 int res;
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 = _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
5295 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5296 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
5297 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5298 Py_CLEAR(tmp);
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 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5300 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
5301 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5302 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5303 if (_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
5304 int res;
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_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
5306 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
5307 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
5308 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5309 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
5310 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
5311 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5312 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5313 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
5314 generators = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5315 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
5316 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
5317 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
5318 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
5319 if (res != 0) goto 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 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
5321 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5322 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5323 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5324 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
5325 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5326 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5327 *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
5328 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
5329 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5330 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5331 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
5332 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5333 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5334 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5335 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5336 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
5337 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
5338
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5339 if (_PyObject_HasAttrId(obj, &PyId_elt)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5340 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5341 tmp = _PyObject_GetAttrId(obj, &PyId_elt);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5342 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5343 res = obj2ast_expr(tmp, &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
5344 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5345 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5346 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5347 PyErr_SetString(PyExc_TypeError, "required field \"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
5348 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5349 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5350 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
5351 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5352 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
5353 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
5354 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
5355 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5356 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
5357 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
5358 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5359 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5360 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
5361 generators = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5362 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
5363 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
5364 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
5365 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
5366 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5367 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
5368 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5369 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5370 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5371 PyErr_SetString(PyExc_TypeError, "required field \"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
5372 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5373 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5374 *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
5375 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
5376 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5377 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5378 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
5379 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5380 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5381 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5382 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5383 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
5384
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5385 if (exists_not_none(obj, &PyId_value)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5386 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5387 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
5388 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5389 res = obj2ast_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
5390 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5391 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5392 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5393 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
5394 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5395 *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
5396 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
5397 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5398 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5399 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
5400 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5401 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5402 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5403 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5404 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
5405
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5406 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
5407 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5408 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
5409 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5410 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
5411 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5412 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5413 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5414 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
5415 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5416 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5417 *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
5418 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
5419 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5420 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5421 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
5422 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5423 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5424 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5425 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5426 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
5427 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
5428 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
5429
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5430 if (_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
5431 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5432 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
5433 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5434 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
5435 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5436 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5437 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5438 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
5439 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5440 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5441 if (_PyObject_HasAttrId(obj, &PyId_ops)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5442 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5443 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
5444 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
5445 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
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 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
5448 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
5449 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5450 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5451 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
5452 ops = _Py_asdl_int_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5453 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
5454 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
5455 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
5456 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
5457 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5458 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
5459 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5460 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5461 } else {
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_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
5463 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5464 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5465 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
5466 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5467 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
5468 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
5469 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
5470 if (tmp == NULL) goto failed;
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 (!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
5472 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
5473 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5474 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5475 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
5476 comparators = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5477 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
5478 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
5479 expr_ty value;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5480 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
5481 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5482 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
5483 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5484 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5485 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5486 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
5487 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5488 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5489 *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
5490 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
5491 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5492 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5493 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
5494 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5495 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5496 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5497 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5498 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
5499 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
5500 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
5501 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
5502 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
5503
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5504 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
5505 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5506 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
5507 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5508 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
5509 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5510 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5511 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5512 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
5513 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5514 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5515 if (_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
5516 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5517 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
5518 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
5519 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
5520 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5521 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
5522 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
5523 goto 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 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5525 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
5526 args = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5527 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
5528 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
5529 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
5530 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
5531 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5532 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
5533 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5534 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5535 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5536 PyErr_SetString(PyExc_TypeError, "required field \"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
5537 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5538 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5539 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
5540 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5541 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
5542 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
5543 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
5544 if (tmp == NULL) goto 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 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
5546 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
5547 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5548 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5549 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
5550 keywords = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5551 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
5552 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
5553 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
5554 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
5555 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5556 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
5557 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5558 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5559 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5560 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
5561 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5562 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5563 if (exists_not_none(obj, &PyId_starargs)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5564 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5565 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
5566 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5567 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
5568 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5569 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5570 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5571 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
5572 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5573 if (exists_not_none(obj, &PyId_kwargs)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5574 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5575 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
5576 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5577 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
5578 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5579 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5580 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5581 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
5582 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5583 *out = 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
5584 arena);
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 (*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
5586 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5587 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5588 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
5589 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5590 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5591 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5592 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5593 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
5594
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5595 if (_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
5596 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5597 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
5598 if (tmp == NULL) goto 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 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
5600 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5601 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5602 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5603 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
5604 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5605 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5606 *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
5607 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
5608 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5609 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5610 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
5611 if (isinstance == -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 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5613 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5614 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5615 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
5616
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5617 if (_PyObject_HasAttrId(obj, &PyId_s)) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5618 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5619 tmp = _PyObject_GetAttrId(obj, &PyId_s);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5620 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5621 res = obj2ast_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
5622 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5623 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5624 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5625 PyErr_SetString(PyExc_TypeError, "required field \"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
5626 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
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 = 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
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*)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
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 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
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_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
5644 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5645 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5646 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5647 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
5648 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5649 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5650 *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
5651 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
5652 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5653 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5654 isinstance = PyObject_IsInstance(obj, (PyObject*)NameConstant_type);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5655 if (isinstance == -1) {
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5656 return 1;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5657 }
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5658 if (isinstance) {
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5659 singleton value;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5660
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5661 if (_PyObject_HasAttrId(obj, &PyId_value)) {
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5662 int res;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5663 tmp = _PyObject_GetAttrId(obj, &PyId_value);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5664 if (tmp == NULL) goto failed;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5665 res = obj2ast_singleton(tmp, &value, arena);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5666 if (res != 0) goto failed;
84853
9d26379db328 (Merge 3.3) Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84851 84852
diff changeset
5667 Py_CLEAR(tmp);
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5668 } else {
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5669 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NameConstant");
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5670 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5671 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5672 *out = NameConstant(value, lineno, col_offset, arena);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5673 if (*out == NULL) goto failed;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5674 return 0;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
5675 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5676 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
5677 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5678 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5679 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5680 if (isinstance) {
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 *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
5683 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
5684 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5685 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5686 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
5687 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5688 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5689 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5690 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5691 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
5692 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
5693 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
5694
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5695 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
5696 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5697 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
5698 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5699 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
5700 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5701 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5702 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5703 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
5704 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5705 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5706 if (_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
5707 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5708 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
5709 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5710 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
5711 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5712 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5713 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5714 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
5715 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5716 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5717 if (_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
5718 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5719 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
5720 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5721 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
5722 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5723 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5724 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5725 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
5726 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5727 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5728 *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
5729 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
5730 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5731 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5732 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
5733 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5734 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5735 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5736 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5737 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
5738 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
5739 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
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 (_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
5742 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5743 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
5744 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5745 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
5746 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5747 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5748 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5749 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
5750 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5751 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5752 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
5753 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5754 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
5755 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5756 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
5757 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5758 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5759 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5760 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
5761 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5762 }
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 (_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
5764 int res;
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 = _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
5766 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5767 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
5768 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5769 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5770 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5771 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
5772 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5773 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5774 *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
5775 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
5776 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5777 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5778 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
5779 if (isinstance == -1) {
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;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5781 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5782 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5783 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
5784 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
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 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
5787 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5788 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
5789 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5790 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
5791 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5792 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5793 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5794 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
5795 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5796 }
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 (_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
5798 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5799 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
5800 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5801 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
5802 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5803 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5804 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5805 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
5806 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5807 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5808 *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
5809 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
5810 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5811 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5812 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
5813 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5814 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5815 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5816 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5817 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
5818 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
5819
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5820 if (_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
5821 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5822 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
5823 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5824 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
5825 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5826 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5827 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5828 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
5829 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5830 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5831 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
5832 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5833 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
5834 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5835 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
5836 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5837 Py_CLEAR(tmp);
84850
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 \"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
5840 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5841 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5842 *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
5843 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
5844 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5845 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5846 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
5847 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5848 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5849 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5850 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5851 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
5852 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
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 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
5855 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5856 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
5857 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
5858 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
5859 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5860 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
5861 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
5862 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5863 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5864 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
5865 elts = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5866 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
5867 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
5868 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
5869 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
5870 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5871 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
5872 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5873 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5874 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5875 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
5876 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5877 }
84850
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 (_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
5879 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5880 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
5881 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5882 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
5883 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5884 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5885 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5886 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
5887 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5888 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5889 *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
5890 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
5891 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5892 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5893 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
5894 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5895 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5896 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5897 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5898 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
5899 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
5900
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5901 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
5902 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5903 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
5904 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
5905 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
5906 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5907 if (!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
5908 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
5909 goto failed;
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 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
5912 elts = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5913 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
5914 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
5915 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
5916 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
5917 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5918 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
5919 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5920 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5921 } else {
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_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
5923 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
5924 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5925 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
5926 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5927 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
5928 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5929 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
5930 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
5931 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5932 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5933 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
5934 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5935 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5936 *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
5937 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
5938 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5939 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5940
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5941 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
5942 failed:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5943 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5944 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5945 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5946
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5947 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5948 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
5949 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5950 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
5951
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5952 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
5953 if (isinstance == -1) {
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 1;
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 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5957 *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
5958 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5959 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5960 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
5961 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5962 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5963 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5964 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5965 *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
5966 return 0;
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 *)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
5969 if (isinstance == -1) {
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
5970 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
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 = Del;
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 *)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
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 = AugLoad;
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 *)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
5985 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
5986 return 1;
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 = AugStore;
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 *)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
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 = Param;
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
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6001 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
6002 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6003 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6004
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6005 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6006 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
6007 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6008 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
6009
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6010 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
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 (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
6013 *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
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 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
6017 if (isinstance == -1) {
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;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6019 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6020 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6021 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
6022 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
6023 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
6024
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6025 if (exists_not_none(obj, &PyId_lower)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6026 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6027 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
6028 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6029 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
6030 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6031 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6032 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6033 lower = NULL;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
6034 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6035 if (exists_not_none(obj, &PyId_upper)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6036 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6037 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
6038 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6039 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
6040 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6041 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6042 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6043 upper = NULL;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6044 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6045 if (exists_not_none(obj, &PyId_step)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6046 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6047 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
6048 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6049 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
6050 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6051 Py_CLEAR(tmp);
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 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6053 step = NULL;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
6054 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6055 *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
6056 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
6057 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6058 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6059 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
6060 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6061 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6062 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6063 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6064 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
6065
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6066 if (_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
6067 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6068 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
6069 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
6070 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
6071 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6072 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
6073 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
6074 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6075 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6076 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
6077 dims = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6078 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
6079 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
6080 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
6081 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
6082 if (res != 0) goto failed;
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_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
6084 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6085 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6086 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6087 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
6088 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6089 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6090 *out = 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
6091 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
6092 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6093 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6094 isinstance = PyObject_IsInstance(obj, (PyObject*)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
6095 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6096 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6097 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6098 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6099 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
6100
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6101 if (_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
6102 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6103 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
6104 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6105 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
6106 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6107 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6108 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6109 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
6110 return 1;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
6111 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6112 *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
6113 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
6114 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6115 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6116
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6117 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
6118 failed:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6119 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6120 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6121 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6122
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6123 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6124 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
6125 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6126 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
6127
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6128 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
6129 if (isinstance == -1) {
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6130 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
6131 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6132 if (isinstance) {
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 = And;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6134 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6135 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6136 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
6137 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6138 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6139 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6140 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6141 *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
6142 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6143 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6144
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6145 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
6146 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6147 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6148
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6149 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6150 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
6151 {
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 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
6153
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6154 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
6155 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6156 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6157 }
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) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6159 *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
6160 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6161 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6162 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
6163 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6164 return 1;
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 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6167 *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
6168 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6169 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6170 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
6171 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6172 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6173 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6174 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6175 *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
6176 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6177 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6178 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
6179 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6180 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6181 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6182 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6183 *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
6184 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6185 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6186 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
6187 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6188 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6189 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6190 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6191 *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
6192 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6193 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6194 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
6195 if (isinstance == -1) {
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6196 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
6197 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6198 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6199 *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
6200 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6201 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6202 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
6203 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6204 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6205 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6206 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6207 *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
6208 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6209 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6210 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
6211 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6212 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6213 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6214 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6215 *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
6216 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6217 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6218 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
6219 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6220 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6221 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6222 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6223 *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
6224 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6225 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6226 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
6227 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6228 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6229 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6230 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6231 *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
6232 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6233 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6234 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
6235 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6236 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6237 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6238 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6239 *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
6240 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6241 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6242 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
6243 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6244 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6245 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6246 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6247 *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
6248 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6249 }
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 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
6252 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6253 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6254
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6255 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6256 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
6257 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6258 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
6259
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6260 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
6261 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6262 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6263 }
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) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6265 *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
6266 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6267 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6268 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
6269 if (isinstance == -1) {
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6270 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
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 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6273 *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
6274 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6275 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6276 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
6277 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6278 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6279 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6280 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6281 *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
6282 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6283 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6284 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
6285 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6286 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6287 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6288 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6289 *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
6290 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6291 }
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 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
6294 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6295 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6296
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6297 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6298 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
6299 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6300 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
6301
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6302 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
6303 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6304 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6305 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6306 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6307 *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
6308 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6309 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6310 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
6311 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6312 return 1;
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 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6315 *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
6316 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6317 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6318 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
6319 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6320 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6321 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6322 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6323 *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
6324 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6325 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6326 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
6327 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6328 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6329 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6330 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6331 *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
6332 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6333 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6334 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
6335 if (isinstance == -1) {
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6336 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
6337 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6338 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6339 *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
6340 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6341 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6342 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
6343 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6344 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6345 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6346 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6347 *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
6348 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6349 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6350 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
6351 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6352 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6353 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6354 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6355 *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
6356 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6357 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6358 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
6359 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6360 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6361 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6362 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6363 *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
6364 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6365 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6366 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
6367 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6368 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6369 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6370 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6371 *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
6372 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6373 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6374 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
6375 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6376 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6377 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6378 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6379 *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
6380 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6381 }
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 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
6384 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6385 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6386
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6387 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6388 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
6389 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6390 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
6391 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
6392 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
6393 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
6394
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6395 if (_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
6396 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6397 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
6398 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6399 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
6400 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6401 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6402 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6403 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
6404 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6405 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6406 if (_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
6407 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6408 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
6409 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6410 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
6411 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6412 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6413 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6414 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
6415 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6416 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6417 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
6418 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6419 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
6420 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
6421 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
6422 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6423 if (!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
6424 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
6425 goto failed;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6426 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6427 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
6428 ifs = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6429 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
6430 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
6431 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
6432 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
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 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
6435 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6436 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6437 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6438 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
6439 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6440 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6441 *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
6442 return 0;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6443 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
6444 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6445 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6446 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6447
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6448 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6449 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
6450 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6451 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
6452
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6453 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
6454 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
6455 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
6456
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6457 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
6458 *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
6459 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6460 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6461 if (_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
6462 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6463 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
6464 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6465 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
6466 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6467 Py_CLEAR(tmp);
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 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6469 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
6470 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6471 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6472 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
6473 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6474 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
6475 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6476 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
6477 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6478 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6479 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6480 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
6481 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6482 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6483 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
6484 if (isinstance == -1) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6485 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6486 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6487 if (isinstance) {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6488 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
6489 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
6490 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
6491
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6492 if (exists_not_none(obj, &PyId_type)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6493 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6494 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
6495 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6496 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
6497 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6498 Py_CLEAR(tmp);
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6499 } 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
6500 type = NULL;
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
6501 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6502 if (exists_not_none(obj, &PyId_name)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6503 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6504 tmp = _PyObject_GetAttrId(obj, &PyId_name);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6505 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6506 res = obj2ast_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
6507 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6508 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6509 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6510 name = NULL;
46231
81ee270a6eb5 Merged revisions 62047 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46229
diff changeset
6511 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6512 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
6513 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6514 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
6515 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
6516 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
6517 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6518 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
6519 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
6520 goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6521 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6522 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
6523 body = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6524 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
6525 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
6526 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
6527 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
6528 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6529 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
6530 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6531 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6532 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6533 PyErr_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
6534 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6535 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6536 *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
6537 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
6538 return 0;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6539 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6540
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6541 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
6542 failed:
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6543 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6544 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6545 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6546
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6547 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6548 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
6549 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6550 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
6551 asdl_seq* args;
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6552 arg_ty vararg;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6553 asdl_seq* kwonlyargs;
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6554 asdl_seq* kw_defaults;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6555 arg_ty kwarg;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6556 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
6557
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6558 if (_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
6559 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6560 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
6561 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
6562 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
6563 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6564 if (!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
6565 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
6566 goto 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 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6568 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
6569 args = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6570 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
6571 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
6572 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
6573 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
6574 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6575 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
6576 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6577 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6578 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6579 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
6580 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6581 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6582 if (exists_not_none(obj, &PyId_vararg)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6583 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6584 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
6585 if (tmp == NULL) goto failed;
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6586 res = obj2ast_arg(tmp, &vararg, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6587 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6588 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6589 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6590 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
6591 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6592 if (_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
6593 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6594 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
6595 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
6596 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
6597 if (tmp == NULL) goto 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 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
6599 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
6600 goto failed;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6601 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6602 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
6603 kwonlyargs = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6604 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
6605 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
6606 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
6607 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
6608 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6609 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
6610 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6611 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6612 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6613 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
6614 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6615 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6616 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
6617 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6618 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
6619 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
6620 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
6621 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6622 if (!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
6623 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
6624 goto failed;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6625 }
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6626 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
6627 kw_defaults = _Py_asdl_seq_new(len, arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6628 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
6629 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
6630 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
6631 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
6632 if (res != 0) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6633 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
6634 }
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6635 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6636 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6637 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
6638 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6639 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6640 if (exists_not_none(obj, &PyId_kwarg)) {
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6641 int res;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6642 tmp = _PyObject_GetAttrId(obj, &PyId_kwarg);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6643 if (tmp == NULL) goto failed;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6644 res = obj2ast_arg(tmp, &kwarg, arena);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6645 if (res != 0) goto failed;
84853
9d26379db328 (Merge 3.3) Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84851 84852
diff changeset
6646 Py_CLEAR(tmp);
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6647 } else {
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6648 kwarg = NULL;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6649 }
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6650 if (_PyObject_HasAttrId(obj, &PyId_defaults)) {
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6651 int res;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6652 Py_ssize_t len;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6653 Py_ssize_t i;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6654 tmp = _PyObject_GetAttrId(obj, &PyId_defaults);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6655 if (tmp == NULL) goto failed;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6656 if (!PyList_Check(tmp)) {
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6657 PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6658 goto failed;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6659 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6660 len = PyList_GET_SIZE(tmp);
86258
142c62a490ce Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
Antoine Pitrou <solipsis@pitrou.net>
parents: 84856
diff changeset
6661 defaults = _Py_asdl_seq_new(len, arena);
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6662 if (defaults == NULL) goto failed;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6663 for (i = 0; i < len; i++) {
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6664 expr_ty value;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6665 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6666 if (res != 0) goto failed;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6667 asdl_seq_SET(defaults, i, value);
82732
7c5c678e4164 unify some ast.argument's attrs; change Attribute column offset (closes #16795)
Benjamin Peterson <benjamin@python.org>
parents: 81039
diff changeset
6668 }
84853
9d26379db328 (Merge 3.3) Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84851 84852
diff changeset
6669 Py_CLEAR(tmp);
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6670 } else {
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6671 PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments");
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6672 return 1;
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6673 }
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6674 *out = arguments(args, vararg, kwonlyargs, kw_defaults, kwarg, defaults,
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6675 arena);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6676 return 0;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6677 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
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 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6680 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6681
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6682 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6683 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
6684 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6685 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
6686 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
6687 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
6688
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 (_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
6690 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6691 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
6692 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6693 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
6694 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6695 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6696 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6697 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
6698 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6699 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6700 if (exists_not_none(obj, &PyId_annotation)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6701 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6702 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
6703 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6704 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
6705 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6706 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6707 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6708 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
6709 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6710 *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
6711 return 0;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6712 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
6713 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6714 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6715 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6716
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6717 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6718 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
6719 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6720 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
6721 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
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
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 (_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
6725 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6726 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
6727 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6728 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
6729 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6730 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6731 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6732 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
6733 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6734 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6735 if (_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
6736 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6737 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
6738 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6739 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
6740 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6741 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6742 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6743 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
6744 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6745 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6746 *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
6747 return 0;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6748 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
6749 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6750 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6751 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6752
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6753 int
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6754 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
6755 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6756 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
6757 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
6758 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
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_name)) {
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_name);
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_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
6765 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6766 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6767 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6768 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
6769 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6770 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6771 if (exists_not_none(obj, &PyId_asname)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6772 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6773 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
6774 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6775 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
6776 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6777 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6778 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6779 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
6780 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6781 *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
6782 return 0;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6783 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
6784 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6785 return 1;
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6786 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6787
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
6788 int
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
6789 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
6790 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6791 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
6792 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
6793 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
6794
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6795 if (_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
6796 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6797 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
6798 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6799 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
6800 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6801 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6802 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6803 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
6804 return 1;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6805 }
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6806 if (exists_not_none(obj, &PyId_optional_vars)) {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6807 int res;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6808 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
6809 if (tmp == NULL) goto failed;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6810 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
6811 if (res != 0) goto failed;
84852
d14f40c87438 Parser/asdl_c.py: use Py_CLEAR()
Victor Stinner <victor.stinner@gmail.com>
parents: 84850
diff changeset
6812 Py_CLEAR(tmp);
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6813 } else {
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6814 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
6815 }
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6816 *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
6817 return 0;
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
6818 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
6819 Py_XDECREF(tmp);
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6820 return 1;
70438
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
6821 }
9b11cc4e2918 reflect with statements with multiple items in the AST (closes #12106)
Benjamin Peterson <benjamin@python.org>
parents: 68428
diff changeset
6822
46208
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
6823
47580
94f64f11fdd0 Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents: 47301
diff changeset
6824 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
6825 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
6826 };
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
6827 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
6828 PyInit__ast(void)
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
6829 {
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6830 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
6831 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
6832 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
6833 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
6834 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
6835 if (PyDict_SetItemString(d, "AST", (PyObject*)&AST_type) < 0) return NULL;
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6836 if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0)
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6837 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6838 if (PyDict_SetItemString(d, "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
6839 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
6840 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6841 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
6842 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
6843 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
6844 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6845 if (PyDict_SetItemString(d, "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
6846 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6847 if (PyDict_SetItemString(d, "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
6848 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
6849 0) return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6850 if (PyDict_SetItemString(d, "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
6851 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6852 if (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
6853 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6854 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
6855 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6856 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
6857 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6858 if (PyDict_SetItemString(d, "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
6859 return NULL;
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 (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
6861 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
6862 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6863 if (PyDict_SetItemString(d, "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
6864 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
6865 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
6866 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6867 if (PyDict_SetItemString(d, "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
6868 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
6869 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6870 if (PyDict_SetItemString(d, "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
6871 NULL;
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 (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
6873 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6874 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
6875 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6876 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
6877 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6878 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
6879 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
6880 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
6881 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 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
6883 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6884 if (PyDict_SetItemString(d, "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
6885 if (PyDict_SetItemString(d, "BoolOp", (PyObject*)BoolOp_type) < 0) return
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6886 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6887 if (PyDict_SetItemString(d, "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
6888 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6889 if (PyDict_SetItemString(d, "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
6890 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6891 if (PyDict_SetItemString(d, "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
6892 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6893 if (PyDict_SetItemString(d, "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
6894 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6895 if (PyDict_SetItemString(d, "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
6896 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
6897 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
6898 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6899 if (PyDict_SetItemString(d, "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
6900 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6901 if (PyDict_SetItemString(d, "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
6902 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6903 if (PyDict_SetItemString(d, "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
6904 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
6905 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
6906 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6907 if (PyDict_SetItemString(d, "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
6908 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6909 if (PyDict_SetItemString(d, "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
6910 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6911 if (PyDict_SetItemString(d, "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
6912 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
6913 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
6914 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
6915 NULL;
84851
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6916 if (PyDict_SetItemString(d, "NameConstant", (PyObject*)NameConstant_type) <
1b464f8453a4 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 84679 84850
diff changeset
6917 0) return NULL;
84850
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6918 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
6919 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6920 if (PyDict_SetItemString(d, "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
6921 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6922 if (PyDict_SetItemString(d, "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
6923 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6924 if (PyDict_SetItemString(d, "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
6925 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6926 if (PyDict_SetItemString(d, "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
6927 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
6928 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
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, "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
6931 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, "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
6933 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
6934 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, "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
6936 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
6937 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6938 if (PyDict_SetItemString(d, "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
6939 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6940 if (PyDict_SetItemString(d, "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
6941 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6942 if (PyDict_SetItemString(d, "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
6943 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6944 if (PyDict_SetItemString(d, "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
6945 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, "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
6947 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6948 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
6949 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6950 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
6951 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, "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
6953 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
6954 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
6955 return 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, "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
6957 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
6958 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
6959 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
6960 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
6961 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
6962 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
6963 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, "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
6965 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, "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
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, "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
6969 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6970 if (PyDict_SetItemString(d, "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
6971 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, "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
6973 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6974 if (PyDict_SetItemString(d, "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
6975 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6976 if (PyDict_SetItemString(d, "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
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, "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
6979 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
6980 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
6981 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
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, "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
6984 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
6985 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6986 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
6987 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
6988 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
6989 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
6990 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
6991 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
6992 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, "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
6994 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
6995 NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
6996 if (PyDict_SetItemString(d, "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
6997 < 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, "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
6999 < 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
7000 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
7001 < 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
7002 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
7003 return NULL;
f2d557484906 According to the PEP 7, C code must "use 4-space indents"
Victor Stinner <victor.stinner@gmail.com>
parents: 80589
diff changeset
7004 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
7005 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
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, "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
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, "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
7010 return 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 return m;
36669
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
7012 }
9504f7ac3669 Create _ast module.
Martin v. Löwis <martin@v.loewis.de>
parents: 36666
diff changeset
7013
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
7014
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
7015 PyObject* PyAST_mod2obj(mod_ty t)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
7016 {
84679
cf8f42eadbd0 Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError)
Victor Stinner <victor.stinner@gmail.com>
parents: 83867
diff changeset
7017 if (!init_types())
cf8f42eadbd0 Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError)
Victor Stinner <victor.stinner@gmail.com>
parents: 83867
diff changeset
7018 return NULL;
36660
3c0b26113df6 Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents: 36174
diff changeset
7019 return ast2obj_mod(t);
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
7020 }
42013
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41825
diff changeset
7021
46227
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7022 /* 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
7023 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
7024 {
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7025 mod_ty res;
46227
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7026 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
7027 (PyObject*)Interactive_type};
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7028 char *req_name[] = {"Module", "Expression", "Interactive"};
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
7029 int isinstance;
46227
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7030 assert(0 <= mode && mode <= 2);
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7031
84679
cf8f42eadbd0 Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError)
Victor Stinner <victor.stinner@gmail.com>
parents: 83867
diff changeset
7032 if (!init_types())
cf8f42eadbd0 Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError)
Victor Stinner <victor.stinner@gmail.com>
parents: 83867
diff changeset
7033 return NULL;
46227
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7034
57677
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
7035 isinstance = PyObject_IsInstance(ast, req_type[mode]);
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
7036 if (isinstance == -1)
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
7037 return NULL;
1558dc69aacf Merged revisions 76776 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 51270
diff changeset
7038 if (!isinstance) {
46227
b2d93a960b98 Merged revisions 62039-62042 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46215
diff changeset
7039 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
7040 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
7041 return NULL;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7042 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7043 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
7044 return NULL;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7045 else
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7046 return res;
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7047 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7048
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7049 int PyAST_Check(PyObject* obj)
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7050 {
84679
cf8f42eadbd0 Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError)
Victor Stinner <victor.stinner@gmail.com>
parents: 83867
diff changeset
7051 if (!init_types())
cf8f42eadbd0 Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError)
Victor Stinner <victor.stinner@gmail.com>
parents: 83867
diff changeset
7052 return -1;
46229
07b36d2b7534 Merged revisions 62049,62054 via svnmerge from
Neal Norwitz <nnorwitz@gmail.com>
parents: 46227
diff changeset
7053 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
7054 }
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7055
ea75b12fe8e7 Merged revisions 62004 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 45495
diff changeset
7056