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-137288: Fix bug where boolean expressions are not associated with the correct exception handler by iritkatriel · Pull Request #137310 · python/cpython

Conversation

@iritkatriel

@iritkatriel iritkatriel commented Aug 1, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Fixes #137288.

  • Issue: Python implicit boolean conversion in logical operations bypasses try/except on 3.14.0rc1 #137288

Sorry, something went wrong.

Uh oh!

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

All reactions
@iritkatriel
pythongh-137288: Fix bug where boolean expressions are not associated…
71b151d
… with the correct exception handler
@iritkatriel
iritkatriel requested a review from markshannon as a code owner August 1, 2025 17:57
@iritkatriel iritkatriel added type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) 3.14 bugs and security fixes labels Aug 1, 2025
@bedevere-app bedevere-app Bot added the awaiting core review label Aug 1, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Aug 1, 2025
Python implicit boolean conversion in logical operations bypasses try/except on 3.14.0rc1 #137288
Closed
@iritkatriel
Merge branch 'main' into pythongh-137288
58dfd02
@picnixz picnixz added needs backport to 3.14 bugs and security fixes and removed 3.14 bugs and security fixes labels Aug 1, 2025
iritkatriel and others added 4 commits August 1, 2025 19:15
@iritkatriel
bump magic number
ea4f664
@iritkatriel
Merge branch 'main' into pythongh-137288
c9ae7ef
@iritkatriel
fix crash
d488c98
@iritkatriel
Revert "bump magic number"
af2128c
This reverts commit ea4f664.
@encukou

encukou commented Aug 4, 2025

Copy link
Copy Markdown
Member

This looks reasonable to me but I don't know this code enough to review it.

However, the fix will require bumping the PYC magic number in 3.14.0rc2 :( Heads up, @hugovk

All reactions

Sorry, something went wrong.

Uh oh!

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

@markshannon

markshannon commented Aug 5, 2025

Copy link
Copy Markdown
Member

The code changes look good to me.

I think this needs a separate pyc magic number bump for the backport.
On main: 3654 -> 3655, and for 3.14: 3624 -> 3625.

All reactions

Sorry, something went wrong.

Uh oh!

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

@iritkatriel
Reapply "bump magic number"
69708fe
This reverts commit af2128c.
@iritkatriel
iritkatriel merged commit 1f2026b into python:main Aug 5, 2025
@miss-islington-app

miss-islington-app Bot commented Aug 5, 2025

Copy link
Copy Markdown

Thanks @iritkatriel 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 Aug 5, 2025
@miss-islington-app

miss-islington-app Bot commented Aug 5, 2025

Copy link
Copy Markdown

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

cherry_picker 1f2026b8a239b3169c0cad0157eb08358152b4c1 3.14
All reactions

Sorry, something went wrong.

Uh oh!

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

iritkatriel added a commit to iritkatriel/cpython that referenced this pull request Aug 5, 2025
@iritkatriel
[3.14] pythongh-137288: Fix bug where boolean expressions are not ass…
9f60d4f
…ociated with the correct exception handler (pythonGH-137310).

(cherry picked from commit 1f2026b)

Co-authored-by: Irit Katriel <[email protected]>
@bedevere-app

bedevere-app Bot commented Aug 5, 2025

Copy link
Copy Markdown

GH-137427 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 Aug 5, 2025
@rgommers

rgommers commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

However, the fix will require bumping the PYC magic number in 3.14.0rc2 :( Heads up, @hugovk

I was pointed at this PR with a message saying "a fix for 3.14.0rc2 may require telling projects that already cut a release to redo that". On closer inspection, that doesn't seem to be the case. The ABI doesn't change here, and packages on PyPI shouldn't contain .pyc code (unless some bad legacy build config in a package explicitly includes .pyc code in wheels). And at install time, .pyc files with an older bytecode magic number should be ignored and be regenerated. So there is no serious impact here, right?

iritkatriel and efimov-mikhail 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.

@encukou

encukou commented Aug 11, 2025

Copy link
Copy Markdown
Member

I know that Fedora builds .pycs, installs them as root so users can't update them, and the more locked-down settings generate security alerts when users attempt to overwrite system files.
Not sure how other redistributors are affected, but I assume this is close to the worst case.

hroncok and rgommers 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.

@rgommers

rgommers commented Aug 11, 2025

Copy link
Copy Markdown
Contributor

Ah of course, distros and other deployment methods that install with root/elevated privileges, thanks @encukou. A bit of digging turns up #73700, which seems like it wasn't much fun for affected redistributors.

There hopefully won't be many distros that distribute packages before the final 3.14.0 release; I believe Fedora is fairly exceptional in doing that. Same for sysadmins installing on multi-user systems, that should be rare pre-3.14.0-final.

All reactions

Sorry, something went wrong.

Uh oh!

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

hugovk pushed a commit that referenced this pull request Aug 12, 2025
@iritkatriel @encukou
[3.14] gh-137288: Fix bug where boolean expressions are not associate…
0ccf244
…d with the correct exception handler (GH-137310). (#137427)

Co-authored-by: Irit Katriel <[email protected]>
Co-authored-by: Petr Viktorin <[email protected]>
hroncok pushed a commit to fedora-python/cpython that referenced this pull request Aug 12, 2025
@iritkatriel @encukou @hroncok
00468: pythongh-137288: Fix bug where boolean expressions are not ass…
7a25fb3
…ociated with the correct exception handler (pythonGH-137310). (python#137427)

Co-authored-by: Irit Katriel <[email protected]>
Co-authored-by: Petr Viktorin <[email protected]>
@hugovk

hugovk commented Aug 12, 2025

Copy link
Copy Markdown
Member

FYI We'll do an early rc2 with this and add an rc3 next month:

  • https://discuss.python.org/t/early-3-14-0-rc2-and-extra-rc3/102151
All reactions

Sorry, something went wrong.

Uh oh!

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

Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
@iritkatriel @Agent-Hellboy
pythongh-137288: Fix bug where boolean expressions are not associated…
21afcc3
… with the correct exception handler (python#137310)
kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull request Sep 9, 2025
@iritkatriel @encukou @kumaraditya303
[3.14] pythongh-137288: Fix bug where boolean expressions are not ass…
f3084ea
…ociated with the correct exception handler (pythonGH-137310). (python#137427)

Co-authored-by: Irit Katriel <[email protected]>
Co-authored-by: Petr Viktorin <[email protected]>
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

Uh oh!

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

Assignees

No one assigned

Labels

interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Python implicit boolean conversion in logical operations bypasses try/except on 3.14.0rc1

Uh oh!

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

6 participants

@iritkatriel @encukou @markshannon @rgommers @hugovk @picnixz
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.