This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lys.nikolaou
Recipients lys.nikolaou, miss-islington, pablogsal
Date 2019-12-14.04:53:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1576299225.02.0.0981363886162.issue39031@roundup.psfhosted.org>
In-reply-to
Content
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=[],
)
History
Date User Action Args
2019-12-14 04:53:45lys.nikolaousetrecipients: + lys.nikolaou, pablogsal, miss-islington
2019-12-14 04:53:45lys.nikolaousetmessageid: <1576299225.02.0.0981363886162.issue39031@roundup.psfhosted.org>
2019-12-14 04:53:45lys.nikolaoulinkissue39031 messages
2019-12-14 04:53:44lys.nikolaoucreate