PR #3384 introduced code that resets sys.last_traceback and friends by assigning None to them:
|
sys.last_type, sys.last_value, sys.last_traceback = (None, None, None) |
The normal CPython behaviour here is that once the exception has been cleared, the attributes are deleted rather than set to None. Could I suggest updating this line of code to delete the attributes?
For context: the Nones caused test failures in another project when we attempted to switch from unittest discover to pytest as our test runner; we had a test for some complex code that was messing with various sys attributes including the sys.last_* attributes, and the test verified that those attributes were unchanged by the code under test.
PR #3384 introduced code that resets
sys.last_tracebackand friends by assigningNoneto them:pytest/src/_pytest/runner.py
Line 124 in 7e10c81
The normal CPython behaviour here is that once the exception has been cleared, the attributes are
deleted rather than set toNone. Could I suggest updating this line of code to delete the attributes?For context: the
Nones caused test failures in another project when we attempted to switch fromunittest discovertopytestas our test runner; we had a test for some complex code that was messing with varioussysattributes including thesys.last_*attributes, and the test verified that those attributes were unchanged by the code under test.