Skip to content
Myr

Remove busy-work. (#2072)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

It is entirely sufficient to walk the MRO of the exception class, no need to check for classes re-appearing later on, no need to add the MRO of any superclass. * Python refuses point-blank to create a class with a circular MRO. * All classes in a superclass MRO *already* appear in the MRO of the derived type. Re-adding the contents of a superclass MRO is doing double work.

authored by Martijn Pieters · committed by David Lord · parent 6478d7b · Browse files · 1 file+1 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+1 added−13 removed

  • other:+1 added−13 removed

1 file+1 added−13 removed

modified:flask/app.py+1 added-13 removed
12 unmodified lines
13from threading import Lock14from datetime import timedelta15from itertools import chain16from functools import update_wrapper17from collections import deque1718from werkzeug.datastructures import ImmutableDict19from werkzeug.routing import Map, Rule, RequestRedirect, BuildError20from werkzeug.exceptions import HTTPException, InternalServerError, \
1414 unmodified lines
14351436 def find_handler(handler_map):1437 if not handler_map:1438 return1440 queue = deque(exc_class.__mro__)1441 # Protect from geniuses who might create circular references in1442 # __mro__1443 done = set()14441445 while queue:1446 cls = queue.popleft()1447 if cls in done:1448 continue1449 done.add(cls)1439 for cls in exc_class.__mro__:1440 handler = handler_map.get(cls)1441 if handler is not None:1442 # cache for next time exc_class is raised1443 handler_map[exc_class] = handler1444 return handler14451456 queue.extend(cls.__mro__)14571446 # try blueprint handlers1447 handler = find_handler(self.error_handler_spec1448 .get(request.blueprint, {})1449 .get(code))
551 unmodified lines