[pygobject] Unify Python unicode to utf8 GI marshaling code



commit a62e8cdf90f7b03cfc8116125ef3557f9ad08dde
Author: Simon Feltman <sfeltman src gnome org>
Date:   Sat Feb 16 19:32:54 2013 -0800

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

 gi/pygi-argument.c |   32 ++------------------------------
 1 files changed, 2 insertions(+), 30 deletions(-)
---
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index a72239c..cb3ac32 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -1041,36 +1041,8 @@ _pygi_argument_from_object (PyObject   *object,
         }
         case GI_TYPE_TAG_UTF8:
         {
-            gchar *string;
-
-            if (object == Py_None) {
-                arg.v_string = NULL;
-                break;
-            }
-#if PY_VERSION_HEX < 0x03000000
-            if (PyUnicode_Check(object)) {
-                 PyObject *pystr_obj = PyUnicode_AsUTF8String (object);
-                 
-                 if (!pystr_obj)
-                     break;
-
-                 string = g_strdup(PyString_AsString (pystr_obj));
-                 Py_DECREF(pystr_obj);
-            } else {
-                 string = g_strdup(PyString_AsString (object));
-            }
-#else
-            {
-                PyObject *pybytes_obj = PyUnicode_AsUTF8String (object);
-                if (!pybytes_obj)
-                    break;
-
-                string = g_strdup(PyBytes_AsString (pybytes_obj));
-                Py_DECREF (pybytes_obj);
-            }
-#endif
-            arg.v_string = string;
-
+            _pygi_marshal_from_py_utf8 (NULL, NULL, NULL,
+                                        object, &arg);
             break;
         }
         case GI_TYPE_TAG_FILENAME:


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