summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Ehresman <jpe@wingware.com>2010-04-13 12:00:34 -0400
committerJohn Ehresman <jpe@wingware.com>2010-04-15 12:16:48 -0400
commit8cd850a5d2526b83bf3862ec86c430f718947294 (patch)
tree5439904329c3bca36e18e5d2cc70ca698b01ca1e
parent8661f934abf276d71b5bf17b617f425a4fc6f06e (diff)
downloadpygobject-8cd850a5d2526b83bf3862ec86c430f718947294.tar.gz
pygobject-8cd850a5d2526b83bf3862ec86c430f718947294.tar.xz
pygobject-8cd850a5d2526b83bf3862ec86c430f718947294.zip
More PyString to _PyUnicode or _PyByteArray
-rw-r--r--gio/gmemoryinputstream.override14
-rw-r--r--gio/gmemoryoutputstream.override2
-rw-r--r--gio/gmount.override2
-rw-r--r--gio/gvolume.override2
-rw-r--r--glib/pyglib-python-compat.h1
5 files changed, 11 insertions, 10 deletions
diff --git a/gio/gmemoryinputstream.override b/gio/gmemoryinputstream.override
index 0495338..32b7a00 100644
--- a/gio/gmemoryinputstream.override
+++ b/gio/gmemoryinputstream.override
@@ -38,14 +38,14 @@ _wrap_g_memory_input_stream_add_data(PyGObject *self,
char *copy;
int length;
- if (!PyString_Check(data)) {
- PyErr_SetString(PyExc_TypeError, "data must be a string or None");
+ if (!_PyByteArray_Check(data)) {
+ PyErr_SetString(PyExc_TypeError, "data must be a bytes instance or None");
return NULL;
}
- length = PyString_Size(data);
+ length = _PyByteArray_Size(data);
copy = g_malloc(length);
- memcpy(copy, PyString_AsString(data), length);
+ memcpy(copy, _PyByteArray_AsString(data), length);
g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(self->obj),
copy, length, (GDestroyNotify) g_free);
@@ -74,14 +74,14 @@ _wrap_g_memory_input_stream_new_from_data(PyGObject *self,
char *copy;
int length;
- if (!PyString_Check(data)) {
+ if (!_PyByteArray_Check(data)) {
PyErr_SetString(PyExc_TypeError, "data must be a string or None");
return NULL;
}
- length = PyString_Size(data);
+ length = _PyByteArray_Size(data);
copy = g_malloc(length);
- memcpy(copy, PyString_AsString(data), length);
+ memcpy(copy, _PyByteArray_AsString(data), length);
stream = g_memory_input_stream_new_from_data(copy, length,
(GDestroyNotify) g_free);
diff --git a/gio/gmemoryoutputstream.override b/gio/gmemoryoutputstream.override
index 7614045..e95df0a 100644
--- a/gio/gmemoryoutputstream.override
+++ b/gio/gmemoryoutputstream.override
@@ -40,6 +40,6 @@ static PyObject *
_wrap_g_memory_output_stream_get_data(PyGObject *self)
{
GMemoryOutputStream *stream = G_MEMORY_OUTPUT_STREAM(self->obj);
- return PyString_FromStringAndSize(g_memory_output_stream_get_data(stream),
+ return _PyByteArray_FromStringAndSize(g_memory_output_stream_get_data(stream),
g_seekable_tell(G_SEEKABLE(stream)));
}
diff --git a/gio/gmount.override b/gio/gmount.override
index 54d5dd2..3aa6303 100644
--- a/gio/gmount.override
+++ b/gio/gmount.override
@@ -340,7 +340,7 @@ _wrap_g_mount_tp_repr(PyGObject *self)
g_free(name);
g_free(uuid);
- result = PyString_FromString(representation);
+ result = _PyUnicode_FromString(representation);
g_free(representation);
return result;
}
diff --git a/gio/gvolume.override b/gio/gvolume.override
index 83b855d..9aa50f8 100644
--- a/gio/gvolume.override
+++ b/gio/gvolume.override
@@ -154,7 +154,7 @@ _wrap_g_volume_tp_repr(PyGObject *self)
else
representation = g_strdup_printf("<%s at %p: UNKNOWN NAME>", Py_TYPE(self)->tp_name, self);
- result = PyString_FromString(representation);
+ result = _PyUnicode_FromString(representation);
g_free(representation);
return result;
}
diff --git a/glib/pyglib-python-compat.h b/glib/pyglib-python-compat.h
index e950160..6ba08a4 100644
--- a/glib/pyglib-python-compat.h
+++ b/glib/pyglib-python-compat.h
@@ -58,6 +58,7 @@ typedef inquiry lenfunc;
#define _PyByteArray_Resize _PyString_Resize
#define _PyByteArray_AsString PyString_AsString
#define _PyByteArray_Size PyString_Size
+#define _PyByteArray_Check PyString_Check
#define _PyLong_Check PyInt_Check
#define _PyLong_FromLong PyInt_FromLong