Irit Katriel <iritkatr...@yahoo.com> added the comment: 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 ---------- nosy: +iritkatriel versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38197> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com