STINNER Victor added the comment: The test was introduced by the change 73afda5a4e4c of the issue ##17911 in Python 3.6: --- changeset: 94850:73afda5a4e4c parent: 94848:fc0201ccbcd4 user: Robert Collins <rbtcoll...@hp.com> date: Thu Mar 05 12:07:57 2015 +1300 files: Doc/library/linecache.rst Doc/library/traceback.rst Lib/linecache.py Lib/test/test_linecache.py Lib/test/test_traceback.py L description: Issue #17911: traceback module overhaul
Provide a way to seed the linecache for a PEP-302 module without actually loading the code. Provide a new object API for traceback, including the ability to not lookup lines at all until the traceback is actually rendered, without any trace of the original objects being kept alive. --- I would prefer that Robert reviews the change to make sure that it's correct. It looks like running Lib/test/test_traceback.py creates a less deeper callback, the callback has 10 frames whereas the test ensures that we have *more* than 10 frames. Output of traceback.print_traceback(): --- .......................................... File "Lib/test/test_traceback.py", line 923, in <module> unittest.main() File "/home/haypo/prog/python/default/Lib/unittest/main.py", line 94, in __init__ self.runTests() File "/home/haypo/prog/python/default/Lib/unittest/main.py", line 255, in runTests self.result = testRunner.run(self.test) File "/home/haypo/prog/python/default/Lib/unittest/runner.py", line 176, in run test(result) File "/home/haypo/prog/python/default/Lib/unittest/suite.py", line 84, in __call__ return self.run(*args, **kwds) File "/home/haypo/prog/python/default/Lib/unittest/suite.py", line 122, in run test(result) File "/home/haypo/prog/python/default/Lib/unittest/suite.py", line 84, in __call__ return self.run(*args, **kwds) File "/home/haypo/prog/python/default/Lib/unittest/suite.py", line 122, in run test(result) File "/home/haypo/prog/python/default/Lib/unittest/case.py", line 648, in __call__ return self.run(*args, **kwds) File "/home/haypo/prog/python/default/Lib/unittest/case.py", line 600, in run testMethod() File "Lib/test/test_traceback.py", line 683, in test_walk_stack traceback.print_stack() --- I count 11 frames, but I guess that we should exclude the latest one. If I understood correctly, we should modify the unit test to check that we have at least *9* frames instead of 10. I don't think that it's ok to test the *exact* number of frames, because it's highly dependent of the implementation of the unittest module. Tomorrow, the unittest module may be modified to add new calls in the call stacks... or maybe even remove some calls, but IMHO this is less likely. --- This issue remembers me a very complex issue related to sys.setrecursionlimit(), issue #25274. I factored deeply Lib/test/regrtest.py (which even became a "library", Lib/test/libregrtest/), and with this change, I added more calls to the call stack. As a consequence, I triggered a new complex bug in how Python handles RecursionError. At the end, I modified sys.setrecursionlimit() to raise directly a RecursionError if the new limit is too low *depending on the depth of the current call stack* ;-) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25783> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com