From 96c1152eab576354bb1de0f9dea09a0fb21dfda9 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Mon, 19 Aug 2019 16:13:35 +0100 Subject: [PATCH] Make try/catch AttributeError less all-encompassing --- wagtail/utils/deprecation.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/wagtail/utils/deprecation.py b/wagtail/utils/deprecation.py index 5b6033ec1..76811c86f 100644 --- a/wagtail/utils/deprecation.py +++ b/wagtail/utils/deprecation.py @@ -47,17 +47,17 @@ class MovedDefinitionHandler(object): # in the stack trace raise e from None - warnings.warn( - "%s has been moved from %s to %s" % (name, self.real_module.__name__, new_module_name), - category=self.warning_class, stacklevel=2 - ) + warnings.warn( + "%s has been moved from %s to %s" % (name, self.real_module.__name__, new_module_name), + category=self.warning_class, stacklevel=2 + ) - # load the requested definition from the module named in moved_definitions - new_module = import_module(new_module_name) - definition = getattr(new_module, name) + # load the requested definition from the module named in moved_definitions + new_module = import_module(new_module_name) + definition = getattr(new_module, name) - # stash that definition into the current module so that we don't have to - # redo this import next time we access it - setattr(self.real_module, name, definition) + # stash that definition into the current module so that we don't have to + # redo this import next time we access it + setattr(self.real_module, name, definition) - return definition + return definition