From 33fb7a6bd849653445b6ae37a8c274d3de9519cc Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 2 Dec 2022 05:41:49 -0800 Subject: [PATCH] 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. --- include/pybind11/detail/type_caster_odr_guard.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/pybind11/detail/type_caster_odr_guard.h b/include/pybind11/detail/type_caster_odr_guard.h index 6dda2583a..71d074d1d 100644 --- a/include/pybind11/detail/type_caster_odr_guard.h +++ b/include/pybind11/detail/type_caster_odr_guard.h @@ -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);