summaryrefslogtreecommitdiffstats
path: root/gi
diff options
context:
space:
mode:
authorSimon van der Linden <svdlinden@src.gnome.org>2009-11-26 23:50:54 +0100
committerSimon van der Linden <svdlinden@src.gnome.org>2009-11-27 22:17:13 +0100
commit076ba3156c13375a75983cef7a409c8c8afea119 (patch)
tree172371d65b4bdc8e596d7ca779a4c0ed43f16b11 /gi
parentac80e64c9f7d257865aa820753e52d56cf2871c8 (diff)
downloadpygi-076ba3156c13375a75983cef7a409c8c8afea119.tar.gz
pygi-076ba3156c13375a75983cef7a409c8c8afea119.tar.xz
pygi-076ba3156c13375a75983cef7a409c8c8afea119.zip
Fix members initialization in metaclasses
In metaclasses, the test for the name of the class was wrong, since it prevented one to create a subclass with the same name (especially annoying for overrides). Now, if a GType is available from the info, the fact that it doesn't have any wrapper yet means that the metaclass is creating the base class, which will be registerd just after its creation. This is true for objects, and for structures registered as boxed or pointer too. This patch includes a test for basic subclassing in Python. It notably tests that methods don't get overridden by the metaclass.
Diffstat (limited to 'gi')
-rw-r--r--gi/types.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/gi/types.py b/gi/types.py
index e32bb72..87dbe16 100644
--- a/gi/types.py
+++ b/gi/types.py
@@ -116,7 +116,7 @@ class GObjectMeta(gobject.GObjectMeta, MetaClassHelper):
super(GObjectMeta, cls).__init__(name, bases, dict_)
# Avoid touching anything else than the base class.
- if cls.__name__ != cls.__info__.get_name():
+ if cls.__info__.get_g_type().pytype is not None:
return;
cls._setup_methods()
@@ -157,7 +157,8 @@ class StructMeta(type, MetaClassHelper):
super(StructMeta, cls).__init__(name, bases, dict_)
# Avoid touching anything else than the base class.
- if cls.__name__ != cls.__info__.get_name():
+ g_type = cls.__info__.get_g_type()
+ if g_type != gobject.TYPE_INVALID and g_type.pytype is not None:
return;
cls._setup_fields()