yinon...@gmail.com wrote:
On Dec 14, 8:07 pm, Brian Allen Vanderburg II
<brianvanderbu...@aim.com> wrote:
Hi,

The interface of extract_tb is:
traceback.extract_tb(tb, limit=None)
try to play with the 'limit' argument

Good luck,
   Yinon
--
http://mail.python.org/mailman/listinfo/python-list
I have, but the limit argument shows the first items and not the last items (where the exception occurred):

def a():
   b()

def b():
   c()

def c():
   d()

def d():
   open('/path/to/fake/file')

try:
   a():
except:
   print traceback.format_exc(limit=2)

try:
   a():
except:
   print format_partial_exc(limit=2)



Prints something like this


Traceback (most recent call last):
 File "b.py", line 52, in ?
   a()
 File "b.py", line 19, in a
   b()
IOError: [Errno 2] No such file or directory: '/path/to/fake/file'

Traceback (most recent call last):
 File "b.py", line 25, in c
   d()
 File "b.py", line 29, in d
   handle=open('/path/to/fake/file', 'rt')
IOError: [Errno 2] No such file or directory: '/path/to/fake/file'


The second one (using format_partial_exc) prints the last two items of the traceback instead of the first, showing the error is line 29 in function d, the first one limits the traceback but gives no indication of where the error occurred.


Brian A. Vanderburg II
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to