-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Labels
triageNew bug, unverifiedNew bug, unverified
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
Problem description
PyPy 3.8 triggers the newly introduced error message
pybind11/include/pybind11/pytypes.h
Lines 459 to 469 in 59f03ee
if (exc_type_name_norm != m_lazy_error_string) { | |
std::string msg = std::string(called) | |
+ ": MISMATCH of original and normalized " | |
"active exception types: "; | |
msg += "ORIGINAL "; | |
msg += m_lazy_error_string; | |
msg += " REPLACED BY "; | |
msg += exc_type_name_norm; | |
msg += ": " + format_value_and_trace(); | |
pybind11_fail(msg); | |
} |
MISMATCH of original and normalized active exception types: ORIGINAL OSError REPLACED BY FileNotFoundError: [Errno 2] No such file or directory: 'this_file_does_not_exist'
In PyPy, PyErr_NormalizeException
causes the "raw" OSError to be normalized into FileNotFoundError. Which seems fair enough.
It's unclear to me whether PyPy is doing something "naughty" here that violates the expectations set by CPython, or if this new exception handling code is just imposing an expectation that doesn't hold for PyPy. As such I don't know if simply disabling that test is appropriate for PyPy.
CPython does not make the same substitution. There is no error (and the code behaves correctly) with pybind11 2.9.
Reproducible example code
m.def("test_pypy_oserror_normalization", []() {
// We want to do "with suppress(FileNotFoundError): open(f)" in C++
try {
py::module_::import("io").attr("open")("this_file_does_not_exist", "r");
} catch (const py::error_already_set &e) {
// FileNotFoundError
}
});
Metadata
Metadata
Assignees
Labels
triageNew bug, unverifiedNew bug, unverified