[New-bugs-announce] [issue45153] Except multiple types of exceptions with OR keyword is not working

Shlomi report at bugs.python.org
Thu Sep 9 10:35:50 EDT 2021


New submission from Shlomi <vgtvgy1 at gmail.com>:

When I want to catch multiple types of exceptions naturally 'OR' keyword is used. But it doesn't work. The interpreter doesn't show any error for the syntax, so developer may think it would work.

Small example:

try:
    myfunc()
except ConnectionResetError or ConnectionAbortedError:
    print("foo")
except Exception as e:
    print("bar")

When myfunc() throws 'ConnectionAbortedError' the interpreter enters "bar" block, and not "foo" block.

----------
components: Interpreter Core
messages: 401486
nosy: ShlomiRex
priority: normal
severity: normal
status: open
title: Except multiple types of exceptions with OR keyword is not working
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45153>
_______________________________________


More information about the New-bugs-announce mailing list