GNOME Bugzilla – Bug 698473
Scanner converts g_iconv function name to empty string
Last modified: 2018-01-24 18:29:27 UTC
(not sure if the Version: field is correct, the RPM I'm using is gobject-introspection-1.34.2-1.fc18.x86_64) The pygobject glib bindings have a weird quirk: >>> from gi.repository import GLib >>> print dir(GLib.IConv) ['', '__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__gtype__', '__hash__', '__info__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'close'] Notice the first parameter in the output is '', which is not a valid variable name. I reported this on python-hackers-list, Simon Feltman responded: > Funny, it looks like this is caused by the function named "g_iconv". GI is > stripping iconv off to get rid of the class name on the method and there is > nothing left. I would log this as a GLib bug which specifies the method should > have a "Rename to:" annotation to something like "g_iconv_convert" or > "g_iconv_iconv". The GI scanner should probably at least warn when this kind > of thing happens because g_base_info_get_name is returning the empty string. I figure the scanner could do one better, and if it detects cases like this, it will just fix up the function name into g_FOO_FOO or something similar.
Even if the GI tools automatically do the naming, I still think a warning should be given. Basically this is an edge case and some amount of explicit attention and involvement/awareness from C API developer is always a good thing in these situations. I'm a fan of instructional warnings/errors with links to relevant information: Warning: g_iconv will be translated to GLib.IConv.iconv, use an "Rename to:" annotation to remove this warning. See: https://bugzilla.gnome.org/show_bug.cgi?id=698473
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]
GIConv is a struct, and g_iconv() is not introspectable due to its memory management semantics; in any case, g-i turns g_iconv() into GLib.iconv(): ``` Python 3.6.3 (default, Oct 9 2017, 12:07:10) [GCC 7.2.1 20170915 (Red Hat 7.2.1-2)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from gi.repository import GLib >>> print(GLib.iconv) gi.FunctionInfo(iconv) >>> print(GLib.IConv.iconv) Traceback (most recent call last):
+ Trace 238366
```