This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author iritkatriel
Recipients Carl.Friedrich.Bolz, iritkatriel
Date 2020-11-04.19:41:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1604518909.41.0.449614283681.issue38197@roundup.psfhosted.org>
In-reply-to
Content
If you change your script to do
sys.tracebacklimit = abs(limit)
and run it with arg -3, then you get the output you expect:

C:\Users\User\src\cpython>python.bat x.py -3
Running Release|Win32 interpreter...
limit -3
from traceback module:
Traceback (most recent call last):
  File "C:\Users\User\src\cpython\x.py", line 14, in x3
    x2()
  File "C:\Users\User\src\cpython\x.py", line 12, in x2
    x1()
  File "C:\Users\User\src\cpython\x.py", line 10, in x1
    1 / 0
ZeroDivisionError: division by zero

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


The documentation for traceback mentions the possibility of using negative limits and their meaning:

Print up to limit stack trace entries from traceback object tb (starting from the caller’s frame) if limit is positive. Otherwise, print the last abs(limit) entries. 

https://docs.python.org/3/library/traceback.html#traceback.print_tb
History
Date User Action Args
2020-11-04 19:41:49iritkatrielsetrecipients: + iritkatriel, Carl.Friedrich.Bolz
2020-11-04 19:41:49iritkatrielsetmessageid: <1604518909.41.0.449614283681.issue38197@roundup.psfhosted.org>
2020-11-04 19:41:49iritkatriellinkissue38197 messages
2020-11-04 19:41:49iritkatrielcreate