BUG: fix an edge case where ExceptionInfo._stringify_exception could crash pytest.raises

This commit is contained in:
Clément Robert 2024-01-29 09:26:15 +01:00 committed by Ran Benita
parent 797c8be4ca
commit 4f80fea833
2 changed files with 3 additions and 1 deletions

View File

@ -0,0 +1 @@
Fix an edge case where ``ExceptionInfo._stringify_exception`` could crash ``pytest.raises``.

View File

@ -47,6 +47,7 @@ from _pytest._io import TerminalWriter
from _pytest._io.saferepr import safeformat
from _pytest._io.saferepr import saferepr
from _pytest.compat import get_real_func
from _pytest.compat import safe_getattr
from _pytest.deprecated import check_ispytest
from _pytest.pathlib import absolutepath
from _pytest.pathlib import bestrelpath
@ -702,7 +703,7 @@ class ExceptionInfo(Generic[E]):
return "\n".join(
[
str(exc),
*getattr(exc, "__notes__", []),
*safe_getattr(exc, "__notes__", []),
]
)