After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 671218 - Unable to bind libguestfs api inspect_get_type
Unable to bind libguestfs api inspect_get_type
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2012-03-02 15:48 UTC by mbooth
Modified: 2015-02-07 16:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Source and generated .gir for libguestfs gobject bindings (87.30 KB, application/x-xz)
2012-03-02 15:48 UTC, mbooth
  Details
Proposed fix (3.47 KB, patch)
2012-03-05 17:11 UTC, mbooth
none Details | Review
Patch V2 (13.36 KB, patch)
2012-03-06 13:53 UTC, mbooth
committed Details | Review

Description mbooth 2012-03-02 15:48:52 UTC
Created attachment 208860 [details]
Source and generated .gir for libguestfs gobject bindings

I have written a gobject binding for libguestfs. I've attached the binding source  .gir file to this bug. The binding is automatically generated due to the size of the libguestfs api, .

Libguestfs contains an api called inspect_get_type(), which is not bound correctly by gobject introspection. This appears to be the only api which is not bound correctly. Looking at the generated XML, I see:

    <function name="session_inspect_get_type"
              c:identifier="guestfs_session_inspect_get_type"
              throws="1">

whereas the very similar inspect_get_arch() generates:

      <method name="inspect_get_arch"
              c:identifier="guestfs_session_inspect_get_arch"
              throws="1">

and is correctly handled as a method of the Session class.

I assume that the problem with this particular api is that its name ends in _get_type(). As this is a binding for an existing library it is not possible to change the name without introducing an inconsistency.
Comment 1 mbooth 2012-03-05 16:12:02 UTC
The immediate cause here is MainTransformer._pair_function(), which is responsible for mapping functions to classes. It aborts matching on guestfs_session_inspect_get_type because it ends in _get_type:

    def _pair_function(self, func):
        """Check to see whether a toplevel function should be a
method or constructor of some type."""
        if (func.symbol.endswith('_get_type')
            or func.symbol.endswith('_get_gtype')
            or func.symbol.startswith('_')):
            return
Comment 2 mbooth 2012-03-05 17:11:55 UTC
Created attachment 209016 [details] [review]
Proposed fix

This patch works for me. However, please review it carefully because I'm not familiar with either this codebase or Python.
Comment 3 Johan (not receiving bugmail) Dahlin 2012-03-05 17:58:08 UTC
Comment on attachment 209016 [details] [review]
Proposed fix

The patch looks good, but it needs a testsuite. Adding the one you ran into would be a good candidate, to verify that it actually works.
Comment 4 mbooth 2012-03-06 13:53:29 UTC
Created attachment 209086 [details] [review]
Patch V2

This updated patch includes the requested test. It also fixes a bug in the previous patch which broke the warning for methods called *_get_type() which didn't return GType.
Comment 5 Johan (not receiving bugmail) Dahlin 2012-03-06 14:36:24 UTC
Review of attachment 209086 [details] [review]:

You didn't have to add a new so/gir/ch set, you could have reused the existing one, but this looks great.
Comment 6 mbooth 2012-03-06 14:43:08 UTC
Actually my first version did re-use an existing set. I switched to adding a new one because I had to disable --warn-error, and I didn't want to disable it more widely than necessary.

I'm not familiar with this project. Is there anything else I need to do to ensure the patch makes it upstream?
Comment 7 André Klapper 2015-02-07 16:57:13 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]