[issue44913] segfault in call to embedded PyModule_New
hai shi
report at bugs.python.org
Sat Aug 21 23:42:50 EDT 2021
hai shi <shihai1991 at 126.com> added the comment:
How about this one?
int foo(void)
{
printf(stderr, "foo BEGIN\n");
if (!Py_IsInitialized()) {
fprintf(stderr, "python already initialized\n");
return -1;
}
const char *module_name = "foo";
PyGILState_STATE state = PyGILState_Ensure();
PyObject *module_handle = PyModule_New(module_name);
if (module_handle == 0)
{
fprintf(stderr,"PyModule_New(module_data_name=%s) failed\n",
module_name);
exit(1);
}
fprintf(stdout, "point is: %p\n", module_handle);
fprintf(stderr, "foo END\n");
PyGILState_Release(state);
return 0;
}
----------
nosy: +shihai1991
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44913>
_______________________________________
More information about the Python-bugs-list
mailing list