mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-11 08:50:31 +00:00
Added function for reloading module (#1040)
This commit is contained in:
committed by
Dean Moldovan
parent
2cf87a54d8
commit
c64e6b1670
@@ -836,6 +836,14 @@ public:
|
||||
return reinterpret_steal<module>(obj);
|
||||
}
|
||||
|
||||
/// Reload the module or throws `error_already_set`.
|
||||
void reload() {
|
||||
PyObject *obj = PyImport_ReloadModule(ptr());
|
||||
if (!obj)
|
||||
throw error_already_set();
|
||||
*this = reinterpret_steal<module>(obj);
|
||||
}
|
||||
|
||||
// Adds an object to the module using the given name. Throws if an object with the given name
|
||||
// already exists.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user