Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-98390: Fix source locations of boolean sub-expressions#98396

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
iritkatriel merged 2 commits intopython:mainfromiritkatriel:bool_linenos
Oct 18, 2022

Conversation

@iritkatriel
Copy link
Member

@iritkatrieliritkatriel commentedOct 18, 2022
edited by bedevere-bot
Loading

Tetita reacted with thumbs up emoji
@iritkatrieliritkatriel added type-bugAn unexpected behavior, bug, or error interpreter-core(Objects, Python, Grammar, and Parser dirs) labelsOct 18, 2022
Copy link
Member

@brandtbucherbrandtbucher left a comment
edited
Loading

Choose a reason for hiding this comment

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

Thanks, looks good.

One comment: I don't think this function needsploc anymore.LOC(e) is correct for everything emitted here, right?

It's actually abug that theCompare_kind case sets the location without restoring it after. I introduced it in#96968 but haven't fixed it yet (since I didn't want to interfere with your refactoring work).

@iritkatriel
Copy link
MemberAuthor

Thanks, looks good.

One comment: I don't think this function needsploc anymore.LOC(e) is correct for everything emitted here, right?

It's actually abug that theCompare_kind case sets the location without restoring it after. I introduced it in#96968 but haven't fixed it yet (since I didn't want to interfere with your refactoring work).

I'm going over all the call sites to see who consumes the modified ploc (expect a PR about assert shortly). Once nobody consumes it, I will convert it to loc.

@iritkatrieliritkatriel merged commitc051d55 intopython:mainOct 18, 2022
@iritkatrieliritkatriel deleted the bool_linenos branchDecember 7, 2022 15:49
@15r10nk
Copy link
Contributor

hi@iritkatriel,
I think theproblem with the first fix of@brandtbucher is still there.

script:

deffunc():assertaandb<c ,"msg"importdisforiindis.get_instructions(func):ifi.opnamein ("COMPARE_OP","CALL"):print(i.positions,i.opname,i.argval)

output (Python 3.11.1):

Positions(lineno=2,end_lineno=2,col_offset=17,end_col_offset=20)COMPARE_OP<Positions(lineno=2,end_lineno=2,col_offset=17,end_col_offset=20)CALL0

The CALL is the creation of the assertion which has the same source range asb<c.

output (Python 3.11.0):

Positions(lineno=2,end_lineno=2,col_offset=17,end_col_offset=20)COMPARE_OP<Positions(lineno=2,end_lineno=2,col_offset=4,end_col_offset=28)CALL0

The source range of CALL in 3.11.0 is the whole assertion, which looks reasonable for me.

Some context:
I implemented the python 3.11 support forexecuting, which relies on the source positions to map bytecode instructions back to ast-nodes.

@carljm
Copy link
Member

@15r10nk the behavior onmain is correct for your example. I think what you are pointing out is that this fix hasn't been backported to 3.11.

@iritkatriel what do you think, is this a candidate for backport?

@brandtbucher
Copy link
Member

brandtbucher commentedDec 20, 2022
edited
Loading

It probably makes the most sense just to fix 3.11 separately (with a backport to 3.10), since location-related stuff has changed a lot on main.

I assigned myself to the issue a while back, but other things came up. I'll just make a PR now (thanks for the reminder@15r10nk)!

@15r10nk
Copy link
Contributor

@carljm yes. I found this problem in 3.11.1.
I thought that this here is what was change between 3.11.0 and 3.11.1.
Sorry if this was the wrong pull-request.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@brandtbucherbrandtbucherbrandtbucher approved these changes

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

Assignees

No one assigned

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Source locations of boolean sub-expressions are too wide

5 participants

@iritkatriel@15r10nk@carljm@brandtbucher@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp