FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-130775: Allow negative locations in `ast` by sobolevn · Pull Request #130795 · python/cpython · GitHub

Repository navigation

gh-130775: Allow negative locations in ast - #130795

Merged
sobolevn merged 5 commits into
python:mainfrom
sobolevn:issue-130775
Apr 7, 2025
Merged

sobolevn merged 5 commits into
python:mainfrom
sobolevn:issue-130775

Conversation

sobolevn commented Mar 3, 2025 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

picnixz 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
  • 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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Comment thread Python/ast.c Outdated
Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner previously approved these changes Mar 3, 2025

vstinner 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Comment thread Lib/test/test_ast/test_ast.py Outdated
Comment thread Lib/test/test_ast/test_ast.py Outdated
Comment thread Python/assemble.c Outdated
Comment thread Python/ast.c Outdated
Comment thread Python/ast.c Outdated
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 commented Mar 13, 2025 •
edited
Loading

Copy link
Copy Markdown
Member Author

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!

vstinner 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM.

Copy link
Copy Markdown
Member Author

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

sobolevn requested a review from JelleZijlstra April 7, 2025 12:01
sobolevn requested a review from iritkatriel April 7, 2025 12:02
sobolevn merged commit bc5233b into python:main Apr 7, 2025
sobolevn added needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes labels Apr 7, 2025

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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 commented Apr 7, 2025

Copy link
Copy Markdown
Member Author

Thanks everyone! 🎉

sobolevn commented Apr 7, 2025

Copy link
Copy Markdown
Member Author

I will work on manual backports today.

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 Bot commented Apr 7, 2025

Copy link
Copy Markdown

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

bedevere-app Bot removed the needs backport to 3.13 only 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 Bot commented Apr 8, 2025

Copy link
Copy Markdown

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

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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL