[New-bugs-announce] [issue38197] Meaning of tracebacklimit differs between sys.tracebacklimit and traceback module

Carl Friedrich Bolz-Tereick report at bugs.python.org
Tue Sep 17 06:34:55 EDT 2019


New submission from Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>:

The meaning of sys.tracebacklimit seems to be different than the meaning of the various limit parameters in the traceback module. One shows the top n stack frames, the other the bottom n.

Is this intentional, and if yes, is that difference documented somewhere? (it came up because PyPy just uses the traceback module and has no equivalent of PyTraceBack_Print).

See the attached script to understand the problem. The script formats the same exception twice, once with the traceback module, once by the interpreter. I would have expected them to look the same for all limits, but instead:

$ ./python /tmp/x.py 3
limit 3
from traceback module:
Traceback (most recent call last):
  File "/tmp/x.py", line 19, in <module>
    main()
  File "/tmp/x.py", line 16, in main
    x3()
  File "/tmp/x.py", line 14, in x3
    x2()
ZeroDivisionError: division by zero

from interpreter:
Traceback (most recent call last):
  File "/tmp/x.py", line 14, in x3
    x2()
  File "/tmp/x.py", line 12, in x2
    x1()
  File "/tmp/x.py", line 10, in x1
    1 / 0
ZeroDivisionError: division by zero

----------
files: x.py
messages: 352628
nosy: Carl.Friedrich.Bolz
priority: normal
severity: normal
status: open
title: Meaning of tracebacklimit differs between sys.tracebacklimit and traceback module
versions: Python 3.7
Added file: https://bugs.python.org/file48610/x.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38197>
_______________________________________


More information about the New-bugs-announce mailing list