Commit 2d34d35e authored by Simon Feltman's avatar Simon Feltman
Browse files

Change interpretation of NULL pointer field from None to 0

The usage of 0 is needed because these fields should generally
be used to store integer indices or hashes, not necessarily
pointers to actual data.

https://bugzilla.gnome.org/show_bug.cgi?id=698366
parent 8d61ad38
......@@ -1402,18 +1402,9 @@ _pygi_argument_to_object (GIArgument *arg,
switch (type_tag) {
case GI_TYPE_TAG_VOID:
{
if (g_type_info_is_pointer (type_info) &&
(arg->v_pointer != NULL)) {
if (g_type_info_is_pointer (type_info)) {
g_warn_if_fail (transfer == GI_TRANSFER_NOTHING);
object = PyLong_FromVoidPtr (arg->v_pointer);
} else {
/* None is used instead of zero for parity with ctypes.
* This is helpful in case the values are being used for
* actual memory addressing, in which case None will
* raise as opposed to 0 which will crash.
*/
object = Py_None;
Py_INCREF (object);
}
break;
}
......
......@@ -505,7 +505,8 @@ class TestEverything(unittest.TestCase):
glist = GLib.List()
raw = RawGList.from_wrapped(glist)
self.assertEqual(glist.data, None)
# Note that pointer fields use 0 for NULL in PyGObject and None in ctypes
self.assertEqual(glist.data, 0)
self.assertEqual(raw.contents.data, None)
glist.data = 123
......@@ -513,7 +514,7 @@ class TestEverything(unittest.TestCase):
self.assertEqual(raw.contents.data, 123)
glist.data = None
self.assertEqual(glist.data, None)
self.assertEqual(glist.data, 0)
self.assertEqual(raw.contents.data, None)
# Setting to anything other than an int should raise
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment