Terry J. Reedy added the comment:
"except a or b:" should be same as "except (a or b):" which should be same as
"except a:", which is current behavior in 3.10.0, etc.
--
nosy: +terry.reedy
resolution: -> not a bug
stage: -> resolved
status: open -> closed
Serhiy Storchaka added the comment:
Yes, it is syntactically correct. It can even make sense. But the meaning is
different from "except (AError, BError)". If it looks confusing to you, it is a
work of linters to warn about misleading or suspicions code.
--
kftse added the comment:
Tested 3.9.6 to have same behavior as 3.8.0.
to clarify, I suppose legal merely means syntactically correct, not
effect of "except AError or BError:" === "except (AError, BError)"
right?
--
___
Python tracker
Serhiy Storchaka added the comment:
I get the correct result (a ValueError traceback) in 3.9.6, I get a crash in
3.9.0. It was a bug in 3.9.0 which is now fixed.
The syntax is legal.
--
nosy: +serhiy.storchaka
___
Python tracker
New submission from kftse :
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)