GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-134280: Disable constant folding for ~ with a boolean argument by serhiy-storchaka · Pull Request #134982 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented May 31, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This moves the deprecation warning from compile time to runtime.

  • Issue: ~bool deprecation not reported for literals #134280

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

decorator-factory reacted with rocket emoji
All reactions
  • 🚀 1 reaction
@serhiy-storchaka
pythongh-134280: Disable constant folding for ~ with a boolean argument
deb1724
This moves the deprecation warning from compile time to runtime.
@serhiy-storchaka
serhiy-storchaka requested review from iritkatriel and markshannon as code owners May 31, 2025 16:49
@serhiy-storchaka serhiy-storchaka added the needs backport to 3.14 bugs and security fixes label May 31, 2025
@bedevere-app bedevere-app Bot added the awaiting core review label May 31, 2025
@bedevere-app bedevere-app Bot mentioned this pull request May 31, 2025
~bool deprecation not reported for literals #134280
Closed
@serhiy-storchaka

serhiy-storchaka commented May 31, 2025

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

iritkatriel commented Jun 1, 2025

Copy link
Copy Markdown
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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka

serhiy-storchaka commented Jun 1, 2025

Copy link
Copy Markdown
Member Author

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

decorator-factory and timhoffm reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iritkatriel

iritkatriel commented Jun 1, 2025

Copy link
Copy Markdown
Member

Is it hard to detect this in the preprocessor?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka

serhiy-storchaka commented Jun 1, 2025

Copy link
Copy Markdown
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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

timhoffm
timhoffm reviewed Jun 1, 2025
View reviewed changes
Comment thread Python/flowgraph.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka added 3 commits June 10, 2025 13:54
@serhiy-storchaka
Merge branch 'main' into constant-folding-invert-bool
ac03563
@serhiy-storchaka
Add a comment about the temporary nature of the code.
cb7d754
@serhiy-storchaka
Merge branch 'main' into constant-folding-invert-bool
81306e8
@serhiy-storchaka
serhiy-storchaka merged commit 86c3316 into python:main Jul 1, 2025
@miss-islington-app

miss-islington-app Bot commented Jul 1, 2025

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting core review label Jul 1, 2025
@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
@serhiy-storchaka @miss-islington
pythongh-134280: Disable constant folding for ~ with a boolean argume…
cd7164f
…nt (pythonGH-134982)

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

Co-authored-by: Serhiy Storchaka <[email protected]>
@bedevere-app

bedevere-app Bot commented Jul 1, 2025

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@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
@miss-islington @serhiy-storchaka
[3.14] gh-134280: Disable constant folding for ~ with a boolean argum…
8ba024d
…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 <[email protected]>
AndPuQing pushed a commit to AndPuQing/cpython that referenced this pull request Jul 11, 2025
@serhiy-storchaka @AndPuQing
pythongh-134280: Disable constant folding for ~ with a boolean argume…
32da324
…nt (pythonGH-134982)

This moves the deprecation warning from compile time to run time.
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
@serhiy-storchaka @Pranjal095
pythongh-134280: Disable constant folding for ~ with a boolean argume…
102920b
…nt (pythonGH-134982)

This moves the deprecation warning from compile time to run time.
picnixz pushed a commit to picnixz/cpython that referenced this pull request Jul 13, 2025
@serhiy-storchaka @picnixz
pythongh-134280: Disable constant folding for ~ with a boolean argume…
7fd5590
…nt (pythonGH-134982)

This moves the deprecation warning from compile time to run time.
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
@serhiy-storchaka @taegyunkim
pythongh-134280: Disable constant folding for ~ with a boolean argume…
ffefde0
…nt (pythonGH-134982)

This moves the deprecation warning from compile time to run time.
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
@serhiy-storchaka @Agent-Hellboy
pythongh-134280: Disable constant folding for ~ with a boolean argume…
37481cd
…nt (pythonGH-134982)

This moves the deprecation warning from compile time to run time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
@iritkatriel iritkatriel Awaiting requested review from iritkatriel iritkatriel is a code owner
@Eclips4 Eclips4 Awaiting requested review from Eclips4 Eclips4 is a code owner
1 more reviewer
@timhoffm timhoffm timhoffm left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@serhiy-storchaka @iritkatriel @timhoffm
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.