1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #16245 -- Included traceback in send_robust()'s response

Exceptions from the (receiver, exception) tuples returned by
``send_robust()`` now have always their traceback attached as their
``__traceback__`` argument.
This commit is contained in:
Unai Zalakain
2013-10-30 12:11:04 +01:00
committed by Tim Graham
parent 79e9da3d1e
commit ebb0279f4a
4 changed files with 15 additions and 2 deletions

View File

@@ -220,7 +220,8 @@ class Signal(object):
If any receiver raises an error (specifically any subclass of
Exception), the error instance is returned as the result for that
receiver.
receiver. The traceback is always attached to the error at
``__traceback__``.
"""
responses = []
if not self.receivers or self.sender_receivers_cache.get(sender) is NO_RECEIVERS:
@@ -232,6 +233,8 @@ class Signal(object):
try:
response = receiver(signal=self, sender=sender, **named)
except Exception as err:
if not hasattr(err, '__traceback__'):
err.__traceback__ = sys.exc_info()[2]
responses.append((receiver, err))
else:
responses.append((receiver, response))