Skip to content

bpo-39080: Starred Expression's column offset fix when inside a CALL#17645

Merged
pablogsal merged 4 commits into
python:masterfrom
lysnikolaou:starred-expr-col
Dec 18, 2019
Merged

bpo-39080: Starred Expression's column offset fix when inside a CALL#17645
pablogsal merged 4 commits into
python:masterfrom
lysnikolaou:starred-expr-col

Conversation

@lysnikolaou

@lysnikolaou lysnikolaou commented Dec 17, 2019

Copy link
Copy Markdown
Member

Comment thread Misc/NEWS.d/next/Core and Builtins/2019-12-17-21-45-36.bpo-39080.OrxEVS.rst Outdated
…80.OrxEVS.rst

Co-Authored-By: Pablo Galindo <Pablogsal@gmail.com>
@pablogsal

pablogsal commented Dec 17, 2019

Copy link
Copy Markdown
Member

Actually, this seems that does not only affect starred expressions. For example:

>>> val = "f(a,b,c)"
>>> val[ast.parse(val).body[0].value.args[2].end_col_offset]
')'
>>> val[ast.parse(val).body[0].value.args[0].end_col_offset]
','
>>> val[ast.parse(val).body[0].value.args[1].end_col_offset]
','
>>> val[ast.parse(val).body[0].value.args[2].end_col_offset]
')'

that seems odd.

@gvanrossum

Copy link
Copy Markdown
Member

Possibly @ilevkivskyi would also be interested in hearing about this?

@pablogsal

Copy link
Copy Markdown
Member

Nevermind, I imagine that is so you can do expression[col_offset:end_col_offset].

@lysnikolaou

Copy link
Copy Markdown
Member Author

Actually, this seems that does not only affect starred expressions.

That's actually ok, because end_col_offset is always where the token ends + 1. In your examples col_offset of a is 2 and end_col_offset is 3, which is the intended behavior.

@pablogsal

Copy link
Copy Markdown
Member

That's actually ok, because end_col_offset is always where the token ends + 1. In your examples col_offset of a is 2 and end_col_offset is 3, which is the intended behavior.

Yup. Also the fix is consistent with extracting the values via expression[col_offset:end_col_offset]

@ilevkivskyi ilevkivskyi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This totally makes sense, with the current logic end position is the end position of the * symbol itself, which is wrong.

@ilevkivskyi

Copy link
Copy Markdown
Member

This doesn't need backport to 3.7 as this is a new feature in 3.8

@lysnikolaou

Copy link
Copy Markdown
Member Author

@ilevkivskyi A similar change I made in #17582 was considered a bugfix and was backported to 3.7

@pablogsal

pablogsal commented Dec 18, 2019

Copy link
Copy Markdown
Member

@lysnikolaou In #17582 what changed was the col_offset that is accessible by Python AST objects in 3.7, but end_col_offset and end_lineno was introduced in 3.8.

@pablogsal pablogsal merged commit 50d4f12 into python:master Dec 18, 2019
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @lysnikolaou for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

I'm having trouble backporting to 3.8. Reason: 'Error 110 while writing to socket. Connection timed out.'. Please retry by removing and re-adding the needs backport to 3.8 label.

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @lysnikolaou for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

Sorry @lysnikolaou and @pablogsal, I had trouble checking out the 3.8 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 50d4f12958bf806a4e1a1021d70cfd5d448c5cba 3.8

pablogsal pushed a commit to pablogsal/cpython that referenced this pull request Dec 18, 2019
… CALL (pythonGH-17645)

Co-Authored-By: Pablo Galindo <Pablogsal@gmail.com>
(cherry picked from commit 50d4f12)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

GH-17649 is a backport of this pull request to the 3.8 branch.

miss-islington pushed a commit that referenced this pull request Dec 18, 2019
… CALL (GH-17645) (GH-17649)

… 
Co-Authored-By: Pablo Galindo <Pablogsal@gmail.com>
(cherry picked from commit 50d4f12)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>





https://bugs.python.org/issue39080
shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request Jan 31, 2020
@lysnikolaou lysnikolaou deleted the starred-expr-col branch May 8, 2020 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants