Ticket #3349: patch_3349.diff

File patch_3349.diff, 10.4 KB (added by durdinator, 16 years ago)

Updated patch against r7574 of trunk

  • django/conf/__init__.py

     
    99import os
    1010import time     # Needed for Windows
    1111from django.conf import global_settings
     12from django.core.exceptions import wrap_and_raise
    1213
    1314ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE"
    1415
     
    8485        try:
    8586            mod = __import__(self.SETTINGS_MODULE, {}, {}, [''])
    8687        except ImportError, e:
    87             raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
     88            wrap_and_raise(ImportError("Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)))
    8889
    8990        # Settings that should be converted into tuples if they're mistakenly entered
    9091        # as strings.
  • django/core/urlresolvers.py

     
    88"""
    99
    1010from django.http import Http404
    11 from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist
     11from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist, wrap_and_raise
    1212from django.utils.encoding import iri_to_uri, force_unicode, smart_str
    1313from django.utils.functional import memoize
    1414import re
     
    178178            self._callback = get_callable(self._callback_str)
    179179        except ImportError, e:
    180180            mod_name, _ = get_mod_func(self._callback_str)
    181             raise ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, str(e))
     181            wrap_and_raise(ViewDoesNotExist("Could not import %s. Error was: %s" % (mod_name, str(e))))
    182182        except AttributeError, e:
    183183            mod_name, func_name = get_mod_func(self._callback_str)
    184184            raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e))
     
    252252            except Exception, e:
    253253                # Either an invalid urlconf_name, such as "foo.bar.", or some
    254254                # kind of problem during the actual import.
    255                 raise ImproperlyConfigured, "Error while importing URLconf %r: %s" % (self.urlconf_name, e)
     255                wrap_and_raise(ImproperlyConfigured("Error while importing URLconf %r: %s" % (self.urlconf_name, e)))
    256256            return self._urlconf_module
    257257    urlconf_module = property(_get_urlconf_module)
    258258
     
    266266        try:
    267267            return getattr(__import__(mod_name, {}, {}, ['']), func_name), {}
    268268        except (ImportError, AttributeError), e:
    269             raise ViewDoesNotExist, "Tried %s. Error was: %s" % (callback, str(e))
     269            wrap_and_raise(ViewDoesNotExist("Tried %s. Error was: %s" % (callback, str(e))))
    270270
    271271    def resolve404(self):
    272272        return self._resolve_special('404')
  • django/core/handlers/base.py

     
    22
    33from django import http
    44from django.core import signals
     5from django.core.exceptions import wrap_and_raise
    56from django.dispatch import dispatcher
    67
    78class BaseHandler(object):
     
    3334            try:
    3435                mod = __import__(mw_module, {}, {}, [''])
    3536            except ImportError, e:
    36                 raise exceptions.ImproperlyConfigured, 'Error importing middleware %s: "%s"' % (mw_module, e)
     37                wrap_and_raise(exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e)))
    3738            try:
    3839                mw_class = getattr(mod, mw_classname)
    3940            except AttributeError:
  • django/core/exceptions.py

     
    3232    """Some kind of problem with a model field."""
    3333    pass
    3434
     35
     36def wrap_and_raise(new_exception):
     37    """
     38    Call from an except: block to raise a new exception, while keeping
     39    the traceback info from the source exception.
     40   
     41    new_exception is be the Exception (or subclass) instance to raise.
     42    """
     43    import sys
     44    exc_class, exc, tb = sys.exc_info()
     45
     46    if issubclass(exc_class, Exception):
     47        raise new_exception.__class__, new_exception, tb
     48    else:
     49        raise new_exception
  • django/contrib/auth/__init__.py

     
    11import datetime
    2 from django.core.exceptions import ImproperlyConfigured
     2from django.core.exceptions import ImproperlyConfigured, wrap_and_raise
    33
    44SESSION_KEY = '_auth_user_id'
    55BACKEND_SESSION_KEY = '_auth_user_backend'
     
    1111    try:
    1212        mod = __import__(module, {}, {}, [attr])
    1313    except ImportError, e:
    14         raise ImproperlyConfigured, 'Error importing authentication backend %s: "%s"' % (module, e)
     14        wrap_and_raise(ImproperlyConfigured('Error importing authentication backend %s: "%s"' % (module, e)))
    1515    except ValueError, e:
    1616        raise ImproperlyConfigured, 'Error importing authentication backends. Is AUTHENTICATION_BACKENDS a correctly defined list or tuple?'
    1717    try:
  • django/template/__init__.py

     
    5151import re
    5252from inspect import getargspec
    5353from django.conf import settings
     54from django.core.exceptions import wrap_and_raise
    5455from django.template.context import Context, RequestContext, ContextPopException
    5556from django.utils.itercompat import is_iterable
    5657from django.utils.functional import curry, Promise
     
    919920        try:
    920921            mod = __import__(module_name, {}, {}, [''])
    921922        except ImportError, e:
    922             raise InvalidTemplateLibrary("Could not load template library from %s, %s" % (module_name, e))
     923            wrap_and_raise(InvalidTemplateLibrary("Could not load template library from %s, %s" % (module_name, e)))
    923924        try:
    924925            lib = mod.register
    925926            libraries[module_name] = lib
  • django/template/loaders/app_directories.py

     
    66import os
    77
    88from django.conf import settings
    9 from django.core.exceptions import ImproperlyConfigured
     9from django.core.exceptions import ImproperlyConfigured, wrap_and_raise
    1010from django.template import TemplateDoesNotExist
    1111from django.utils._os import safe_join
    1212
     
    2424        else:
    2525            mod = getattr(__import__(m, {}, {}, [a]), a)
    2626    except ImportError, e:
    27         raise ImproperlyConfigured, 'ImportError %s: %s' % (app, e.args[0])
     27        wrap_and_raise(ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0])))
    2828    template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates')
    2929    if os.path.isdir(template_dir):
    3030        app_template_dirs.append(template_dir)
  • django/template/defaulttags.py

     
    1212from django.template import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, SINGLE_BRACE_START, SINGLE_BRACE_END, COMMENT_TAG_START, COMMENT_TAG_END
    1313from django.template import get_library, Library, InvalidTemplateLibrary
    1414from django.conf import settings
     15from django.core.exceptions import wrap_and_raise
    1516from django.utils.encoding import smart_str, smart_unicode
    1617from django.utils.itercompat import groupby
    1718from django.utils.safestring import mark_safe
     
    853854            lib = get_library("django.templatetags.%s" % taglib)
    854855            parser.add_library(lib)
    855856        except InvalidTemplateLibrary, e:
    856             raise TemplateSyntaxError("'%s' is not a valid tag library: %s" %
    857                                       (taglib, e))
     857            wrap_and_raise(TemplateSyntaxError("'%s' is not a valid tag library: %s" %
     858                                      (taglib, e)))
    858859    return LoadNode()
    859860load = register.tag(load)
    860861
  • django/template/context.py

     
    11from django.conf import settings
    2 from django.core.exceptions import ImproperlyConfigured
     2from django.core.exceptions import ImproperlyConfigured, wrap_and_raise
    33
    44_standard_context_processors = None
    55
     
    7777            try:
    7878                mod = __import__(module, {}, {}, [attr])
    7979            except ImportError, e:
    80                 raise ImproperlyConfigured('Error importing request processor module %s: "%s"' % (module, e))
     80                wrap_and_raise(ImproperlyConfigured('Error importing request processor module %s: "%s"' % (module, e)))
    8181            try:
    8282                func = getattr(mod, attr)
    8383            except AttributeError:
  • django/template/loader.py

     
    2020# Python eggs) sets is_usable to False if the "pkg_resources" module isn't
    2121# installed, because pkg_resources is necessary to read eggs.
    2222
    23 from django.core.exceptions import ImproperlyConfigured
     23from django.core.exceptions import ImproperlyConfigured, wrap_and_raise
    2424from django.template import Origin, Template, Context, TemplateDoesNotExist, add_to_builtins
    2525from django.conf import settings
    2626
     
    5353            try:
    5454                mod = __import__(module, globals(), locals(), [attr])
    5555            except ImportError, e:
    56                 raise ImproperlyConfigured, 'Error importing template source loader %s: "%s"' % (module, e)
     56                wrap_and_raise(ImproperlyConfigured('Error importing template source loader %s: "%s"' % (module, e)))
    5757            try:
    5858                func = getattr(mod, attr)
    5959            except AttributeError:
Back to Top