How to increase the depth of the python traceback?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Milton

    How to increase the depth of the python traceback?

    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

  • Peter Otten

    #2
    Re: How to increase the depth of the python traceback?

    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
    “tracebacklim it” 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.traceback limit
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    AttributeError: 'module' object has no attribute 'tracebacklimit '
    >>sys.traceback limit = 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
    ZeroDivisionErr or: integer division or modulo by zero

    Peter

    Comment

    Working...