gh-134280: Disable constant folding for ~ with a boolean argument by serhiy-storchaka · Pull Request #134982 · python/cpython · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

gh-134280: Disable constant folding for ~ with a boolean argument #134982

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

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented May 31, 2025

This moves the deprecation warning from compile time to runtime.

This moves the deprecation warning from compile time to runtime.
@serhiy-storchaka
Copy link
Member Author

3.14 and 3.13 differ from main, so I would do backporting step by step.

@Eclips4 Eclips4 self-requested a review May 31, 2025 20:05
@iritkatriel
Copy link
Member

If we can detect this in https://github.com/python/cpython/blob/main/Python/ast_preprocess.c then we get the warning in both static analysis and execution.

@serhiy-storchaka
Copy link
Member Author

Yes, but we only add SyntaxWarning for very common errors. ~True is unlikely used in real code.

@iritkatriel
Copy link
Member

Is it hard to detect this in the preprocessor?

@serhiy-storchaka
Copy link
Member Author

I do not know. But even a couple lines of code is a high price for this feature. And it will be more than a couple lines.

@serhiy-storchaka serhiy-storchaka merged commit 86c3316 into python:main Jul 1, 2025
40 checks passed
@miss-islington-app
Copy link

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@serhiy-storchaka serhiy-storchaka deleted the constant-folding-invert-bool branch July 1, 2025 17:24
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 1, 2025
…nt (pythonGH-134982)

This moves the deprecation warning from compile time to run time.
(cherry picked from commit 86c3316)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Jul 1, 2025

GH-136185 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jul 1, 2025
serhiy-storchaka added a commit that referenced this pull request Jul 2, 2025
…ent (GH-134982) (GH-136185)

This moves the deprecation warning from compile time to run time.
(cherry picked from commit 86c3316)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
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.

3 participants

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.