You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def expr_match(ob, ed, c=InstanceDict, r=0):
e, md, push, pop = ed
push(c(ob, md))
try:
r = e.eval(md)
finally:
pop()
return r
The return in the finally will swallow any in-flight exception. This means that if r.eval(md) raises any exception (including KeyboardInterrupt), this exception will be swallowed. This is probably not what the author intended.
I agree this should probably be corrected, but in the case of an exception in the try block, I think this raises UnboundLocalError since r hasn't been assigned.
In the expr_match function:
The
return
in the finally will swallow any in-flight exception. This means that ifr.eval(md)
raises any exception (includingKeyboardInterrupt
), this exception will be swallowed. This is probably not what the author intended.See also: https://docs.python.org/3/tutorial/errors.html#defining-clean-up-actions.
It is possible that the intention was to write:
which would return r is there is no exception, but allow the exception to propagate if there is one.
The text was updated successfully, but these errors were encountered: