GNOME Bugzilla – Bug 692633
Marshaling of non-local types does not import overrides
Last modified: 2013-01-29 06:44:11 UTC
This was found digging into bug 691185. When a method or property is accessed which returns a type that has not already been imported through gi.repository, overrides will never be imported for that type. This can be observed using Gst.ElementFactor.make without first importing the typelib for the type being returned (GstApp.AppSrc): >>> from gi.repository import Gst >>> Gst.init(None) >>> src = Gst.ElementFactory.make('appsrc', None) >>> type(src) gi.types.__main__.GstAppSrc vs: >>> from gi.repository import GstApp >>> from gi.repository import Gst >>> Gst.init(None) >>> src = Gst.ElementFactory.make('appsrc', None) >>> type(src) gi.repository.GstApp.AppSrc In the former case, if AppSrc has overrides, they will not be loaded. This is also happening with properties of type Enum: >>> from gi.repository import Gst >>> Gst.init(None) >>> src = Gst.ElementFactory.make('appsrc', None) >>> src.props.stream_type <enum GST_APP_STREAM_TYPE_STREAM of type GstAppStreamType> >>> from gi.repository import GstApp >>> src.props.stream_type = GstApp.AppStreamType.SEEKABLE AttributeError: type object 'GstAppStreamType' has no attribute 'SEEKABLE' The above messes up the GstApp.AppStreamType enum and it will not contain any values. However, importing GstApp before the property access will work.
This seems like an impossible thing to fix without GType having the ability to provide a namespace that matches the gi namespace. From the perspective of pygobject, we are getting back a GObject instance which I do not see a way to get back the namespace "GstApp". We could attempt to do something hacky like parse the type name breaking it up on capital letters and then attempt to import each variation. But that doesn't sound very reasonable.