classification
Title: col_offset for parenthesized expressions looks weird
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: BTaskaya, benjamin.peterson, gvanrossum, lys.nikolaou, miss-islington, pablogsal, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2020-01-28 08:41 by BTaskaya, last changed 2020-02-12 21:54 by gvanrossum. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18477 merged serhiy.storchaka, 2020-02-12 10:03
PR 18491 merged miss-islington, 2020-02-12 20:38
Messages (7)
msg360844 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python triager) Date: 2020-01-28 08:41
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.
msg361842 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-02-12 00:39
This is also a 3.8 issue. We discovered this with pegen, and would love to see it fixed.
msg361845 - (view) Author: Lysandros Nikolaou (lys.nikolaou) * (Python committer) Date: 2020-02-12 00:56
Are you going to work on a patch then, Batuhan?
msg361898 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python triager) Date: 2020-02-12 14:54
> Are you going to work on a patch then, Batuhan?

Serhiy already submitted a PR, which looks great.
msg361913 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-02-12 20:37
New changeset 6e619c48b8e804ece9521453fc8da0640a04d5b1 by Serhiy Storchaka in branch 'master':
bpo-39474: Fix AST pos for expressions like (a)(b), (a)[b] and (a).b. (GH-18477)
https://github.com/python/cpython/commit/6e619c48b8e804ece9521453fc8da0640a04d5b1
msg361916 - (view) Author: miss-islington (miss-islington) Date: 2020-02-12 20:56
New changeset 2076d4f97ef514bb4dc4ca768fbaa3f538ce7f1f 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)
https://github.com/python/cpython/commit/2076d4f97ef514bb4dc4ca768fbaa3f538ce7f1f
msg361919 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-02-12 21:54
Thanks!
History
Date User Action Args
2020-02-12 21:54:32gvanrossumsetstatus: open -> closed
resolution: fixed
messages: + msg361919

stage: patch review -> resolved
2020-02-12 20:56:50miss-islingtonsetnosy: + miss-islington
messages: + msg361916
2020-02-12 20:38:18miss-islingtonsetpull_requests: + pull_request17864
2020-02-12 20:37:53serhiy.storchakasetmessages: + msg361913
2020-02-12 14:54:38BTaskayasetmessages: + msg361898
2020-02-12 10:03:55serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request17847
2020-02-12 08:11:22serhiy.storchakasetassignee: serhiy.storchaka
2020-02-12 07:41:40serhiy.storchakasetnosy: + serhiy.storchaka
2020-02-12 00:56:31lys.nikolaousetmessages: + msg361845
2020-02-12 00:39:58gvanrossumsetnosy: + gvanrossum

messages: + msg361842
versions: + Python 3.8
2020-02-12 00:09:13lys.nikolaousetnosy: + lys.nikolaou
2020-01-28 08:43:18BTaskayasettype: behavior
title: col_offset for parenthesized expressions looks weird on attribute access -> col_offset for parenthesized expressions looks weird
2020-01-28 08:41:48BTaskayacreate