Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
Assignees
iritkatriel
Labels
3.14bugs and security fixes3.15new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)release-blockertype-bugAn unexpected behavior, bug, or error
@justinjfu

Description

@justinjfu

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:

classFoo:def__bool__(self):raiseNotImplementedError()a=Foo()b=Foo()# Workstry:c=bool(a)except:print("passed c = bool(a)")# Failstry:c=aorbexcept: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", line15, in<module>    c= aor b^^^^^^  File"/Users/justinfu/code/test_bool.py", line3, in__bool__raiseNotImplementedError()NotImplementedError

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

Labels

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

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2026 Movatter.jp