[Python-Dev] Compilation of "except FooExc as var" adds useless store
On Sun, 6 Jan 2019 17:26:09 +0200
Serhiy Storchaka <storchaka at gmail.com> wrote:
> Because there is a reason for such code.
> See issue1631942  and the thread with the subject "self-contained
> exceptions" on the Python-3000 mailing list  for the rationale.
> In short, the code
> except Exception as e:
> del e
> should work.
(Dark) Magic. Live and learn/think. So, we allow user to delete a var,
then recreate it, just to delete again. Thanks for both the hint and
I can only agree with what Chris wrote in the initial reply - it
would nice if there would be an explanation of these tricks somewhere.
I myself wouldn't know a better place than the source code comments.
Well, at least I did trace it to the source code where it's handled.
> I do not see a problem with storing None before deleting a variable.
> This is not a performance critical code, because it is executed only
> when an exception was raised and caught.