diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index b6de43116..c4f9426d1 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -470,6 +470,7 @@ public: sibling((handle) attr(name_)), extra...); /* PyModule_AddObject steals a reference to 'func' */ PyModule_AddObject(ptr(), name_, func.inc_ref().ptr()); + func.attr("__module__") = attr("__name__"); return *this; }