Skip to content

gh-130775: Allow negative locations in ast #130795

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

Merged
merged 5 commits into from
Apr 7, 2025
Merged

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Mar 3, 2025

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

If we cannot bypass the ast.c layer and directly end up in the assemble.c, then this should be the correct approach (I didn't know where we validate the locations).

Comment on lines +211 to +214
{'lineno': -2, 'col_offset': 0},
{'lineno': 0, 'col_offset': -2},
{'lineno': 0, 'col_offset': -2, 'end_col_offset': -2},
{'lineno': -2, 'end_lineno': -2, 'col_offset': 0},
Copy link
Member

Choose a reason for hiding this comment

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

  • Off topic: are we already testing that passing a non-int is fine?
  • Maybe test with values that are excessively large (either in + or -) just for overflow checks.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will open a new issue for that, if we don't. Thanks for the idea.

Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner
vstinner previously approved these changes Mar 3, 2025
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM. I just suggest a shorter test name :-)

@vstinner vstinner dismissed their stale review March 7, 2025 16:08

I remove my LGTM vote, I didn't notice that -1 value is still allowed. I'm not sure about rejecting values <= -2.

@sobolevn
Copy link
Member Author

sobolevn commented Mar 13, 2025

Ok, I followed the idea in #130795 (comment) by @JelleZijlstra and now all negative locations are just allowed. This way we won't have any compat issues and can backport this fix easily.

Thanks a lot, everyone!

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM.

@sobolevn
Copy link
Member Author

Looks like #130627 changed a lot of related things. Digging into it.

@sobolevn sobolevn requested a review from JelleZijlstra April 7, 2025 12:01
@sobolevn sobolevn requested a review from iritkatriel April 7, 2025 12:02
@sobolevn sobolevn merged commit bc5233b into python:main Apr 7, 2025
42 checks passed
@sobolevn sobolevn added needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes labels Apr 7, 2025
@miss-islington-app
Copy link

Thanks @sobolevn for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @sobolevn for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @sobolevn, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker bc5233b6a5cdd8f77a4737ce317f94110869c082 3.12

@miss-islington-app
Copy link

Sorry, @sobolevn, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker bc5233b6a5cdd8f77a4737ce317f94110869c082 3.13

@sobolevn
Copy link
Member Author

sobolevn commented Apr 7, 2025

Thanks everyone! 🎉

@sobolevn
Copy link
Member Author

sobolevn commented Apr 7, 2025

I will work on manual backports today.

@sobolevn sobolevn changed the title gh-130775: Validate negative locations in ast gh-130775: Allow negative locations in ast Apr 7, 2025
sobolevn added a commit to sobolevn/cpython that referenced this pull request Apr 7, 2025
…30795)

(cherry picked from commit bc5233b)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
@bedevere-app
Copy link

bedevere-app bot commented Apr 7, 2025

GH-132243 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Apr 7, 2025
Yhg1s pushed a commit that referenced this pull request Apr 8, 2025
)

(cherry picked from commit bc5233b)

Co-authored-by: Victor Stinner <vstinner@python.org>
sobolevn added a commit to sobolevn/cpython that referenced this pull request Apr 8, 2025
…30795)

(cherry picked from commit bc5233b)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
@bedevere-app
Copy link

bedevere-app bot commented Apr 8, 2025

GH-132260 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Apr 8, 2025
Yhg1s pushed a commit that referenced this pull request Apr 8, 2025
)

(cherry picked from commit bc5233b)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 2025
Co-authored-by: Victor Stinner <vstinner@python.org>
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.

6 participants