GNOME Bugzilla – Bug 559001
Allow setting pytype wrapper class
Last modified: 2009-03-24 20:35:02 UTC
Patch allows setting the pytype wrapper for a gtype. Implemented via setattr on GType.pytype, but could be moved to another function. Needed for the pybank prototype.
Created attachment 121834 [details] [review] Patch
> --- gobject/pygtype.c (revision 974) > +++ gobject/pygtype.c (working copy) > @@ -83,6 +83,23 @@ > return py_type; > } > > +int > +_wrap_g_type_wrapper__set_pytype(PyGTypeWrapper *self, PyObject* value, void *closure) > +{ Shouldn't that be a static function? I'd really like to see this get into pygobject.
We have a getter already, so it make sense to add a setter as well.
Created attachment 131142 [details] [review] updated patch Here's an updated version of John's patch with the following changes: * ChangeLog entry * consistent formatting * made the setter a static function * setter typechecks for None/type objects (throws a TypeError if invalid) * added two testcases and associated helper methods
Comment on attachment 131142 [details] [review] updated patch I *think* that the reference counting is wrong here, if value is non NULL it should be Py_INCREF:ed and g_type_set_qdata_full's destroy notifier should Py_DECREF it. Shouldn't matter too much in practice though, since the GTypes are likely to survive anyway.
Committed in revision 1030.