Commit 73a1c0cf authored by Manuel Günther's avatar Manuel Günther
Browse files

Corrected error cases in module creation

parent 51e9be76
......@@ -38,11 +38,13 @@ static PyObject* create_module (void) {
# if PY_VERSION_HEX >= 0x03000000
PyObject* m = PyModule_Create(&module_definition);
auto m_ = make_xsafe(m);
const char* ret = "O";
# else
PyObject* m = Py_InitModule3(BOB_EXT_MODULE_NAME, module_methods, module_docstr);
const char* ret = "N";
# endif
if (!m) return 0;
auto m_ = make_safe(m);
/* imports dependencies */
if (import_bob_blitz() < 0) return 0;
......@@ -102,7 +104,7 @@ static PyObject* create_module (void) {
PyErr_Print();
}
return Py_BuildValue("O", m);
return Py_BuildValue(ret, m);
}
PyMODINIT_FUNC BOB_EXT_ENTRY_NAME (void) {
......
......@@ -122,17 +122,19 @@ static PyObject* create_module (void) {
# if PY_VERSION_HEX >= 0x03000000
PyObject* m = PyModule_Create(&module_definition);
auto m_ = make_xsafe(m);
const char* ret = "O";
# else
PyObject* m = Py_InitModule3(BOB_EXT_MODULE_NAME, module_methods, module_docstr);
const char* ret = "N";
# endif
if (!m) return 0;
auto m_ = make_safe(m); ///< protects against early returns
/* register version numbers and constants */
if (PyModule_AddStringConstant(m, "module", BOB_EXT_MODULE_VERSION) < 0) return 0;
if (PyModule_AddObject(m, "externals", build_version_dictionary()) < 0) return 0;
return Py_BuildValue("O", m);
return Py_BuildValue(ret, m);
}
PyMODINIT_FUNC BOB_EXT_ENTRY_NAME (void) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment