New submission from STINNER Victor:

In Python 3, an exception contains a traceback. A traceback contains frames 
which contain local variables. Sometimes, the newly raised exception is a local 
variable and so we get a reference cycle: exc -> traceback -> frame -> exc...

In asyncio, it's a real issue because exception objects are kept alive longer 
than an except block. They are stored in Future objects by 
Future.set_exception() (and so Task.set_exception()).

Python 3.5 has a new traceback.TracebackException (see issue #17911) which 
creates a light "view" which can be used to format a traceback and the view 
doesn't contain local variables.

It would be great if we can use it.

The problem is to that Future.result() raises the exception set in 
Future.set_exception(), and we except to get the traceback of the exception.

So it's unclear to me how long we must store the exception.

Maybe we can only store a traceback.TracebackException in release mode and 
store the full traceback object in debug mode? Such change means that enabling 
the debug mode may create reference cycles (compared to the new release mode), 
which can be very suprising and annoying.

----------
messages: 237234
nosy: haypo, rbcollins
priority: normal
severity: normal
status: open
title: asyncio: use the new traceback.TracebackException class
versions: Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23587>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to