[New-bugs-announce] [issue45058] Undefined behavior for syntax "except AError or BError:" accepted by interpreter

kftse report at bugs.python.org
Tue Aug 31 07:31:30 EDT 2021


New submission from kftse <kftse20031207 at gmail.com>:

Test case:

try:
    raise TypeError()
except TypeError or ValueError:
    print("OK")
try:
    raise ValueError()
except TypeError or ValueError:
    print("OK")

Output:
(Python 3.9.0)
OK
OK
# seem to eventually lead to segmentation fault elsewhere
(Python 3.8.0)
OK
Traceback (most recent call last):
  File "test.py", line 7, in <module>
    raise ValueError()
ValueError


I understand that this code is incorrect syntax for exception.

The awkward behavior is that the interpreter accepted this syntax and the output being correct in some case, or even in both cases, but seem to eventually lead to segmentation fault elsewhere.

----------
components: Interpreter Core
messages: 400710
nosy: kftse20031207
priority: normal
severity: normal
status: open
title: Undefined behavior for syntax "except AError or BError:" accepted by interpreter
type: behavior
versions: Python 3.8, Python 3.9

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


More information about the New-bugs-announce mailing list