summaryrefslogtreecommitdiffstats
path: root/glib
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2010-04-16 12:57:15 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2010-04-16 13:02:42 -0400
commit15c3b04f4257fef54ca5f7ab60012b4936d672a3 (patch)
tree7681289908d6b6c4cca916fee6d61d2c2f649909 /glib
parentcecafa7e4809c8c2bfa77446beea8beb3a51d8dc (diff)
downloadpygobject-15c3b04f4257fef54ca5f7ab60012b4936d672a3.tar.gz
pygobject-15c3b04f4257fef54ca5f7ab60012b4936d672a3.tar.xz
pygobject-15c3b04f4257fef54ca5f7ab60012b4936d672a3.zip
Fix various selftests when building against python 3.1
Diffstat (limited to 'glib')
-rw-r--r--glib/pygiochannel.c2
-rw-r--r--glib/pygoptiongroup.c25
2 files changed, 24 insertions, 3 deletions
diff --git a/glib/pygiochannel.c b/glib/pygiochannel.c
index 544d3dd..45ccf52 100644
--- a/glib/pygiochannel.c
+++ b/glib/pygiochannel.c
@@ -279,7 +279,7 @@ static PyObject*
py_io_channel_write_lines(PyGIOChannel* self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "lines", NULL };
- char *buf;
+ char *buf = NULL;
Py_ssize_t buf_len;
gsize count;
GError* error = NULL;
diff --git a/glib/pygoptiongroup.c b/glib/pygoptiongroup.c
index ea3830b..58b9dad 100644
--- a/glib/pygoptiongroup.c
+++ b/glib/pygoptiongroup.c
@@ -165,6 +165,11 @@ pyg_option_group_add_entries(PyGOptionGroup *self, PyObject *args,
for (pos = 0; pos < entry_count; pos++)
{
gchar *long_name, *description, *arg_description;
+#if PY_VERSION_HEX >= 0x03000000
+ int short_name;
+#else
+ char short_name;
+#endif
entry_tuple = PyList_GetItem(list, pos);
if (!PyTuple_Check(entry_tuple))
{
@@ -173,9 +178,14 @@ pyg_option_group_add_entries(PyGOptionGroup *self, PyObject *args,
g_free(entries);
return NULL;
}
- if (!PyArg_ParseTuple(entry_tuple, "scisz",
+ if (!PyArg_ParseTuple(entry_tuple,
+#if PY_VERSION_HEX >= 0x03000000
+ "sCisz",
+#else
+ "scisz",
+#endif
&long_name,
- &(entries[pos].short_name),
+ &short_name,
&(entries[pos].flags),
&description,
&arg_description))
@@ -185,6 +195,17 @@ pyg_option_group_add_entries(PyGOptionGroup *self, PyObject *args,
g_free(entries);
return NULL;
}
+#if PY_VERSION_HEX >= 0x03000000
+ if (short_name > 0xff) {
+ PyErr_SetString(PyExc_TypeError,
+ "GOptionGroup.add_entries expected a shortname in the range 0-255");
+ return NULL;
+ }
+ entries[pos].short_name = short_name;
+#else
+ entries[pos].short_name = short_name;
+#endif
+
long_name = g_strdup(long_name);
self->strings = g_slist_prepend(self->strings, long_name);
entries[pos].long_name = long_name;