New submission from DMITRY KOSHELEV <[email protected]>:
Hello dear developer!
I was playing with try/else/finally block and have found a bug:
Inside of "else" or/and "except" I can do this
1 + print('Why do you print me?') + 1
this would print "Why do you print me?",
in case if I have "finally" block with a "return" statement, no error raises,
if I don't have finally, nothing is printed.
def foo(var):
try:
print("Hello")
# 1 + print("Hello")
except:
1 + print('Why do you print me?') + 1
else:
1 + print('Why do you print me?') + 1
finally:
print("finally block")
return
----------
files: bug_in_try_exceptions.py
messages: 334950
nosy: dmitry_koshelev
priority: normal
severity: normal
status: open
title: 3.6.5 try/except/else/finally block executes code with typos, no errors
type: behavior
versions: Python 3.6
Added file: https://bugs.python.org/file48107/bug_in_try_exceptions.py
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35916>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com