Mark Lawrence <breamore...@yahoo.co.uk>:

> On 30/01/2015 06:16, Marko Rauhamaa wrote:
>> How about:
>>
>> ==============================
>>      try:
>>          do_interesting_stuff()
>>      except ValueError:
>>          try:
>>              log_it()
>>          except:
>>              pass
>>          raise
>> ==============================
>>
>> Surprisingly this variant could raise an unexpected exception:
>>
>> ==============================
>>      try:
>>          do_interesting_stuff()
>>      except ValueError:
>>          try:
>>              log_it()
>>          finally:
>>              raise
>> ==============================
>>
>> A Python bug?
>
> It depends on the Python version that you're running - I think!!!  See
> https://www.python.org/dev/peps/pep-3134/

TL;DR

My Python did do exception chaining, but the problem is the surface
exception changes, which could throw off the whole error recovery.

So I'm thinking I might have found a valid use case for the "diabolical
antipattern."


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to