summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Frécinaux <code@istique.net>2011-04-04 21:12:18 +0200
committerSteve Frécinaux <code@istique.net>2011-04-08 23:17:42 +0200
commitcc0e8423f36486d15f751bd3c14351edda28538d (patch)
tree176686b4f7de6fa73d53aea24cdab1fb0f9be8d6
parentb0e499744d337adc608e2aa8996469bca2df044a (diff)
downloadpygobject-cc0e8423f36486d15f751bd3c14351edda28538d.tar.gz
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. https://bugzilla.gnome.org/show_bug.cgi?id=646437
-rw-r--r--gi/types.py9
-rw-r--r--gobject/__init__.py16
2 files changed, 18 insertions, 7 deletions
diff --git a/gi/types.py b/gi/types.py
index 9b250b16..210fdc1c 100644
--- a/gi/types.py
+++ b/gi/types.py
@@ -232,6 +232,15 @@ class GObjectMeta(gobject.GObjectMeta, MetaClassHelper):
def mro(cls):
return mro(cls)
+ def _must_register_type(cls, namespace):
+ ## don't register the class if already registered
+ if '__gtype__' in namespace:
+ return False
+
+ # Do not register a new GType for the overrides, as this would sort of
+ # defeat the purpose of overrides...
+ return not cls.__module__.startswith('gi.overrides.')
+
def mro(C):
"""Compute the class precedence list (mro) according to C3
diff --git a/gobject/__init__.py b/gobject/__init__.py
index 1858d188..a9522a63 100644
--- a/gobject/__init__.py
+++ b/gobject/__init__.py
@@ -101,17 +101,19 @@ class GObjectMeta(type):
prop.setter(self, value)
cls.do_set_property = obj_set_property
- def _type_register(cls, namespace):
+ def _must_register_type(cls, namespace):
## don't register the class if already registered
if '__gtype__' in namespace:
- return
+ return False
- # Do not register a new GType for the overrides, as this would sort of
- # defeat the purpose of overrides...
- if cls.__module__.startswith('gi.overrides.'):
- return
+ return ('__gproperties__' in namespace or
+ '__gsignals__' in namespace or
+ '__gtype_name__' in namespace)
+
+ def _type_register(cls, namespace):
+ if cls._must_register_type(namespace):
+ type_register(cls, namespace.get('__gtype_name__'))
- type_register(cls, namespace.get('__gtype_name__'))
_gobject._install_metaclass(GObjectMeta)
del _gobject