By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,994 Members | 1,166 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,994 IT Pros & Developers. It's quick & easy.

How to increase the depth of the python traceback?

P: n/a
How to increase the depth of the python traceback?

I have some code that gets an exception deep in the python logging
module and the traceback produced does not go back far enough to show
my own code. How can the traceback limit be controlled in Python 2.5.

The docs indicate that there is an attribute in the sys module
“tracebacklimit” that defaults to 1000 (affectively no limit). I
cannot find this attribute in the sys module of Python2.5

Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Milton wrote:
How to increase the depth of the python traceback?

I have some code that gets an exception deep in the python logging
module and the traceback produced does not go back far enough to show
my own code. How can the traceback limit be controlled in Python 2.5.

The docs indicate that there is an attribute in the sys module
“tracebacklimit” that defaults to 1000 (affectively no limit). I
cannot find this attribute in the sys module of Python2.5
Just set it yourself:
>>import sys
sys.tracebacklimit
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'tracebacklimit'
>>sys.tracebacklimit = 3
def bomb(n):
.... if n: bomb(n-1)
.... else: 1/0
....
>>bomb(100)
Traceback (most recent call last):
File "<stdin>", line 2, in bomb
File "<stdin>", line 2, in bomb
File "<stdin>", line 3, in bomb
ZeroDivisionError: integer division or modulo by zero

Peter
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.