Module: sems
Branch: rco/offer_answer
Commit: 299616d4832bd29354bc5b97ee57e743de505f7d
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=299616d4832bd29354bc5b97ee57e743de505f7d

Author: Raphael Coeffic <[email protected]>
Committer: Raphael Coeffic <[email protected]>
Date:   Mon May 23 12:00:32 2011 +0200

deleting inconditionally might corrupt the sys.modules dictionnary.

This fixes an issue which caused all subsequent ivr scripts not to load after 
one failed (for example, because of missing imports).

---

 apps/ivr/Ivr.cpp |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/apps/ivr/Ivr.cpp b/apps/ivr/Ivr.cpp
index 75e087e..601ffae 100644
--- a/apps/ivr/Ivr.cpp
+++ b/apps/ivr/Ivr.cpp
@@ -360,7 +360,6 @@ bool IvrFactory::loadScript(const string& path)
   modName = PyString_FromString(path.c_str());
   
   mod     = PyImport_Import(modName);
-  Py_DECREF(modName);
   if (NULL != config) {
     // remove config ivr ivr_module while loading
     PyObject_DelAttrString(ivr_module, "config");
@@ -371,14 +370,21 @@ bool IvrFactory::loadScript(const string& path)
     PyErr_Print();
     WARN("IvrFactory: Failed to load \"%s\"\n", path.c_str());
 
+    // before python 2.4,
+    // it can happen that the module
+    // is still in the dictionnary.
     dict = PyImport_GetModuleDict();
     Py_INCREF(dict);
-    PyDict_DelItemString(dict,path.c_str());
+    if(PyDict_Contains(dict,modName)){
+      PyDict_DelItem(dict,modName);
+    }
     Py_DECREF(dict);
+    Py_DECREF(modName);
 
     return false;
   }
 
+  Py_DECREF(modName);
   dict = PyModule_GetDict(mod);
   dlg_class = PyDict_GetItemString(dict, "IvrDialog");
 

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to