              mod_name, func_name = get_mod_func(lookup_view)
              if func_name != '':
                  lookup_view = getattr(import_module(mod_name), func_name)
                  if not callable(lookup_view):
                      raise AttributeError("'%s.%s' is not a callable." % (mod_name, func_name))
          except (ImportError, AttributeError):
              if not can_fail:
                  raise
          except UnicodeEncodeError:
              pass
      return lookup_view
 
</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  </s> remove         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)))
 </s> add         self._callback = get_callable(self._callback_str)
                    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))
              mod_name, func_name = get_mod_func(lookup_view)
              if func_name != '':
                  lookup_view = getattr(import_module(mod_name), func_name)
                  if not callable(lookup_view):
                    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))
                    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))
              if not can_fail:
                  raise
          except UnicodeEncodeError:
              pass
      return lookup_view
keep keep keep keep 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