Skip to content

Commit a92957f

Browse files
committed
BUG: fix an edge case where ExceptionInfo._stringify_exception could crash pytest.raises
1 parent 0ac53cc commit a92957f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/_pytest/_code/code.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from _pytest._io.saferepr import safeformat
4848
from _pytest._io.saferepr import saferepr
4949
from _pytest.compat import get_real_func
50+
from _pytest.compat import safe_getattr
5051
from _pytest.deprecated import check_ispytest
5152
from _pytest.pathlib import absolutepath
5253
from _pytest.pathlib import bestrelpath
@@ -702,7 +703,7 @@ def _stringify_exception(self, exc: BaseException) -> str:
702703
return "\n".join(
703704
[
704705
str(exc),
705-
*getattr(exc, "__notes__", []),
706+
*safe_getattr(exc, "__notes__", []),
706707
]
707708
)
708709

0 commit comments

Comments
 (0)