From a492ccf0bc3da0b99c27b44e491ec3d6aabd5d3f Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Thu, 15 Oct 2020 12:51:50 +0200 Subject: [PATCH] Refs #31672 -- Simplified ExceptionReporter.get_traceback_frames(). --- django/views/debug.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/django/views/debug.py b/django/views/debug.py index b555610d4a..47c91cc943 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -427,12 +427,13 @@ class ExceptionReporter: # In case there's just one exception, take the traceback from self.tb exc_value = exceptions.pop() tb = self.tb if not exceptions else exc_value.__traceback__ - frames.extend(self.get_exception_traceback_frames(exc_value, tb)) - while exceptions: - exc_value = exceptions.pop() - frames.extend( - self.get_exception_traceback_frames(exc_value, exc_value.__traceback__), - ) + while True: + frames.extend(self.get_exception_traceback_frames(exc_value, tb)) + try: + exc_value = exceptions.pop() + except IndexError: + break + tb = exc_value.__traceback__ return frames def get_exception_traceback_frames(self, exc_value, tb):