[libpeas] Remove overly verbose warnings in the Python loader



commit b95aebb38b317c9a33db80e0c0caee7accb60a2b
Author: Garrett Regier <garrettregier gmail com>
Date:   Sun Jan 4 21:31:00 2015 -0800

    Remove overly verbose warnings in the Python loader
    
    Instead of very specific and still confusing messages
    we use g_return_*() to give us an idea about what
    went wrong while initializing. This only affects the
    internal Python initialization code.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742349

 loaders/python/peas-python-internal.c |   41 ++++-----------------------------
 1 files changed, 5 insertions(+), 36 deletions(-)
---
diff --git a/loaders/python/peas-python-internal.c b/loaders/python/peas-python-internal.c
index c7d175b..6acd020 100644
--- a/loaders/python/peas-python-internal.c
+++ b/loaders/python/peas-python-internal.c
@@ -49,13 +49,7 @@ peas_python_internal_new (void)
   builtins_module = PyImport_ImportModule ("builtins");
 #endif
 
-  if (builtins_module == NULL)
-    {
-      g_warning ("Error initializing Python Plugin Loader: "
-                 "failed to get builtins module");
-
-      return NULL;
-    }
+  g_return_val_if_fail (builtins_module != NULL, NULL);
 
   /* We don't use the byte-compiled Python source
    * because glib-compile-resources cannot output
@@ -74,34 +68,21 @@ peas_python_internal_new (void)
                                              G_RESOURCE_LOOKUP_FLAGS_NONE,
                                              NULL);
 
-  if (internal_python == NULL)
-    {
-      g_warning ("Error initializing Python Plugin Loader: "
-                 "failed to locate internal Python code");
-
-      return NULL;
-    }
+  g_return_val_if_fail (internal_python != NULL, NULL);
 
   /* Compile it manually so the filename is available */
   code = Py_CompileString (g_bytes_get_data (internal_python, NULL),
                            "peas-python-internal.py",
                            Py_file_input);
-
   g_bytes_unref (internal_python);
 
-  if (code == NULL)
-    {
-      g_warning ("Error initializing Python Plugin Loader: "
-                 "failed to compile internal Python code");
-
-      return NULL;
-    }
+  g_return_val_if_fail (code != NULL, NULL);
 
   globals = PyDict_New ();
   if (globals == NULL)
     {
       Py_DECREF (code);
-      return NULL;
+      g_return_val_if_fail (globals != NULL, NULL);
     }
 
   if (PyDict_SetItemString (globals, "__builtins__",
@@ -114,31 +95,19 @@ peas_python_internal_new (void)
 
   result = PyEval_EvalCode ((gpointer) code, globals, globals);
   Py_XDECREF (result);
-
   Py_DECREF (code);
 
   if (PyErr_Occurred ())
     {
-      g_warning ("Error initializing Python Plugin Loader: "
-                 "failed to run internal Python code");
-
       Py_DECREF (globals);
       return NULL;
     }
 
   internal = PyDict_GetItemString (globals, "hooks");
   Py_XINCREF (internal);
-
   Py_DECREF (globals);
 
-  if (internal == NULL)
-    {
-      g_warning ("Error initializing Python Plugin Loader: "
-                 "failed to find internal Python hooks");
-
-      return NULL;
-    }
-
+  g_return_val_if_fail (internal != NULL, NULL);
   return (PeasPythonInternal *) internal;
 }
 


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