Hi, 2014-03-06 16:19 GMT+01:00 Victor Stinner <victor.stin...@gmail.com>: > By the way, here is my test script to try to create a lightweight > traceback object without references to locals: > https://bitbucket.org/haypo/misc/src/tip/python/suppress_locals.py > > It works if there is no chained exception.
I updated my proof-of-concept to support Exception.__context__, Exception.__cause__ and Exception.__suppress_context__: https://bitbucket.org/haypo/misc/src/tip/python/suppress_locals.py It creates a lightweight "view" of an exception only keeping information needed to format a traceback. > The problem is to build something working with the traceback module. I > should maybe write my own formatting function reusing some traceback > functions. I reused as much code as possible of the traceback module. I only reimplemented _iter_chain() and _format_exception_iter(). View classes could be simplified, but it would need to modify more code in the traceback module. What do you think of my approach? Would it be something useful in other applications? If yes, I can maybe work on a a better implementation, and maybe on a PEP, to see how such thing could be integrated in Python stdlib. It can maybe directly be part of the traceback module. I don't know if storing an exception to maybe format it later as a traceback is a common use case. Usually, exceptions are immediatly formatted or dropped, no? Victor _______________________________________________ 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