      @property
      def callback(self):
          if self._callback is not None:
              return self._callback
          try:
              self._callback = get_callable(self._callback_str)
          except ImportError, e:
              mod_name, _ = get_mod_func(self._callback_str)
              raise ViewDoesNotExist("Could not import %s. Error was: %s" % (mod_name, str(e)))
          except AttributeError, e:
              mod_name, func_name = get_mod_func(self._callback_str)
              raise ViewDoesNotExist("Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e)))
          return self._callback
  
  class RegexURLResolver(LocaleRegexProvider):
      def __init__(self, regex, urlconf_name, default_kwargs=None, app_name=None, namespace=None):
          LocaleRegexProvider.__init__(self, regex)
 
</s> remove         try:
            return get_callable(callback), {}
        except (ImportError, AttributeError), e:
            raise ViewDoesNotExist("Tried %s. Error was: %s" % (callback, str(e)))
 </s> add         return get_callable(callback), {} </s> remove                     raise AttributeError("'%s.%s' is not a callable." % (mod_name, func_name))
        except (ImportError, AttributeError):
 </s> add                     raise ViewDoesNotExist(
                        "Could not import %s.%s. View is not callable."
                    % (mod_name, func_name))
        except AttributeError:
            if not can_fail:
                raise ViewDoesNotExist(
                    "Could not import %s. View does not exist in module %s."
                    % (lookup_view, mod_name))
        except ImportError:
            ownermod, submod = get_mod_func(mod_name)
            if (not can_fail and submod != '' and
                    not module_has_submodule(import_module(ownermod), submod)):
                raise ViewDoesNotExist(
                    "Could not import %s. Owning module %s does not exist."
                    % (lookup_view, mod_name)) </s> remove             # Bail early for non-ASCII strings (they can't be functions).
            lookup_view = lookup_view.encode('ascii')
            mod_name, func_name = get_mod_func(lookup_view)
 </s> add  </s> remove         except UnicodeEncodeError:
            pass
 </s> add 
        self._callback = get_callable(self._callback_str)
      @property
      def callback(self):
          if self._callback is not None:
              return self._callback
        self._callback = get_callable(self._callback_str)
        self._callback = get_callable(self._callback_str)
        self._callback = get_callable(self._callback_str)
        self._callback = get_callable(self._callback_str)
        self._callback = get_callable(self._callback_str)
        self._callback = get_callable(self._callback_str)
        self._callback = get_callable(self._callback_str)
        self._callback = get_callable(self._callback_str)
          return self._callback
  
  class RegexURLResolver(LocaleRegexProvider):
      def __init__(self, regex, urlconf_name, default_kwargs=None, app_name=None, namespace=None):
          LocaleRegexProvider.__init__(self, regex)
keep keep keep keep replace replace replace replace replace replace replace replace keep keep keep keep keep
 Fixed #10802 -- Handle ImportErrors and AttributeErrors gracefully when raised by the URL resolver system during startup. Many thanks, IonelMaries and Bas Peschier.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16420 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
django/core/urlresolvers.py