There was a bug in my last PR, hopefully I will get a fix some time later today.
The bug is as follows: I only updated the asdl_seq_SET call for an elif without an else, if an else is included then the behavior is like before.
After my last PR it looks like this, parsing
2:if a:
3: pass
4:elif b:
5: pass
outputs the following AST:
Module(
body=[
If(
test=Name(id="a", ctx=Load(), lineno=2, col_offset=3, end_lineno=2, end_col_offset=4),
body=[Pass(lineno=3, col_offset=4, end_lineno=3, end_col_offset=8)],
orelse=[
If(
test=Name(
id="b", ctx=Load(), lineno=4, col_offset=5, end_lineno=4, end_col_offset=6
),
body=[Pass(lineno=5, col_offset=4, end_lineno=5, end_col_offset=8)],
orelse=[],
lineno=4,
col_offset=0,
end_lineno=5,
end_col_offset=8,
)
],
lineno=2,
col_offset=0,
end_lineno=5,
end_col_offset=8,
)
],
type_ignores=[],
)
On the other hand parsing
2:if a:
3: pass
4:elif b:
5: pass
6:else:
7: pass
outputs
Module(
body=[
If(
test=Name(
id="a",
ctx=Load(),
lineno=2,
col_offset=3,
end_lineno=2,
end_col_offset=4,
),
body=[Pass(lineno=3, col_offset=4, end_lineno=3, end_col_offset=8)],
orelse=[
If(
test=Name(
id="b",
ctx=Load(),
lineno=4,
col_offset=5,
end_lineno=4,
end_col_offset=6,
),
body=[Pass(lineno=5, col_offset=4, end_lineno=5, end_col_offset=8)],
orelse=[
Pass(lineno=7, col_offset=4, end_lineno=7, end_col_offset=8)
],
lineno=4,
col_offset=5,
end_lineno=7,
end_col_offset=8,
)
],
lineno=2,
col_offset=0,
end_lineno=7,
end_col_offset=8,
)
],
type_ignores=[],
) |