Name
exc_info
Synopsis
exc_info( )
If the current thread is handling an exception,
exc_info returns a tuple whose three items are the
class, object, and traceback for the exception. If the current thread
is not handling any exception, exc_info returns
(None,None,None). A traceback object indirectly
holds references to all variables of all functions that propagated
the exception. Thus, if you hold a reference to the traceback object
(for example, indirectly, by binding a variable to the whole tuple
that exc_info returns), Python has to retain in
memory data that might otherwise be garbage-collected. So you should
make sure that any binding to the traceback object is of short
duration. To ensure that the binding gets removed, you can use a
try/finally statement
(discussed in Chapter 6).
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access