File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -976,18 +976,18 @@ class module_ : public object {
976
976
/* m_free */ nullptr
977
977
};
978
978
auto m = PyModule_Create (def);
979
- if (m == nullptr )
980
- pybind11_fail (" Internal error in module_::create_extension_module()" );
981
- // TODO: Should be reinterpret_steal, but Python also steals it again when returned from PyInit_...
982
- return reinterpret_borrow<module_>(m);
983
979
#else
984
980
// Ignore module_def *def; only necessary for Python 3
985
981
(void ) def;
986
982
auto m = Py_InitModule3 (name, nullptr , options::show_user_defined_docstrings () ? doc : nullptr );
983
+ #endif
984
+ if (PyErr_Occurred ())
985
+ throw error_already_set ();
987
986
if (m == nullptr )
988
987
pybind11_fail (" Internal error in module_::create_extension_module()" );
988
+ // TODO: Sould be reinterpret_steal for Python 3, but Python also steals it again when returned from PyInit_...
989
+ // For Python 2, reinterpret_borrow is correct.
989
990
return reinterpret_borrow<module_>(m);
990
- #endif
991
991
}
992
992
};
993
993
You can’t perform that action at this time.
0 commit comments