Castrated traceback in sys.exc_info()

Gabriel Genellina gagsl-py2 at
Sat Mar 20 02:54:58 CET 2010

En Wed, 17 Mar 2010 09:42:06 -0300, Pascal Chambon  
<chambon.pascal at> escribió:

> traceback functions indeed allow the manipulation of exception  
> tracebacks,
> but the root problem is that anyway, since that traceback is incomplete,
> your "traceback.format_exc().splitlines()" will only provide frames for
> callee (downward) functions, not caller (upward) ones, starting from the
> exception catching frame.

Either I don't understand what you mean, or I can't reproduce it:

import logging

def a(): return b()
def b(): return c()
def c(): return d()
def d(): raise ValueError

def main():
   try: a()
   except: logging.exception("An error")



ERROR:root:An error
Traceback (most recent call last):
   File "", line 10, in main
     try: a()
   File "", line 3, in a
     def a(): return b()
   File "", line 4, in b
     def b(): return c()
   File "", line 5, in c
     def c(): return d()
   File "", line 6, in d
     def d(): raise ValueError

Gabriel Genellina

More information about the Python-list mailing list