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.

classification
Title: Inconsistency with Starred Expression line/col info
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: lys.nikolaou, miss-islington, pablogsal
Priority: normal Keywords: patch

Created on 2019-12-17 21:32 by lys.nikolaou, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 17645 merged lys.nikolaou, 2019-12-17 21:43
PR 17649 merged pablogsal, 2019-12-18 00:23
Messages (3)
msg358584 - (view) Author: Lysandros Nikolaou (lys.nikolaou) * (Python committer) Date: 2019-12-17 21:32
When a starred expression like *[0, 1] is parsed, the following AST gets generated:

Module(
    body=[
        Expr(
            value=Starred(
                value=List(
                    elts=[
                        Constant(
                            value=0,
                            kind=None,
                            lineno=1,
                            col_offset=2,
                            end_lineno=1,
                            end_col_offset=3,
                        ),
                        Constant(
                            value=1,
                            kind=None,
                            lineno=1,
                            col_offset=5,
                            end_lineno=1,
                            end_col_offset=6,
                        ),
                    ],
                    ctx=Load(),
                    lineno=1,
                    col_offset=1,
                    end_lineno=1,
                    end_col_offset=7,
                ),
                ctx=Load(),
                lineno=1,
                col_offset=0,
                end_lineno=1,
                end_col_offset=7,
            ),
            lineno=1,
            col_offset=0,
            end_lineno=1,
            end_col_offset=7,
        )
    ],
    type_ignores=[],
)


But, when a starred expression is an argument to a function call then the line/col info are wrong (end_col_offset is always equal to col_offset + 1):

Module(
    body=[
        Expr(
            value=Call(
                func=Name(
                    id="f", ctx=Load(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=1
                ),
                args=[
                    Starred(
                        value=List(
                            elts=[
                                Constant(
                                    value=0,
                                    kind=None,
                                    lineno=1,
                                    col_offset=4,
                                    end_lineno=1,
                                    end_col_offset=5,
                                ),
                                Constant(
                                    value=1,
                                    kind=None,
                                    lineno=1,
                                    col_offset=7,
                                    end_lineno=1,
                                    end_col_offset=8,
                                ),
                            ],
                            ctx=Load(),
                            lineno=1,
                            col_offset=3,
                            end_lineno=1,
                            end_col_offset=9,
                        ),
                        ctx=Load(),
                        lineno=1,
                        col_offset=2,
                        end_lineno=1,
                        end_col_offset=9,
                    )
                ],
                keywords=[],
                lineno=1,
                col_offset=0,
                end_lineno=1,
                end_col_offset=10,
            ),
            lineno=1,
            col_offset=0,
            end_lineno=1,
            end_col_offset=10,
        )
    ],
    type_ignores=[],
)
msg358600 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-12-18 00:21
New changeset 50d4f12958bf806a4e1a1021d70cfd5d448c5cba by Pablo Galindo (Lysandros Nikolaou) in branch 'master':
bpo-39080: Starred Expression's column offset fix when inside a CALL (GH-17645)
https://github.com/python/cpython/commit/50d4f12958bf806a4e1a1021d70cfd5d448c5cba
msg358603 - (view) Author: miss-islington (miss-islington) Date: 2019-12-18 01:42
New changeset b1f204471092678dd89117e608fa041a9589d14c by Miss Islington (bot) (Pablo Galindo) in branch '3.8':
[3.8] bpo-39080: Starred Expression's column offset fix when inside a CALL (GH-17645) (GH-17649)
https://github.com/python/cpython/commit/b1f204471092678dd89117e608fa041a9589d14c
History
Date User Action Args
2022-04-11 14:59:24adminsetgithub: 83261
2019-12-18 01:59:34pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-12-18 01:42:03miss-islingtonsetnosy: + miss-islington
messages: + msg358603
2019-12-18 00:23:04pablogsalsetpull_requests: + pull_request17116
2019-12-18 00:21:09pablogsalsetnosy: + pablogsal
messages: + msg358600
2019-12-17 21:43:03lys.nikolaousetkeywords: + patch
stage: patch review
pull_requests: + pull_request17113
2019-12-17 21:32:08lys.nikolaoucreate