Yes I agree with the re-raise analysis, but see no real difference in break/continue/return inside an except block or a finally I really would prefer the same behaviour. I can always use sys.exc_info to discover information about unhandled exceptions although that is a bit clunky.
I don’t find anything special about the exception suppression; after all except blocks can choose to suppress an exception by just not re-raising.
import sys
for i in range(3):
try:
raise (ValueError if i==2 else RuntimeError)(i)
except ValueError:
print('raised')
continue
finally:
print(f'finalised {sys.exc_info()==(None,None,None)}')
continue
else:
print('else')
I’m sure there are many other gotchas in python which are not regarded as syntax errors mutable default arguments are often used wrongly (by me).
I think foot-shooting should be allowed ![]()