After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 646437 - "metaclass hackery" no longer works with PyGObject-2.28
"metaclass hackery" no longer works with PyGObject-2.28
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: gobject
2.28.x
Other All
: Normal major
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2011-04-01 12:49 UTC by Dieter Verfaillie
Modified: 2011-04-08 21:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Traceback from the kiwi example as described above (1.13 KB, text/plain)
2011-04-01 12:51 UTC, Dieter Verfaillie
  Details
Traceback from the sqledit script as described above (1.83 KB, text/plain)
2011-04-01 12:51 UTC, Dieter Verfaillie
  Details
Fix ABI break in old static bindings. (2.62 KB, patch)
2011-04-04 19:13 UTC, Steve Frécinaux
committed Details | Review

Description Dieter Verfaillie 2011-04-01 12:49:58 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?
Comment 1 Dieter Verfaillie 2011-04-01 12:51:10 UTC
Created attachment 184867 [details]
Traceback from the kiwi example as described above
Comment 2 Dieter Verfaillie 2011-04-01 12:51:47 UTC
Created attachment 184868 [details]
Traceback from the sqledit script as described above
Comment 3 johnp 2011-04-01 21:19:34 UTC
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?
Comment 4 Steve Frécinaux 2011-04-04 19:13:58 UTC
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.
Comment 5 Steve Frécinaux 2011-04-04 19:25:49 UTC
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.
Comment 6 Dieter Verfaillie 2011-04-04 20:12:06 UTC
Thanks, tested your patch and it indeed works as expected :)
Comment 7 johnp 2011-04-04 21:15:50 UTC
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.
Comment 8 Dieter Verfaillie 2011-04-05 04:29:51 UTC
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.
Comment 9 Johan (not receiving bugmail) Dahlin 2011-04-05 16:28:55 UTC
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.
Comment 10 Tomeu Vizoso 2011-04-05 16:44:31 UTC
(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.
Comment 11 Dieter Verfaillie 2011-04-05 17:17:26 UTC
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.
Comment 12 Steve Frécinaux 2011-04-08 21:18:39 UTC
Attachment 185135 [details] pushed as cc0e842 - Fix ABI break in old static bindings.