Skip to content

Commit 16066f3

Browse files
committed
When fetching converter table ptr from __main__ properly check if it was initialized
1 parent a98bfe4 commit 16066f3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/cpp2py/py_converter.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ namespace cpp2py {
6363
}
6464

6565
// Return ptr from __cpp2py_table attribute if available
66+
if(not PyObject_HasAttrString(mod, "__cpp2py_table"))
67+
return {};
6668
pyref capsule = PyObject_GetAttrString(mod, "__cpp2py_table");
6769
if(capsule.is_null())
68-
return {};
70+
throw std::runtime_error("Severe internal error : can not load __main__.__cpp2py_table");
6971
void * ptr = PyCapsule_GetPointer(capsule, "__main__.__cpp2py_table");
7072
return {*static_cast<std::shared_ptr<conv_table_t> *>(ptr)};
7173
}

0 commit comments

Comments
 (0)