Code

Ticket #6379: no_exception_hiding.diff

File no_exception_hiding.diff, 1.0 KB (added by Bastian Kleineidam <calvin@…>, 6 years ago)
Line 
1Index: django/core/urlresolvers.py
2===================================================================
3--- django/core/urlresolvers.py (Revision 7020)
4+++ django/core/urlresolvers.py (Arbeitskopie)
5@@ -178,9 +178,15 @@
6             self._callback = get_callable(self._callback_str)
7         except ImportError, e:
8             mod_name, _ = get_mod_func(self._callback_str)
9-            raise ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, str(e))
10+            msg = str(e)
11+            if not msg.endswith(mod_name):
12+                raise
13+            raise ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, msg)
14         except AttributeError, e:
15             mod_name, func_name = get_mod_func(self._callback_str)
16+            msg = str(e)
17+            if not (mod_name in msg and func_name in msg):
18+                raise
19             raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e))
20         return self._callback
21     callback = property(_get_callback)