Why isn't the code in the `else` section of my `try` block being run?
In case else
block raises an exception, it gets ignored, since the interpreter has to execute return
from the function. A demo:
>>> def divide(x, y):... try:... result = x / y... except ZeroDivisionError:... print "division by zero!"... else:... print "result is", result... print 1/0... finally:... return 1... >>> divide(2,1)result is 21
1/0
doesn't cause any traceback.
I think errors
is not defined.
len(errors)
would raise an exception, but not prevent the execution of the finally
block, hence still returning some data, without having defined result_response['success']