Skip to content

Commit

Permalink
FlakyException failure_point_init debugging prints
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf W. Grosse-Kunstleve committed Mar 9, 2023
1 parent d69bb15 commit d38c9da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/pybind11/pytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ struct error_fetch_and_normalize {
"of the original active exception type.");
}
m_lazy_error_string = exc_type_name_orig;
printf("\nLOOOK exc_type_name_orig=%s %s:%d\n", exc_type_name_orig, __FILE__, __LINE__); fflush(stdout);
// PyErr_NormalizeException() may change the exception type if there are cascading
// failures. This can potentially be extremely confusing.
PyErr_NormalizeException(&m_type.ptr(), &m_value.ptr(), &m_trace.ptr());
Expand All @@ -506,6 +507,7 @@ struct error_fetch_and_normalize {
+ " failed to obtain the name "
"of the normalized active exception type.");
}
printf("\nLOOOK exc_type_name_norm=%s %s:%d\n", exc_type_name_norm, __FILE__, __LINE__); fflush(stdout);
#if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x07030a00
// This behavior runs the risk of masking errors in the error handling, but avoids a
// conflict with PyPy, which relies on the normalization here to change OSError to
Expand Down
3 changes: 3 additions & 0 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ def test_error_already_set_message_with_malformed_utf8():
class FlakyException(Exception):
def __init__(self, failure_point):
if failure_point == "failure_point_init":
print("\nLOOOK FlakyException failure_point_init", flush=True)
raise ValueError("triggered_failure_point_init")
self.failure_point = failure_point

Expand Down Expand Up @@ -319,6 +320,8 @@ def test_error_already_set_what_with_happy_exceptions(

@pytest.mark.skipif("env.PYPY", reason="PyErr_NormalizeException Segmentation fault")
def test_flaky_exception_failure_point_init():
tup = m.error_already_set_what(FlakyException, ("failure_point_init",))
print("\nLOOOK tup", tup, flush=True)
with pytest.raises(RuntimeError) as excinfo:
m.error_already_set_what(FlakyException, ("failure_point_init",))
lines = str(excinfo.value).splitlines()
Expand Down

0 comments on commit d38c9da

Please sign in to comment.