[pygobject/2.28] Fix ABI break in old static bindings.



commit cc0e8423f36486d15f751bd3c14351edda28538d
Author: Steve Frécinaux <code istique net>
Date:   Mon Apr 4 21:12:18 2011 +0200

    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

 gi/types.py         |    9 +++++++++
 gobject/__init__.py |   16 +++++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/gi/types.py b/gi/types.py
index 9b250b1..210fdc1 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 1858d18..a9522a6 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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]