Skip to content
Myr

added caching

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

authored by Phil Schaf · committed by Phil Schaf · parent fd8e6b2 · Browse files · 1 file+5 added−6 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+5 added−6 removed

  • other:+5 added−6 removed

1 file+5 added−6 removed

modified:flask/app.py+5 added-6 removed
1077 unmodified lines
1078 return f1079 return decorator10801081 @staticmethod1082 def _ensure_exc_class(exc_class_or_code):1082 def _get_exc_class_and_code(exc_class_or_code):1083 """ensure that we register only exceptions as handler keys"""1084 if isinstance(exc_class_or_code, integer_types):1085 exc_class = default_exceptions[exc_class_or_code]1086 elif isinstance(exc_class_or_code, type):1087 exc_class = exc_class_or_code1086 else:1089 exc_class = type(exc_class_or_code)1087 exc_class = exc_class_or_code1088 1089 assert issubclass(exc_class, Exception)1090 1091 if issubclass(exc_class, HTTPException):
69 unmodified lines
1161 'Tried to register a handler for an exception instance {0!r}. '1162 'Handlers can only be registered for exception classes or HTTP error codes.'1163 .format(code_or_exception))1164 1167 exc_class, code = self._ensure_exc_class(code_or_exception)1165 exc_class, code = self._get_exc_class_and_code(code_or_exception)1166 1167 handlers = self.error_handler_spec.setdefault(key, {}).setdefault(code, {})1168 handlers[exc_class] = f1169
239 unmodified lines
1409 def _find_error_handler(self, e):1410 """Finds a registered error handler for the request’s blueprint.1411 If neither blueprint nor App has a suitable handler registered, returns None1412 """1415 exc_class, code = self._ensure_exc_class(e)1413 exc_class, code = self._get_exc_class_and_code(type(e))1414 1415 def find_superclass(d):1416 if not d:1417 return None
1 unmodified line
1419 if superclass is BaseException:1420 return None1421 handler = d.get(superclass)1422 if handler is not None:1423 d[exc_class] = handler # cache for next time exc_class is raised1424 return handler1425 return None1426 1427 # try blueprint handlers
538 unmodified lines