We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3735249 commit bf30d61Copy full SHA for bf30d61
include/pybind11/pybind11.h
@@ -794,11 +794,14 @@ class module : public object {
794
explicit module(const char *name, const char *doc = nullptr) {
795
if (!options::show_user_defined_docstrings()) doc = nullptr;
796
#if PY_MAJOR_VERSION >= 3
797
- PyModuleDef *def = new PyModuleDef();
+ PyModuleDef *def = PyMem_New(PyModuleDef, 1);
798
std::memset(def, 0, sizeof(PyModuleDef));
799
def->m_name = name;
800
def->m_doc = doc;
801
def->m_size = -1;
802
+ def->m_free = [](void* module){
803
+ Py_DECREF( PyModule_GetDef((PyObject*) module));
804
+ };
805
Py_INCREF(def);
806
m_ptr = PyModule_Create(def);
807
#else
0 commit comments