GNOME Bugzilla – Bug 646437
"metaclass hackery" no longer works with PyGObject-2.28
Last modified: 2011-04-08 21:18:43 UTC
commit 84d6142c14a7ebfb7284d3db52e14d3393f93905 (Always register a new GType when a GObject class is subclassed) breaks the more advanced usage of PyGObject with regards to "metaclass hackery" as used in for example the kiwi and sqlkit projects. I'll attach a traceback from the example at http://www.async.com.br/projects/kiwi/example-personalinformation.html and from the sqledit script as installed by sqlkit. Reverting the above patch fixes this, but I understand it causes other problems in the gi related parts of PyGObject?
Created attachment 184867 [details] Traceback from the kiwi example as described above
Created attachment 184868 [details] Traceback from the sqledit script as described above
Ya, that should have been backed out as it is an ABI change. Too late for the GNOME 3 release but we should revert it in the 2-28 branch for the next point release. Is there a way to fix the hackery for future releases? I see the value in the patch. Perhaps we should have a __delay_gtype_register__ or something?
Created attachment 185135 [details] [review] Fix ABI break in old static bindings. Commit 84d6142c14a7ebfb7284d3db52e14d3393f93905 (Always register a new GType when a GObject class is subclassed) breaks the more advanced usage of PyGObject with regards to "metaclass hackery" as used in for example the kiwi and sqlkit projects. But the users of the gi-based bindings now rely on the new behaviour. We fix this by restraining the systematical registering of new types to the new gi-based bindings, leaving the old pygtk ones untouched.
Ok, so the above patch should fix the issues you encountered with pygtk, while retaining the behaviour for the gi-based bindings. It effectively reverts the commit 84d6142c14a7ebfb7284d3db52e14d3393f93905 for what pygtk and co are concerned. If it doesn't fix all your issues, then the problem is something else. For the gi-enabled future of kiwi, I'd suggest you to override the _type_register() method, which would allow you to do whatever you want between the initialization of the metaclass and the proper type registration. Think of it as a signal.
Thanks, tested your patch and it indeed works as expected :)
Dieter, Are there plans to port kiwi to pygi? In which case your metaclass hackery might not work. We should figure out a way forward if this is the case.
I'm but a humble user of parts of kiwi's code, so that's most likely a question for Johan Dahlin or Christian Reis to answer. Note there hasn't been much activity on kiwi lately (last release was 2 years ago), but the parts of it that allow properties and signals for GObject sublasses to be defined in mixin classes remain enormously helpful for larger projects.
Dieter: we're releasing new versions of Kiwi every couple of weeks, but they're only available though a ppa in launchpad: https://launchpad.net/~stoq-dev/+archive/lancamentos I'm currently working on Kiwi and I'm not going to consider porting it until a stable release of Ubuntu is made with Gtk+-3.0, which we'll be 11.10 at earliest. We've had reports from people using our software on Ubuntu 11.04 that it breaks, it would be appreciated if this could be reverted for the 2.28 bindings.
(In reply to comment #5) > > For the gi-enabled future of kiwi, I'd suggest you to override the > _type_register() method, If we are going to support that, we should add proper public API for it or people's code will break in later releases.
Johan: thanks for the information, looks like I've got some catching up to do! Btw, was keeping an eye on http://www.async.com.br/projects/kiwi/getit.html and http://pypi.python.org/pypi/kiwi-gtk/ and never noticed development of kiwi moved to launchpad. Steve's patch (see comment 4), applied to the pygobject-2-28 branch fixes kiwi's utils.py (PropertyObject/gproperty/gsingal) but I've only tested it on Windows. Judging from the traceback reported on http://bugs.async.com.br/show_bug.cgi?id=4279 Steve's patch should also fix it for people using Ubuntu.
Attachment 185135 [details] pushed as cc0e842 - Fix ABI break in old static bindings.