Python: get_structure() API change?

Users of Mopidy running with GStreamer 1.26.2 are having issues with our long-working code to extract details from the caps in messages:

        elif msg.type == Gst.MessageType.APPLICATION:
            if msg.get_structure().get_name() == "have-type":
                mime = msg.get_structure().get_value("caps").get_name()

Users with GStreamer 1.26.2 are now getting

AttributeError: 'StructureWrapper' object has no attribute 'get_name'

I can see that python: Fix pulling events from appsink (!9148) · Merge requests · GStreamer / gstreamer · GitLab is related but I’m not sure what we should be doing. I couldn’t find anything in the 1.26.x release notes about this. Was this an accidental API breakage that we need a temporary (realistically, semi-permanent) workaround/hack for, or should we need to change more of our codeto support this going forward? We have to support a wide range of GStreamer versions so we need something compatible for how it used to work also.

I think it was an accidental breakage that should hopefully be fixed in 1.26.3 which is due this week.

If you can get someone to test the MR or the tip of the 1.26 branch to make sure it’s fixed that’d be great.

To get the underlying structure instead of the wrapper you can write get_structure()._StructureWrapper__structure.get_name. I don’t know if that is fixed in the later versions, but the above workaround patched the problem for me.

Sorry for the delay, yes it looks to be fixed. Thanks. We’ll add a helper function to access the name which will try both ways as required. We have some places where we pass messages by creating a Structure with Gst.Structure.new_empty("foo") and send it as an Application message. When we later read these, regardless of the Gst version they are obviously Structure types, not StructureWrapper types like the other places in our event handler. So our helper can’t just look at the Gst version, we have to try the “old way”, and if that fails we fall-back to the context manager method. And that’s fine.