[pygobject] Unify utf8 to Python GI marshaling code



commit 54aa043d96deb02589e13042a46917405ca53780
Author: Simon Feltman <sfeltman src gnome org>
Date:   Thu Mar 28 05:20:00 2013 -0700

    Unify utf8 to Python GI marshaling code
    
    Change _pygi_argument_to_object to use the cachers marshaler
    (_pygi_marshal_to_py_utf8) directly instead of keeping a
    copy of the code.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=693405

 gi/pygi-argument.c      |   11 ++++-------
 gi/pygi-marshal-to-py.c |    4 +---
 2 files changed, 5 insertions(+), 10 deletions(-)
---
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index 44dff1a..dd0944f 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -1527,14 +1527,11 @@ _pygi_argument_to_object (GIArgument  *arg,
             break;
         }
         case GI_TYPE_TAG_UTF8:
-            if (arg->v_string == NULL) {
-                object = Py_None;
-                Py_INCREF (object);
-                break;
-            }
-
-            object = PYGLIB_PyUnicode_FromString (arg->v_string);
+        {
+            object = _pygi_marshal_to_py_utf8 (NULL, NULL, NULL,
+                                               arg);
             break;
+        }
         case GI_TYPE_TAG_FILENAME:
         {
             GError *error = NULL;
diff --git a/gi/pygi-marshal-to-py.c b/gi/pygi-marshal-to-py.c
index 6dde41d..fbd2bb0 100644
--- a/gi/pygi-marshal-to-py.c
+++ b/gi/pygi-marshal-to-py.c
@@ -293,9 +293,7 @@ _pygi_marshal_to_py_utf8 (PyGIInvokeState   *state,
 {
     PyObject *py_obj = NULL;
     if (arg->v_string == NULL) {
-        py_obj = Py_None;
-        Py_INCREF (py_obj);
-        return py_obj;
+        Py_RETURN_NONE;
      }
 
     py_obj = PYGLIB_PyUnicode_FromString (arg->v_string);


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