Fixed #33433 -- Avoided unnecessary resolve() calls in technical_404_response().

Thanks Keryn Knight for the initial patch.
This commit is contained in:
Hrushikesh Vaidya 2022-01-12 12:23:09 +05:30 committed by Mariusz Felisiak
parent 75c1127eef
commit 18a15bbc9c
1 changed files with 7 additions and 5 deletions

View File

@ -537,11 +537,13 @@ def technical_404_response(request, exception):
urlconf = urlconf.__name__ urlconf = urlconf.__name__
caller = '' caller = ''
try: resolver_match = request.resolver_match
resolver_match = resolve(request.path) if resolver_match is None:
except Http404: try:
pass resolver_match = resolve(request.path)
else: except Http404:
pass
if resolver_match is not None:
obj = resolver_match.func obj = resolver_match.func
if hasattr(obj, 'view_class'): if hasattr(obj, 'view_class'):