diff --git a/AUTHORS b/AUTHORS index 879097622..446eb4bd1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -127,6 +127,7 @@ Edison Gustavo Muenz Edoardo Batini Edson Tadeu M. Manoel Eduardo Schettino +Edward Haigh Eli Boyarski Elizaveta Shashkova Éloi Rivard diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index 40adad062..6c4ecae6e 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -168,7 +168,8 @@ def pytest_runtest_call(item: Item) -> None: del sys.last_type del sys.last_value del sys.last_traceback - del sys.last_exc + if sys.version_info >= (3,12,0): + del sys.last_exc except AttributeError: pass try: @@ -177,7 +178,8 @@ def pytest_runtest_call(item: Item) -> None: # Store trace info to allow postmortem debugging sys.last_type = type(e) sys.last_value = e - sys.last_exc = e + if sys.version_info >= (3,12,0): + sys.last_exc = e assert e.__traceback__ is not None # Skip *this* frame sys.last_traceback = e.__traceback__.tb_next