pybind11/include/pybind11
Dean Moldovan d534bd670e Fix handling of Python exceptions during module initialization (#657)
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.)
2017-02-08 20:23:56 +01:00
..
attr.h Fix debugging output for nameless py::arg_v annotations (#648) 2017-02-08 08:45:51 +01:00
cast.h Add support for non-converting arguments 2017-02-03 20:18:15 -05:00
chrono.h Simplify redundant code, conform to style suggestions, improve logic 2016-09-28 01:01:44 +10:00
common.h Fix handling of Python exceptions during module initialization (#657) 2017-02-08 20:23:56 +01:00
complex.h Made arithmetic and complex casters respect convert 2017-02-03 20:16:14 -05:00
descr.h std::valarray support for stl.h (#545) 2016-12-08 00:43:29 +01:00
eigen.h Fix pointer to reference error in type_caster on MSVC (#583) 2017-01-03 11:52:05 +01:00
eval.h WIP: PyPy support (#527) 2016-12-16 15:00:46 +01:00
functional.h Fix pointer to reference error in type_caster on MSVC (#583) 2017-01-03 11:52:05 +01:00
numpy.h renamed _check -> check_ 2017-02-07 00:06:07 +01:00
operators.h Multiple inheritance support 2016-09-19 13:45:31 +02:00
options.h Provide more control over automatic generation of docstrings (#486) 2016-11-15 12:38:05 +01:00
pybind11.h Fix handling of Python exceptions during module initialization (#657) 2017-02-08 20:23:56 +01:00
pytypes.h renamed _check -> check_ 2017-02-07 00:06:07 +01:00
stl_bind.h Change all_of_t/any_of_t to all_of/any_of, add none_of 2016-12-14 20:42:36 +01:00
stl.h WIP: PyPy support (#527) 2016-12-16 15:00:46 +01:00
typeid.h minor cleanups in common.h; updated author info and copyright year 2016-04-18 10:53:38 +02:00