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 — Python implicit boolean conversion in logical operations bypasses try/except on 3.14.0rc1 · Issue #137288 · python/cpython

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

New issue
Copy link
New issue
Copy link
Closed
#137310
Closed
Python implicit boolean conversion in logical operations bypasses try/except on 3.14.0rc1#137288
#137310
Copy link
Assignees
iritkatriel
Labels
3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)release-blockertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@justinjfu
justinjfu
opened on Jul 31, 2025
Issue body actions

Bug report

Bug description:

Throwing an exception during an implicit cast to a boolean as part of a logical operation (or, and) bypasses surrounding try/except statements.

The following example works on Python 3.12.3 but fails on Python 3.14.0rc1:

Example:

class Foo:
  def __bool__(self):
    raise NotImplementedError()

a = Foo()
b = Foo()

# Works
try:
  c = bool(a)
except:
  print("passed c = bool(a)")

# Fails
try:
  c = a or b
except:
  print("passed c = a or b")

Output on Python 3.12.3 (expected behavior):

passed c = bool(a)
passed c = a or b

Output on Python 3.14.0rc1:

passed c = bool(a)
Traceback (most recent call last):
  File "/Users/justinfu/code/test_bool.py", line 15, in <module>
    c = a or b
        ^^^^^^
  File "/Users/justinfu/code/test_bool.py", line 3, in __bool__
    raise NotImplementedError()
NotImplementedError

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Linked PRs

  • gh-137288: Fix bug where boolean expressions are not associated with the correct exception handler #137310
  • [3.14] gh-137288: Fix bug where boolean expressions are not associated with the correct exception handler (GH-137310). #137427
  • gh-137288: Fix Python version in magic number comment #137664
  • gh-137288: Update 3.14 magic numbers #137665
  • [3.14] gh-137288: Update version in magic number log (GH-137665) #137667

Activity

Next
  1. justinjfu
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jul 31, 2025
  2. ethanfurman commented on Jul 31, 2025

    @ethanfurman
    ethanfurman
    on Jul 31, 2025
    Member
    More actions

    Confirmed on LinuxMint.

  3. brianschubert commented on Jul 31, 2025

    @brianschubert
    brianschubert
    on Jul 31, 2025
    Contributor
    More actions

    Bisects to 78aeb38 (#124394), cc @iritkatriel

    Reacted by Irit Katriel
  4. brianschubert
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    3.14bugs and security fixesbugs and security fixes
    3.15bugs and security fixesbugs and security fixes
    on Jul 31, 2025
  5. JelleZijlstra
    added
    release-blocker
    on Aug 1, 2025
  6. ezio-melotti
    added this to Release and Deferred blockers 🚫on Aug 1, 2025
  7. github-project-automation
    moved this to Todo in Release and Deferred blockers 🚫on Aug 1, 2025
  8. iritkatriel
    self-assigned this
    on Aug 1, 2025
  9. iritkatriel
    added a commit that references this issue on Aug 1, 2025

    pythongh-137288: Fix bug where boolean expressions are not associated…

    71b151d
  10. iritkatriel commented on Aug 1, 2025

    @iritkatriel
    iritkatriel
    on Aug 1, 2025
    Member
    More actions

    Thank you @justinjfu for reporting and @brianschubert for bisecting. This is a nice little bug.

    Fix in #137310

  11. iritkatriel
    added a commit that references this issue on Aug 1, 2025

    Merge branch 'main' into pythongh-137288

    58dfd02
  12. justinjfu commented on Aug 1, 2025

    @justinjfu
    justinjfu
    on Aug 1, 2025
    Author
    More actions

    Thank you for the quick fix!

  13. iritkatriel
    added a commit that references this issue on Aug 3, 2025

    Merge branch 'main' into pythongh-137288

    c9ae7ef
  14. 7 remaining items

  15. hroncok
    added 7 commits that reference this issue on Aug 12, 2025

    00468: pythongh-137288: Fix bug where boolean expressions are not ass…

    64aae21

    00468: pythongh-137288: Fix bug where boolean expressions are not ass…

    8c018e1

    pythongh-137288: Fix Python version in magic number comment

    f344256

    00468: pythongh-137288: Fix bug where boolean expressions are not ass…

    7df7306

    00468: pythongh-137288: Fix bug where boolean expressions are not ass…

    84d6330

    00468: pythongh-137288: Fix bug where boolean expressions are not ass…

    dfac92a

    00468: pythongh-137288: Fix bug where boolean expressions are not ass…

    7e91859
  16. encukou
    added 2 commits that reference this issue on Aug 12, 2025

    gh-137288: Update 3.14 magic numbers (GH-137665)

    715647a

    [3.14] pythongh-137288: Update 3.14 magic numbers (pythonGH-137665)

    72a639d
  17. hugovk
    added a commit that references this issue on Aug 12, 2025

    [3.14] gh-137288: Update version in magic number log (GH-137665) (#13…

    946b226
  18. maurycy
    added a commit that references this issue on Aug 12, 2025

    Merge branch 'main' into csv-sniffer-counter-set

    11c891d
  19. Agent-Hellboy
    added 2 commits that reference this issue on Aug 19, 2025

    pythongh-137288: Fix bug where boolean expressions are not associated…

    21afcc3

    pythongh-137288: Update 3.14 magic numbers (pythonGH-137665)

    8625362
  20. kumaraditya303
    added 2 commits that reference this issue on Sep 9, 2025

    [3.14] pythongh-137288: Fix bug where boolean expressions are not ass…

    f3084ea

    [3.14] pythongh-137288: Update version in magic number log (pythonGH-…

    49d5ed0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @iritkatriel
    iritkatriel

Labels

3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)release-blockertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

  • Release and Deferred blockers 🚫
    Status
    Done
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

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.