More verbose error messages when PyType_Ready fails

This commit is contained in:
Wenzel Jakob 2016-09-14 23:39:16 +08:00
parent c1fc27e2b5
commit e72a676b72

View File

@ -633,7 +633,7 @@ protected:
auto type = (PyHeapTypeObject*) type_holder.ptr(); auto type = (PyHeapTypeObject*) type_holder.ptr();
if (!type_holder || !name) if (!type_holder || !name)
pybind11_fail("generic_type: unable to create type object!"); pybind11_fail(std::string(rec->name) + ": Unable to create type object!");
/* Register supplemental type information in C++ dict */ /* Register supplemental type information in C++ dict */
detail::type_info *tinfo = new detail::type_info(); detail::type_info *tinfo = new detail::type_info();
@ -682,7 +682,8 @@ protected:
type->ht_type.tp_doc = tp_doc; type->ht_type.tp_doc = tp_doc;
if (PyType_Ready(&type->ht_type) < 0) if (PyType_Ready(&type->ht_type) < 0)
pybind11_fail("generic_type: PyType_Ready failed!"); pybind11_fail(std::string(rec->name) + ": PyType_Ready failed (" +
detail::error_string() + ")!");
m_ptr = type_holder.ptr(); m_ptr = type_holder.ptr();