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-124285: Fix bug where bool() is called multiple times for the same part of a boolean expression by iritkatriel · Pull Request #124394 · python/cpython

Conversation

@iritkatriel

@iritkatriel iritkatriel commented Sep 23, 2024 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Fixes #124285.

  • Issue: Behavior change for foo and 1 or 2: 3.12 newly converts foo to bool twice #124285

📚 Documentation preview 📚: https://cpython-previews--124394.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

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

All reactions
@iritkatriel
pythongh-124285: Fix bug where bool() is called multiple times for th…
9cd97d4
…e same part of a boolean expression
@iritkatriel
iritkatriel requested a review from markshannon as a code owner September 23, 2024 22:58
@bedevere-app bedevere-app Bot added the awaiting core review label Sep 23, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Sep 23, 2024
Behavior change for foo and 1 or 2: 3.12 newly converts foo to bool twice #124285
Open
iritkatriel
iritkatriel commented Sep 23, 2024
View reviewed changes
Comment thread Python/bytecodes.c Resolved

Uh oh!

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

iritkatriel added 3 commits September 24, 2024 15:46
@iritkatriel
teach cases generator about sequence-shortcut psuedo instructions
2612ace
@iritkatriel
add annotation
f9891e2
@iritkatriel
bump magic number
b5358ec
markshannon
markshannon approved these changes Sep 24, 2024
View reviewed changes

@markshannon markshannon left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Very nice.
One suggestion for a comment, otherwise lgtm.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Tools/cases_generator/opcode_metadata_generator.py Resolved

Uh oh!

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

@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Sep 24, 2024
iritkatriel and others added 4 commits September 24, 2024 18:20
@iritkatriel
no need for 1+ anymore
e3137b6
@iritkatriel
Merge branch 'main' into pseudo-jumps
ef192ae
@iritkatriel
fix it
9564043
@iritkatriel
Merge branch 'main' into pseudo-jumps
02d0626
@JelleZijlstra

JelleZijlstra commented Sep 24, 2024

Copy link
Copy Markdown
Member

@ncoghlan on the issue suggested we could do this in the AST optimizer without changing the eval loop. Is that approach worth considering? It would involve transforming a and b or c into (b or c) if a else c.

All reactions

Sorry, something went wrong.

Uh oh!

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

@iritkatriel

iritkatriel commented Sep 24, 2024

Copy link
Copy Markdown
Member Author

@ncoghlan on the issue suggested we could do this in the AST optimizer without changing the eval loop. Is that approach worth considering? It would involve transforming a and b or c into (b or c) if a else c.

I'm not sure I see what the general solution is, but I'm all for trying it.

All reactions

Sorry, something went wrong.

Uh oh!

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

@iritkatriel
Merge branch 'main' into pseudo-jumps
468ce65
@iritkatriel

iritkatriel commented Sep 25, 2024

Copy link
Copy Markdown
Member Author

I'll merge this though - we can easily replace this with the alternative idea. The "sequence" pseudo-ops change is worth having anyway.

All reactions

Sorry, something went wrong.

Uh oh!

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

@iritkatriel
iritkatriel merged commit 78aeb38 into python:main Sep 25, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Sep 25, 2024
@brianschubert brianschubert mentioned this pull request Jul 31, 2025
Python implicit boolean conversion in logical operations bypasses try/except on 3.14.0rc1 #137288
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@markshannon markshannon markshannon approved these changes

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.

Behavior change for foo and 1 or 2: 3.12 newly converts foo to bool twice

Uh oh!

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

3 participants

@iritkatriel @JelleZijlstra @markshannon
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.