USD IO: handle UMM Python module load error.

Clearing the Python import module error if loading
the UMM module failed.  If we don't do this, the
Python unit test for USD will fail if the UMM
addon isn't installed. Also printing the Python
error in this case, if printing warnings is enabled.
This commit is contained in:
Michael Kowalski 2021-10-24 13:51:20 -04:00
parent 3f2a1fa87c
commit 1496105327
1 changed files with 8 additions and 2 deletions

View File

@ -334,8 +334,14 @@ static bool ensure_module_loaded(bool warn = true)
if (!g_umm_module) {
g_umm_module = PyImport_ImportModule(k_umm_module_name);
if (warn && !g_umm_module) {
std::cout << "WARNING: couldn't load Python module " << k_umm_module_name << std::endl;
if (!g_umm_module) {
if (warn) {
std::cout << "WARNING: couldn't load Python module " << k_umm_module_name << std::endl;
if (PyErr_Occurred()) {
PyErr_Print();
}
}
PyErr_Clear();
}
}