bugfix [#23148] "ImportError: __import__ not found" on changing Render FPS
The BGE was getting the namespace dict directly from __main__ which conflicts with my recent fix to get the pickle module working which to overwrote the __main__ module on script execution. Simple fix is to have the BGE and Blender use the same method of getting namespaces. Renamed CreateGlobalDictionary() to bpy_namespace_dict_new() and moved into bpy_internal_import.c pickle still wont work in the BGE since we make a copy of __main__ namespace but for speed would rather not have to replace the __main__ module many times per second.
This commit is contained in:
@@ -305,7 +305,7 @@ bool SCA_PythonController::Import()
|
||||
char *function_string;
|
||||
|
||||
function_string= strrchr(mod_path, '.');
|
||||
|
||||
|
||||
if(function_string == NULL) {
|
||||
printf("Python module name formatting error \"%s\":\n\texpected \"SomeModule.Func\", got \"%s\"\n", GetName().Ptr(), m_scriptText.Ptr());
|
||||
return false;
|
||||
@@ -316,11 +316,17 @@ bool SCA_PythonController::Import()
|
||||
|
||||
// Import the module and print an error if it's not found
|
||||
PyObject *mod = PyImport_ImportModule(mod_path);
|
||||
if(mod && m_debug)
|
||||
|
||||
if (mod == NULL) {
|
||||
ErrorPrint("Python module can't be imported");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(m_debug)
|
||||
mod = PyImport_ReloadModule(mod);
|
||||
|
||||
if (mod == NULL) {
|
||||
ErrorPrint("Python module not found");
|
||||
ErrorPrint("Python module can't be reloaded");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user