Show ODR VIOLATION DETECTED message only if `PYBIND11_DETAIL_TYPE_CASTER_ODR_GUARD_IMPL_DEBUG` is defined, to not clutter the test_gil_scoped.py output with many of these messages when `multiprocessing.set_start_method("forkserver")` is used.

This commit is contained in:
Ralf W. Grosse-Kunstleve 2022-12-02 05:41:49 -08:00
parent 13eb5eafd5
commit 33fb7a6bd8
1 changed files with 2 additions and 0 deletions

View File

@ -82,8 +82,10 @@ inline void type_caster_odr_guard_impl(const std::type_info &intrinsic_type_info
+ reg_iter->second + "\", SourceLocation2=\"" + source_file_line_from_sloc
+ "\"");
if (throw_disabled) {
# if defined(PYBIND11_DETAIL_TYPE_CASTER_ODR_GUARD_IMPL_DEBUG)
std::fprintf(stderr, "\nDISABLED std::system_error: %s\n", msg.c_str());
std::fflush(stderr);
# endif
type_caster_odr_violation_detected_counter()++;
} else {
throw std::system_error(std::make_error_code(std::errc::state_not_recoverable), msg);