mirror of
https://github.com/django/django.git
synced 2025-03-06 15:32:33 +00:00
Caught all exceptions raised by Engine.get_default().
In addition to ImproperlyConfigured, Engine.get_default() may also raise ImportError or other exceptions. It's better to catch all exceptions in places where the default engine isn't strictly required.
This commit is contained in:
parent
9410d69835
commit
27f9ff459b
@ -177,8 +177,14 @@ class AdminSite(object):
|
|||||||
"setting in order to use the admin application.")
|
"setting in order to use the admin application.")
|
||||||
try:
|
try:
|
||||||
default_template_engine = Engine.get_default()
|
default_template_engine = Engine.get_default()
|
||||||
except ImproperlyConfigured:
|
except Exception:
|
||||||
# Skip the check if the user has a non-trivial TEMPLATES setting
|
# Skip this non-critical check:
|
||||||
|
# 1. if the user has a non-trivial TEMPLATES setting and Django
|
||||||
|
# can't find a default template engine
|
||||||
|
# 2. if anything goes wrong while loading template engines, in
|
||||||
|
# order to avoid raising an exception from a confusing location
|
||||||
|
# Catching ImproperlyConfigured suffices for 1. but 2. requires
|
||||||
|
# catching all exceptions.
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if ('django.contrib.auth.context_processors.auth'
|
if ('django.contrib.auth.context_processors.auth'
|
||||||
|
@ -7,7 +7,6 @@ import sys
|
|||||||
import types
|
import types
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
|
||||||
from django.core.urlresolvers import resolve, Resolver404
|
from django.core.urlresolvers import resolve, Resolver404
|
||||||
from django.http import (HttpResponse, HttpResponseNotFound, HttpRequest,
|
from django.http import (HttpResponse, HttpResponseNotFound, HttpRequest,
|
||||||
build_request_repr)
|
build_request_repr)
|
||||||
@ -282,7 +281,11 @@ class ExceptionReporter(object):
|
|||||||
"""Return a dictionary containing traceback information."""
|
"""Return a dictionary containing traceback information."""
|
||||||
try:
|
try:
|
||||||
default_template_engine = Engine.get_default()
|
default_template_engine = Engine.get_default()
|
||||||
except ImproperlyConfigured:
|
except Exception:
|
||||||
|
# Since the debug view must never crash, catch all exceptions.
|
||||||
|
# If Django can't find a default template engine, get_default()
|
||||||
|
# raises ImproperlyConfigured. If some template engines fail to
|
||||||
|
# load, any exception may be raised.
|
||||||
default_template_engine = None
|
default_template_engine = None
|
||||||
|
|
||||||
# TODO: add support for multiple template engines (#24120).
|
# TODO: add support for multiple template engines (#24120).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user