[pygobject] Simplify pygi_error_marshal to use GError initializer arguments



commit f80f5ec434ed868ab1f35d6a81537384e753b09d
Author: Simon Feltman <sfeltman src gnome org>
Date:   Sun May 4 23:43:50 2014 -0700

    Simplify pygi_error_marshal to use GError initializer arguments
    
    https://bugzilla.gnome.org/show_bug.cgi?id=712519

 gi/pygi-error.c |   27 +++++++--------------------
 1 files changed, 7 insertions(+), 20 deletions(-)
---
diff --git a/gi/pygi-error.c b/gi/pygi-error.c
index d848a0e..73b7fbe 100644
--- a/gi/pygi-error.c
+++ b/gi/pygi-error.c
@@ -43,7 +43,7 @@ pygi_error_marshal (GError **error)
     PyGILState_STATE state;
     PyObject *exc_type;
     PyObject *exc_instance;
-    PyObject *d;
+    const char *domain = NULL;
 
     g_return_val_if_fail(error != NULL, NULL);
 
@@ -61,27 +61,14 @@ pygi_error_marshal (GError **error)
             exc_type = item;
     }
 
-    exc_instance = PyObject_CallFunction(exc_type, "z", (*error)->message);
-
     if ((*error)->domain) {
-        PyObject_SetAttrString(exc_instance, "domain",
-                               d=PYGLIB_PyUnicode_FromString(g_quark_to_string((*error)->domain)));
-        Py_DECREF(d);
+        domain = g_quark_to_string ((*error)->domain);
     }
-    else
-        PyObject_SetAttrString(exc_instance, "domain", Py_None);
-
-    PyObject_SetAttrString(exc_instance, "code",
-                           d=PYGLIB_PyLong_FromLong((*error)->code));
-    Py_DECREF(d);
 
-    if ((*error)->message) {
-        PyObject_SetAttrString(exc_instance, "message",
-                               d=PYGLIB_PyUnicode_FromString((*error)->message));
-        Py_DECREF(d);
-    } else {
-        PyObject_SetAttrString(exc_instance, "message", Py_None);
-    }
+    exc_instance = PyObject_CallFunction (exc_type, "ssi",
+                                          (*error)->message,
+                                          domain,
+                                          (*error)->code);
 
     pyglib_gil_state_release(state);
 


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