Message380352
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 |
|
Date |
User |
Action |
Args |
2020-11-04 19:41:49 | iritkatriel | set | recipients:
+ iritkatriel, Carl.Friedrich.Bolz |
2020-11-04 19:41:49 | iritkatriel | set | messageid: <1604518909.41.0.449614283681.issue38197@roundup.psfhosted.org> |
2020-11-04 19:41:49 | iritkatriel | link | issue38197 messages |
2020-11-04 19:41:49 | iritkatriel | create | |
|