New submission from Anthony Sottile <asott...@umich.edu>:
This is breaking pytest for failed assertions: https://github.com/pytest-dev/pytest/pull/8227 It also breaks the traceback in the output below Here's a minimal example: ```python class Boom: def __enter__(self): return self def __exit__(self, *_): raise AssertionError('boom!') def main() -> int: with Boom(): raise AssertionError('hi') if __name__ == '__main__': exit(main()) ``` On python3.9 you get this: ``` Traceback (most recent call last): File "/home/asottile/workspace/cpython/t.py", line 10, in main raise AssertionError('hi') AssertionError: hi During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/asottile/workspace/cpython/t.py", line 14, in <module> exit(main()) File "/home/asottile/workspace/cpython/t.py", line 10, in main raise AssertionError('hi') File "/home/asottile/workspace/cpython/t.py", line 5, in __exit__ raise AssertionError('boom!') AssertionError: boom! ``` output in python3.10: ``` Traceback (most recent call last): File "/home/asottile/workspace/cpython/t.py", line 10, in main raise AssertionError('hi') AssertionError: hi During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/asottile/workspace/cpython/t.py", line 14, in <module> exit(main()) File "/home/asottile/workspace/cpython/t.py", line -1, in main File "/home/asottile/workspace/cpython/t.py", line 5, in __exit__ raise AssertionError('boom!') AssertionError: boom! ``` Notice the second to last frame is now missing and invalid (line -1) I bisected this and found this is the culprit: https://github.com/python/cpython/commit/3bd6035b6baf1a7d51b7cc2c6bb2c81886236b67 https://github.com/python/cpython/pull/24202 ``` 3bd6035b6baf1a7d51b7cc2c6bb2c81886236b67 is the first bad commit commit 3bd6035b6baf1a7d51b7cc2c6bb2c81886236b67 Author: Mark Shannon <m...@hotpy.org> Date: Wed Jan 13 12:05:43 2021 +0000 bpo-42908: Mark cleanup code at end of try-except and with artificial (#24202) * Mark bytecodes at end of try-except as artificial. * Make sure that the CFG is consistent throughout optimiization. * Extend line-number propagation logic so that implicit returns after 'try-except' or 'with' have the correct line numbers. * Update importlib Lib/test/test_dis.py | 2 +- Lib/test/test_sys_settrace.py | 40 + Python/compile.c | 135 +- Python/importlib.h | 3153 ++++++++++++++--------------- Python/importlib_external.h | 4489 ++++++++++++++++++++--------------------- Python/importlib_zipimport.h | 1013 +++++----- 6 files changed, 4473 insertions(+), 4359 deletions(-) bisect run success ``` which appears to be due to bpo-42908 ---------- messages: 391795 nosy: Anthony Sottile, Mark.Shannon, pablogsal priority: normal severity: normal status: open title: Regression in python3.10 with traceback frame having lineno of -1 versions: Python 3.10, Python 3.11 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43933> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com