summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gi/module.py9
-rw-r--r--gi/pygi-basictype.c2
-rw-r--r--gi/pygi-basictype.h1
-rw-r--r--gi/pygi-repository.c18
4 files changed, 11 insertions, 19 deletions
diff --git a/gi/module.py b/gi/module.py
index 28569039..c5b030ab 100644
--- a/gi/module.py
+++ b/gi/module.py
@@ -22,11 +22,8 @@
from __future__ import absolute_import
-import sys
import importlib
-_have_py3 = (sys.version_info[0] >= 3)
-
try:
maketrans = ''.maketrans
except AttributeError:
@@ -124,9 +121,6 @@ class IntrospectionModule(object):
path = repository.get_typelib_path(self._namespace)
self.__path__ = [path]
- if _have_py3:
- # get_typelib_path() delivers bytes, not a string
- self.__path__ = [path.decode('UTF-8')]
if self._version is None:
self._version = repository.get_version(self._namespace)
@@ -239,9 +233,6 @@ class IntrospectionModule(object):
def __repr__(self):
path = repository.get_typelib_path(self._namespace)
- if _have_py3:
- # get_typelib_path() delivers bytes, not a string
- path = path.decode('UTF-8')
return "<IntrospectionModule %r from %r>" % (self._namespace, path)
def __dir__(self):
diff --git a/gi/pygi-basictype.c b/gi/pygi-basictype.c
index 75cbcdfb..451875e7 100644
--- a/gi/pygi-basictype.c
+++ b/gi/pygi-basictype.c
@@ -1003,7 +1003,7 @@ pygi_utf8_to_py (gchar *value)
return PYGLIB_PyUnicode_FromString (value);
}
-static PyObject *
+PyObject *
pygi_filename_to_py (gchar *value)
{
PyObject *py_obj;
diff --git a/gi/pygi-basictype.h b/gi/pygi-basictype.h
index 1a6ecc4e..1d010ec7 100644
--- a/gi/pygi-basictype.h
+++ b/gi/pygi-basictype.h
@@ -63,6 +63,7 @@ PyObject *pygi_gint_to_py (gint value);
PyObject *pygi_glong_to_py (glong value);
PyObject *pygi_guint_to_py (guint value);
PyObject *pygi_gulong_to_py (gulong value);
+PyObject *pygi_filename_to_py (gchar *value);
gboolean pygi_gboolean_from_py (PyObject *object, gboolean *result);
gboolean pygi_gint64_from_py (PyObject *object, gint64 *result);
diff --git a/gi/pygi-repository.c b/gi/pygi-repository.c
index e69d784b..146f4e70 100644
--- a/gi/pygi-repository.c
+++ b/gi/pygi-repository.c
@@ -21,6 +21,7 @@
#include "pygi-repository.h"
#include "pygi-info.h"
+#include "pygi-basictype.h"
#include "pygi-python-compat.h"
PyObject *PyGIRepositoryError;
@@ -46,7 +47,7 @@ _wrap_g_irepository_enumerate_versions (PyGIRepository *self,
ret = PyList_New(0);
for (item = versions; item; item = item->next) {
char *version = item->data;
- PyObject *py_version = PYGLIB_PyUnicode_FromString (version);
+ PyObject *py_version = pygi_utf8_to_py (version);
PyList_Append(ret, py_version);
Py_DECREF(py_version);
g_free (version);
@@ -121,8 +122,8 @@ _wrap_g_irepository_is_registered (PyGIRepository *self,
return NULL;
}
- return PyBool_FromLong (g_irepository_is_registered (self->repository,
- namespace_, version));
+ return pygi_gboolean_to_py (g_irepository_is_registered (self->repository,
+ namespace_, version));
}
static PyObject *
@@ -237,7 +238,7 @@ _wrap_g_irepository_get_typelib_path (PyGIRepository *self,
return NULL;
}
- return PYGLIB_PyBytes_FromString (typelib_path);
+ return pygi_filename_to_py (typelib_path);
}
static PyObject *
@@ -260,7 +261,7 @@ _wrap_g_irepository_get_version (PyGIRepository *self,
return NULL;
}
- return PYGLIB_PyUnicode_FromString (version);
+ return pygi_utf8_to_py (version);
}
static PyObject *
@@ -274,7 +275,7 @@ _wrap_g_irepository_get_loaded_namespaces (PyGIRepository *self)
py_namespaces = PyList_New (0);
for (i = 0; namespaces[i] != NULL; i++) {
- PyObject *py_namespace = PYGLIB_PyUnicode_FromString (namespaces[i]);
+ PyObject *py_namespace = pygi_utf8_to_py (namespaces[i]);
PyList_Append (py_namespaces, py_namespace);
Py_DECREF(py_namespace);
g_free (namespaces[i]);
@@ -309,7 +310,7 @@ _wrap_g_irepository_get_dependencies (PyGIRepository *self,
}
for (i = 0; namespaces[i] != NULL; i++) {
- PyObject *py_namespace = PYGLIB_PyUnicode_FromString (namespaces[i]);
+ PyObject *py_namespace = pygi_utf8_to_py (namespaces[i]);
PyList_Append (py_namespaces, py_namespace);
Py_DECREF(py_namespace);
}
@@ -342,7 +343,7 @@ _wrap_g_irepository_get_immediate_dependencies (PyGIRepository *self,
namespace_);
for (i = 0; namespaces[i] != NULL; i++) {
- PyObject *py_namespace = PYGLIB_PyUnicode_FromString (namespaces[i]);
+ PyObject *py_namespace = pygi_utf8_to_py (namespaces[i]);
PyList_Append (py_namespaces, py_namespace);
Py_DECREF (py_namespace);
}
@@ -400,4 +401,3 @@ pygi_repository_register_types (PyObject *m)
return 0;
}
-