This is a very simple change in support of the PyCLIF-pybind11 integration work:
Merely an extra if to pre-empt TypeError: pybind11::init(): factory function returned nullptr. This allows the factory function to set a custom Python error instead.
Manually written factory functions could throw error_already_set() directly, but in the context of PyCLIF that is very difficult (compared to this very simple PR), because the factory function can be completely unaware of pybind11.
Suggested changelog entry:
Python errors set in constructor factory functions are no longer clobbered by a generic exception.
Description
(The equivalent of this PR was merged as https://github.com/google/pywrapcc/pull/30064 on September 12, 2023.)
This is a very simple change in support of the PyCLIF-pybind11 integration work:
Merely an extra
if
to pre-emptTypeError: pybind11::init(): factory function returned nullptr
. This allows the factory function to set a custom Python error instead.Manually written factory functions could
throw error_already_set()
directly, but in the context of PyCLIF that is very difficult (compared to this very simple PR), because the factory function can be completely unaware of pybind11.Suggested changelog entry: