[glom] test_python_module: Unref the python object.



commit e46c9d1dc5af9353ad4cdff5ab5c02d3d70b3217
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Nov 6 10:04:59 2013 +0100

    test_python_module: Unref the python object.

 tests/python/test_python_module.cc |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/tests/python/test_python_module.cc b/tests/python/test_python_module.cc
index 6cb6cab..7162c7a 100644
--- a/tests/python/test_python_module.cc
+++ b/tests/python/test_python_module.cc
@@ -14,13 +14,15 @@ namespace Glom
 bool glom_python_module_is_available()
 {
   const gchar* name = "glom_" GLOM_ABI_VERSION_UNDERLINED;
-  PyObject* module_glom = PyImport_ImportModule((char*)name); //TODO: unref this?
+  PyObject* module_glom = PyImport_ImportModule((char*)name);
 
   if(!module_glom)
   {
-    g_warning("Glom: A python import of %s failed.\n", name);
+    std::cerr << "Glom: A python import of " << name << " failed." << std::endl;
   }
 
+  Py_XDECREF(module_glom);
+
   return module_glom != 0;
 }
 
@@ -29,13 +31,15 @@ bool gda_python_module_is_available()
   //Python code usually uses "from gi.repository import Gda" so that 
   //the code may use Gda. rather than gi.repository.Gda in the code.
   const gchar* name = "gi.repository.Gda"; 
-  PyObject* module_glom = PyImport_ImportModule((char*)name); //TODO: unref this?
+  PyObject* module_glom = PyImport_ImportModule((char*)name);
 
   if(!module_glom)
   {
-    g_warning("Glom: A python import of %s failed.\n", name);
+    std::cerr << "Glom: A python import of " << name << " failed." << std::endl;
   }
 
+  Py_XDECREF(module_glom);
+
   return module_glom != 0;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]