Added function for reloading module (#1040)

This commit is contained in:
Gunnar Läthén
2017-09-12 08:05:05 +02:00
committed by Dean Moldovan
parent 2cf87a54d8
commit c64e6b1670
3 changed files with 65 additions and 1 deletions

View File

@@ -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.
//