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
When Flask finds an error handler for a given exception, it caches it in the handler map. This can lead to incorrect behavior for subclasses of the exception.
In this example, we have two exception classes, E1 and E2, and a third exception E that inherits from both. We register error handlers for E2 and Exception. When E is raised, Flask should invoke the E2 error handler as E2 comes before Exception in the MRO of E. But if E1 has been raised in the past, then the Exception error handler will be "cached" as the handler for E1, so that handler will be invoked instead.
The text was updated successfully, but these errors were encountered:
ngaya-ll
changed the title
Flask error handler caching behavior leads to inconsistent behavior
Flask error handler caching leads to inconsistent behavior
May 2, 2017
When Flask finds an error handler for a given exception, it caches it in the handler map. This can lead to incorrect behavior for subclasses of the exception.
Here is some code demonstrating the problem:
In this example, we have two exception classes,
E1
andE2
, and a third exceptionE
that inherits from both. We register error handlers forE2
andException
. WhenE
is raised, Flask should invoke theE2
error handler asE2
comes beforeException
in the MRO ofE
. But ifE1
has been raised in the past, then theException
error handler will be "cached" as the handler forE1
, so that handler will be invoked instead.The text was updated successfully, but these errors were encountered: