The following code has been tested with (cpython) Python 3.6.4 and Python 2.7.14.
When the explicit statement is raise ValueError
commented out, the following code runs and prints "Hello!" and then "Peace!" although the symbol ValueErro
does not exist.
Uncomment the statement raise ValueError
and the ValueError will be raised and the expected one NameError: name 'ValueErro' is not defined
will be raised.
try:
print("Hello!")
except ValueErro:
print("Error!")
finally:
print("World!")
I expected that a NameError would display well before processing the exception block at runtime.
Is there any other syntax that checks names / characters more aggressively during a parsing session?
Is this an implementation error?
Thanks for reading!
source
share