New submission from Irit Katriel <iritkatr...@gmail.com>:
In C code, there is a check in print_exception that the value passed in is of type exception, and it raises TypeError otherwise. This check is not covered by tests, and indeed it is hard to reach it with tests because the _testcapi module has this check as well, which blocks it before the interpreter's check is reached. In traceback.py, there is no such check so this happens: >>> traceback.print_exception(12) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/iritkatriel/src/cpython-654/Lib/traceback.py", line 121, in print_exception value, tb = _parse_value_tb(exc, value, tb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/iritkatriel/src/cpython-654/Lib/traceback.py", line 102, in _parse_value_tb raise TypeError(f"Expected exception, got {exc}") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: Expected exception, got 12 ---------- components: Interpreter Core, Library (Lib) messages: 405048 nosy: iritkatriel priority: normal severity: normal status: open title: Missing test for type of error when printing traceback for non-exception type: behavior versions: Python 3.11 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45615> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com