On Wednesday 30 October 2013 11:23:07 unai wrote:
>
> Now, this ticket doubts between two possible solutions. The first of them
> is returning a `(receiver, (type, exception, traceback))` made by
> `(receiver, sys.exc_info())` tuple if `exc_info` is True:
>
> for receiver, (typ, exc, tbk) in my_signal.send_robust(exc_info=True):
> ...
>
> The second solution is to attach the traceback to the exception, a la
> Python 3, at its `__traceback__` attribute.
>
> The two solutions are backwards compatible. Personally, I prefer the second
> one because it's the way to go on Python 3, it doesn't add extra
> parameters for maintaining backwards compatibility and doesn't return a
> messy list of tuple of tuples.
>
> But there's already a patch with tests from two years ago implementing
> solution #1. So what do you think? Do I try to recover the patch with the
> first solution or do I go with the second one?
>
I wouldn't go telling you to do more work than you think is necessary, but if
you're willing to do eithr, I'd prefer to see the second solution in Django;
for all the reasons you gave, plus it is "more backward compatible": Assume I
have some code doing
for receiver, response in my_signal.send_robust(sender):
if isinstance(response, Exception):
my_error_signal.send_robust(sender, exc=response)
With the second solution, I only need to fix the receivers of the error signal
to enjoy the benefits; With the first, I'll need to fix both the receivers and
the signal-sending code, which may be out of my control.
Shai.