On Tue, Jun 13, 2017 at 2:26 AM, Nathaniel Smith <n...@pobox.com> wrote: > On Mon, Jun 12, 2017 at 6:29 AM, Stefan Ring <stefan...@gmail.com> wrote: >> >> > Yury in the comment for PR 2108 [1] suggested more complicated code: >> > >> > do_something() >> > try: >> > do_something_other() >> > except BaseException as ex: >> > try: >> > undo_something() >> > finally: >> > raise ex >> >> And this is still bad, because it loses the back trace. The way we do it is: >> >> do_something() >> try: >> do_something_other() >> except BaseException as ex: >> tb = sys.exc_info()[2] >> try: >> undo_something() >> finally: >> raise ex, None, tb > > Are you testing on python 2? On Python 3 just plain 'raise ex' seems > to give a sensible traceback for me...
Yes, on Python 2. Interesting to know that this has changed in Python 3. I'll check this out immediately. _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com