Salome HOME
This commit was generated by cvs2git to create tag 'V1_3_0'.
[modules/kernel.git] / src / SALOMEGUI / QAD_PyInterp.cxx
index 00faaa1b1b13b5073723a1af5e8990dd17160c7d..5f04d820f6e5f352c15db968f9a4a8a0684f2594 100644 (file)
@@ -93,8 +93,8 @@ void QAD_PyInterp::initContext()
   if(m == NULL)
     {
       MESSAGE("problem...");
-      ASSERT(0);
       PyErr_Print();
+      ASSERT(0);
       salomeReleaseLock(); 
       return;
     }  
@@ -105,21 +105,31 @@ void QAD_PyInterp::initContext()
     {
       PyDict_SetItemString(_g, "__builtins__", builtinmodule); // assign singleton __builtin__ module
     }
+// Debut modif CCAR
   /*
-   * Call salome_shared_modules to import salome shared modules that must not be initialized twice
-   * so import_shared_modules makes only a copy of the modules in _tstate->interp->modules
-   * (sys.modules)
+   * Import special module to change the import mechanism
    */
-  m= PyObject_CallMethod(salome_shared_modules_module,
-                        "import_shared_modules","O",
-                        _tstate->interp->modules);
-  if (m == NULL)
-    {
-      /*
-       * Problem  , print it
-       */
-      MESSAGE("problem...");
-      ASSERT(0);
+  m =PyImport_ImportModule("import_hook");
+  if(m == NULL){
+      MESSAGE("initContext: problem with import_hook import");
       PyErr_Print();
-    }
+      PyErr_Clear();
+      ASSERT(0);
+  }
+  /*
+   * Call init_shared_modules to initialize the shared import mechanism for modules 
+   * that must not be imported twice
+   */
+  if(m != NULL){
+      m= PyObject_CallMethod(m,
+                        "init_shared_modules","O",salome_shared_modules_module);
+      if (m == NULL){
+          MESSAGE("initContext: problem with init_shared_modules call");
+          PyErr_Print();
+          PyErr_Clear();
+          ASSERT(0);
+      }
+  }
+// Fin   modif CCAR
+
 }