Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7e0dc7ed
Commit
7e0dc7ed
authored
Feb 26, 2006
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix iterating over cmpop_ty lists.
parent
7ea809c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
7 deletions
+20
-7
Parser/asdl_c.py
Parser/asdl_c.py
+13
-5
Python/Python-ast.c
Python/Python-ast.c
+7
-2
No files found.
Parser/asdl_c.py
View file @
7e0dc7ed
...
...
@@ -609,13 +609,21 @@ class ObjVisitor(PickleVisitor):
def
set
(
self
,
field
,
value
,
depth
):
if
field
.
seq
:
# XXX should really check for is_simple, but that requires a symbol table
if
field
.
type
.
value
==
"cmpop"
:
# XXX check that this cast is safe, i.e. works independent on whether
# sizeof(cmpop_ty) != sizeof(void*)
cast
=
"(PyObject*(*)(void*))"
# While the sequence elements are stored as void*,
# ast2obj_cmpop expects an enum
self
.
emit
(
"{"
,
depth
)
self
.
emit
(
"int i, n = asdl_seq_LEN(%s);"
%
value
,
depth
+
1
)
self
.
emit
(
"value = PyList_New(n);"
,
depth
+
1
)
self
.
emit
(
"if (!value) goto failed;"
,
depth
+
1
)
self
.
emit
(
"for(i = 0; i < n; i++)"
,
depth
+
1
)
# This cannot fail, so no need for error handling
self
.
emit
(
"PyList_SET_ITEM(value, i, ast2obj_%s((%s_ty)asdl_seq_GET(%s, i)));"
%
(
field
.
type
,
field
.
type
,
value
),
depth
+
2
,
reflow
=
False
)
self
.
emit
(
"}"
,
depth
)
else
:
cast
=
""
self
.
emit
(
"value = ast2obj_list(%s, %sast2obj_%s);"
%
(
value
,
cast
,
field
.
type
),
depth
)
self
.
emit
(
"value = ast2obj_list(%s, ast2obj_%s);"
%
(
value
,
field
.
type
),
depth
)
else
:
ctype
=
get_c_type
(
field
.
type
)
self
.
emit
(
"value = ast2obj_%s(%s);"
%
(
field
.
type
,
value
),
depth
,
reflow
=
False
)
...
...
Python/Python-ast.c
View file @
7e0dc7ed
...
...
@@ -2216,8 +2216,13 @@ ast2obj_expr(void* _o)
if
(
PyObject_SetAttrString
(
result
,
"left"
,
value
)
==
-
1
)
goto
failed
;
Py_DECREF
(
value
);
value
=
ast2obj_list
(
o
->
v
.
Compare
.
ops
,
(
PyObject
*
(
*
)(
void
*
))
ast2obj_cmpop
);
{
int
i
,
n
=
asdl_seq_LEN
(
o
->
v
.
Compare
.
ops
);
value
=
PyList_New
(
n
);
if
(
!
value
)
goto
failed
;
for
(
i
=
0
;
i
<
n
;
i
++
)
PyList_SET_ITEM
(
value
,
i
,
ast2obj_cmpop
((
cmpop_ty
)
asdl_seq_GET
(
o
->
v
.
Compare
.
ops
,
i
)));
}
if
(
!
value
)
goto
failed
;
if
(
PyObject_SetAttrString
(
result
,
"ops"
,
value
)
==
-
1
)
goto
failed
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment