[pygobject] use PyObject_SetAttrString, not PyDict_SetItemString when setting __gtype__
- From: John Palmieri <johnp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] use PyObject_SetAttrString, not PyDict_SetItemString when setting __gtype__
- Date: Fri, 3 Sep 2010 20:32:46 +0000 (UTC)
commit 6d183d1fff55d54569ba3e1f90a10284df74fd40
Author: John (J5) Palmieri <johnp redhat com>
Date: Fri Sep 3 12:04:16 2010 -0400
use PyObject_SetAttrString, not PyDict_SetItemString when setting __gtype__
* When registering a gtype wrapper we used to set tp_dict directly. This works
in python 2 but python 3 seems to handle attributes in a slightly different
way where the tp_dict and attr get out of sync. By setting the attr
directly we avoid this issue.
* Note that there are many more places where we set __gtype__ using tp_dict
however for objects which are not instantiated yet we have to set tp_dict
directly.
* Since this one change fixes a lot of failed tests, for now we ignore the
other places where we set __gtype__. If we run into more issues dealing
with __gtype__ we can take a closer look later.
https://bugzilla.gnome.org/show_bug.cgi?id=627878
https://bugzilla.gnome.org/show_bug.cgi?id=615872
gobject/gobjectmodule.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c
index 05a71d9..804d5b0 100644
--- a/gobject/gobjectmodule.c
+++ b/gobject/gobjectmodule.c
@@ -1192,7 +1192,7 @@ pyg_type_register(PyTypeObject *class, const char *type_name)
/* set new value of __gtype__ on class */
gtype = pyg_type_wrapper_new(instance_type);
- PyDict_SetItemString(class->tp_dict, "__gtype__", gtype);
+ PyObject_SetAttrString(class, "__gtype__", gtype);
Py_DECREF(gtype);
/* propagate new constructor API compatility flag from parent to child type */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]