Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency with Starred Expression line/col info #83261

Closed
lysnikolaou opened this issue Dec 17, 2019 · 3 comments
Closed

Inconsistency with Starred Expression line/col info #83261

lysnikolaou opened this issue Dec 17, 2019 · 3 comments
Labels
3.8 only security fixes 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@lysnikolaou
Copy link
Contributor

BPO 39080
Nosy @lysnikolaou, @pablogsal, @miss-islington
PRs
  • bpo-39080: Starred Expression's column offset fix when inside a CALL #17645
  • [3.8] bpo-39080: Starred Expression's column offset fix when inside a CALL (GH-17645) #17649
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-12-18.01:59:34.679>
    created_at = <Date 2019-12-17.21:32:08.200>
    labels = ['interpreter-core', 'type-bug', '3.8', '3.9']
    title = 'Inconsistency with Starred Expression line/col info'
    updated_at = <Date 2019-12-18.01:59:34.678>
    user = 'https://github.com/lysnikolaou'

    bugs.python.org fields:

    activity = <Date 2019-12-18.01:59:34.678>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-12-18.01:59:34.679>
    closer = 'pablogsal'
    components = ['Interpreter Core']
    creation = <Date 2019-12-17.21:32:08.200>
    creator = 'lys.nikolaou'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39080
    keywords = ['patch']
    message_count = 3.0
    messages = ['358584', '358600', '358603']
    nosy_count = 3.0
    nosy_names = ['lys.nikolaou', 'pablogsal', 'miss-islington']
    pr_nums = ['17645', '17649']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue39080'
    versions = ['Python 3.8', 'Python 3.9']

    @lysnikolaou
    Copy link
    Contributor Author

    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=[],
    )

    @lysnikolaou lysnikolaou added 3.8 only security fixes 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Dec 17, 2019
    @pablogsal
    Copy link
    Member

    New changeset 50d4f12 by Pablo Galindo (Lysandros Nikolaou) in branch 'master':
    bpo-39080: Starred Expression's column offset fix when inside a CALL (GH-17645)
    50d4f12

    @miss-islington
    Copy link
    Contributor

    New changeset b1f2044 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)
    b1f2044

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants