The following code has been tested with (cpython) Python 3.6.4 and Python 2.7.14.
When the explicit statement is raise ValueErrorcommented out, the following code runs and prints "Hello!" and then "Peace!" although the symbol ValueErrodoes not exist.
Uncomment the statement raise ValueErrorand the ValueError will be raised and the expected one NameError: name 'ValueErro' is not definedwill 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