Ticket #13480: django-1.0.2-nice-ImportError.patch
File django-1.0.2-nice-ImportError.patch, 2.9 KB (added by , 15 years ago) |
---|
-
core/handlers/base.py
diff -ur django-1.0.2/core/handlers/base.py django-1.0.2-nice-ImportErrror/core/handlers/base.py
old new 62 62 from django.core import exceptions, urlresolvers 63 63 from django.conf import settings 64 64 65 65 66 # Apply request middleware 66 for middleware_method in self._request_middleware: 67 response = middleware_method(request) 68 if response: 69 return response 67 try: 68 for middleware_method in self._request_middleware: 69 response = middleware_method(request) 70 if response: 71 return response 72 73 # Catch a ViewDoesNotExist error wrapping an ImportError, 74 # or a naked SyntaxError. 75 except (exceptions.ViewDoesNotExist, SyntaxError), e: 76 if isinstance(e, exceptions.ViewDoesNotExist): 77 if len(e.args) < 3 or not isinstance(e.args[1], ImportError): 78 raise 79 else: 80 # Wrapped ImportError, use the packaged exc_info. 81 exc_info = e.args[2] 82 else: # Naked SyntaxErrror, get the exc_info directly. 83 exc_info = sys.exc_info() 84 85 # Get urlconf from request object, if available. Otherwise use default. 86 urlconf = getattr(request, "urlconf", settings.ROOT_URLCONF) 87 88 resolver = urlresolvers.RegexURLResolver(r'^/', urlconf) 89 receivers = signals.got_request_exception.send(sender=self.__class__, request=request) 90 return self.handle_uncaught_exception(request, resolver, exc_info) 70 91 71 92 # Get urlconf from request object, if available. Otherwise use default. 72 93 urlconf = getattr(request, "urlconf", settings.ROOT_URLCONF) -
core/urlresolvers.py
diff -ur django-1.0.2/core/urlresolvers.py django-1.0.2-nice-ImportErrror/core/urlresolvers.py
old new 7 7 (view_function, function_args, function_kwargs) 8 8 """ 9 9 10 import re 10 import re, sys 11 11 12 12 from django.http import Http404 13 13 from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist … … 130 130 self._callback = get_callable(self._callback_str) 131 131 except ImportError, e: 132 132 mod_name, _ = get_mod_func(self._callback_str) 133 raise ViewDoesNotExist , "Could not import %s. Error was: %s" % (mod_name, str(e))133 raise ViewDoesNotExist("Could not import %s. Error was: %s" % (mod_name, str(e)), e, sys.exc_info()) 134 134 except AttributeError, e: 135 135 mod_name, func_name = get_mod_func(self._callback_str) 136 136 raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e))