mirror of
https://github.com/pybind/pybind11.git
synced 2025-01-19 09:25:51 +00:00
d534bd670e
Fixes #656. Before this commit, the problematic sequence was: 1. `catch (const std::exception &e)` gets a Python exception, i.e. `error_already_set`. 2. `PyErr_SetString(PyExc_ImportError, e.what())` sets an `ImportError`. 3. `~error_already_set()` now runs, but `gil_scoped_acquire` fails due to an unhandled `ImportError` (which was just set in step 2). This commit adds a separate catch block for Python exceptions which just clears the Python error state a little earlier and replaces it with an `ImportError`, thus making sure that there is only a single Python exception in flight at a time. (After step 2 in the sequence above, there were effectively two Python expections set.) |
||
---|---|---|
.. | ||
pybind11 |