From e72a676b7262bef30fbe96149d3a11bb2ef969ff Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Wed, 14 Sep 2016 23:39:16 +0800 Subject: [PATCH] More verbose error messages when PyType_Ready fails --- include/pybind11/pybind11.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 0f5faa23d..4a6fa8dcf 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -633,7 +633,7 @@ protected: auto type = (PyHeapTypeObject*) type_holder.ptr(); 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 */ detail::type_info *tinfo = new detail::type_info(); @@ -682,7 +682,8 @@ protected: type->ht_type.tp_doc = tp_doc; 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();