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

col_offset for parenthesized expressions looks weird #83655

Closed
isidentical opened this issue Jan 28, 2020 · 7 comments
Closed

col_offset for parenthesized expressions looks weird #83655

isidentical opened this issue Jan 28, 2020 · 7 comments
Assignees
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

@isidentical
Copy link
Sponsor Member

BPO 39474
Nosy @gvanrossum, @benjaminp, @serhiy-storchaka, @lysnikolaou, @pablogsal, @miss-islington, @isidentical
PRs
  • bpo-39474: Fix AST pos for expressions like (a)(b), (a)[b] and (a).b. #18477
  • [3.8] bpo-39474: Fix AST pos for expressions like (a)(b), (a)[b] and (a).b. (GH-18477) #18491
  • 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 = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2020-02-12.21:54:32.088>
    created_at = <Date 2020-01-28.08:41:48.702>
    labels = ['interpreter-core', 'type-bug', '3.8', '3.9']
    title = 'col_offset for parenthesized expressions looks weird'
    updated_at = <Date 2020-02-12.21:54:32.087>
    user = 'https://github.com/isidentical'

    bugs.python.org fields:

    activity = <Date 2020-02-12.21:54:32.087>
    actor = 'gvanrossum'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2020-02-12.21:54:32.088>
    closer = 'gvanrossum'
    components = ['Interpreter Core']
    creation = <Date 2020-01-28.08:41:48.702>
    creator = 'BTaskaya'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39474
    keywords = ['patch']
    message_count = 7.0
    messages = ['360844', '361842', '361845', '361898', '361913', '361916', '361919']
    nosy_count = 7.0
    nosy_names = ['gvanrossum', 'benjamin.peterson', 'serhiy.storchaka', 'lys.nikolaou', 'pablogsal', 'miss-islington', 'BTaskaya']
    pr_nums = ['18477', '18491']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue39474'
    versions = ['Python 3.8', 'Python 3.9']

    @isidentical
    Copy link
    Sponsor Member Author

    Python 3.9.0a2+ (heads/master:65ecc390c1, Jan 26 2020, 15:39:11) 
    [GCC 9.2.1 20191008] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import ast
    >>> source = "(2+2).source"
    >>> ast.get_source_segment(source, ast.parse(source).body[0].value)
    '2+2).source'
    >>> source = "(2+2)[1]"
    >>> ast.get_source_segment(source, ast.parse(source).body[0].value)
    '2+2)[1]'

    I can prepare a patch to extend attribute's col_offset into parens if it is any if approved.

    @isidentical isidentical added 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jan 28, 2020
    @isidentical isidentical changed the title col_offset for parenthesized expressions looks weird on attribute access col_offset for parenthesized expressions looks weird Jan 28, 2020
    @isidentical isidentical added the type-bug An unexpected behavior, bug, or error label Jan 28, 2020
    @gvanrossum
    Copy link
    Member

    This is also a 3.8 issue. We discovered this with pegen, and would love to see it fixed.

    @gvanrossum gvanrossum added the 3.8 only security fixes label Feb 12, 2020
    @lysnikolaou
    Copy link
    Contributor

    Are you going to work on a patch then, Batuhan?

    @isidentical
    Copy link
    Sponsor Member Author

    Are you going to work on a patch then, Batuhan?

    Serhiy already submitted a PR, which looks great.

    @serhiy-storchaka
    Copy link
    Member

    New changeset 6e619c4 by Serhiy Storchaka in branch 'master':
    bpo-39474: Fix AST pos for expressions like (a)(b), (a)[b] and (a).b. (GH-18477)
    6e619c4

    @miss-islington
    Copy link
    Contributor

    New changeset 2076d4f by Miss Islington (bot) in branch '3.8':
    bpo-39474: Fix AST pos for expressions like (a)(b), (a)[b] and (a).b. (GH-18477)
    2076d4f

    @gvanrossum
    Copy link
    Member

    Thanks!

    @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

    5 participants