[pygobject] pygobject_lookup_class: clear exceptions between calls and don't return with one set



commit 052cea9e2b6e599e52435df3155d8de22500e0f4
Author: Christoph Reiter <creiter src gnome org>
Date:   Sun Mar 26 19:34:00 2017 +0200

    pygobject_lookup_class: clear exceptions between calls and don't return with one set
    
    https://bugzilla.gnome.org/show_bug.cgi?id=773394

 gi/pygobject-object.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/gi/pygobject-object.c b/gi/pygobject-object.c
index 0166a60..1e51f38 100644
--- a/gi/pygobject-object.c
+++ b/gi/pygobject-object.c
@@ -913,6 +913,8 @@ pygobject_find_slot_for(PyTypeObject *type, PyObject *bases, int slot_offset,
  * or interface has been registered for the given GType, then a new
  * type will be created.
  *
+ * Does not set an exception when NULL is returned.
+ *
  * Returns: The wrapper class for the GObject or NULL if the
  *          GType has no registered type and a new type couldn't be created
  */
@@ -928,11 +930,14 @@ pygobject_lookup_class(GType gtype)
     if (py_type == NULL) {
         py_type = g_type_get_qdata(gtype, pyginterface_type_key);
 
-        if (py_type == NULL)
+        if (py_type == NULL) {
             py_type = (PyTypeObject *)pygi_type_import_by_g_type(gtype);
+            PyErr_Clear ();
+        }
 
         if (py_type == NULL) {
             py_type = pygobject_new_with_interfaces(gtype);
+            PyErr_Clear ();
             g_type_set_qdata(gtype, pyginterface_type_key, py_type);
         }
     }


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