commit 8e567d3ac18be2d0b32fbb1e6af033f36106206e
Author: John Stowers <john.stowers@gmail.com>
Date:   Fri Sep 24 22:44:03 2010 +1200

    Tidy up g_get_{cache,config,data}_dir
    
    	* Share common code

diff --git a/glib/glibmodule.c b/glib/glibmodule.c
index 4724e8d..d78ff82 100644
--- a/glib/glibmodule.c
+++ b/glib/glibmodule.c
@@ -417,10 +417,8 @@ pyglib_get_current_time(PyObject *unused)
 }
 
 static PyObject*
-pyglib_get_user_cache_dir(PyObject *self)
+get_user_dir(const char *path)
 {
-    const char *path = g_get_user_cache_dir();
-
     if (path)
         return PYGLIB_PyUnicode_FromString(path);
     else {
@@ -432,27 +430,19 @@ pyglib_get_user_cache_dir(PyObject *self)
 static PyObject*
 pyglib_get_user_config_dir(PyObject *self)
 {
-    const char *path = g_get_user_config_dir();
+    return get_user_dir(g_get_user_config_dir());
+}
 
-    if (path)
-        return PYGLIB_PyUnicode_FromString(path);
-    else {
-        Py_INCREF(Py_None);
-        return Py_None;
-    }
+static PyObject*
+pyglib_get_user_cache_dir(PyObject *self)
+{
+    return get_user_dir(g_get_user_cache_dir());
 }
 
 static PyObject*
 pyglib_get_user_data_dir(PyObject *self)
 {
-    const char *path = g_get_user_data_dir();
-
-    if (path)
-        return PYGLIB_PyUnicode_FromString(path);
-    else {
-        Py_INCREF(Py_None);
-        return Py_None;
-    }
+    return get_user_dir(g_get_user_data_dir());
 }
 
 static PyObject *
