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 698473 - Scanner converts g_iconv function name to empty string
Scanner converts g_iconv function name to empty string
Status: RESOLVED OBSOLETE
Product: gobject-introspection
Classification: Platform
Component: g-ir-scanner
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2013-04-20 20:45 UTC by Cole Robinson
Modified: 2018-01-24 18:29 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Cole Robinson 2013-04-20 20:45:11 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.
Comment 1 Simon Feltman 2013-04-23 02:30:48 UTC
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
Comment 2 André Klapper 2015-02-07 17:11:06 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]
Comment 3 Emmanuele Bassi (:ebassi) 2018-01-24 18:29:27 UTC
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):
  • File "<stdin>", line 1 in <module>
AttributeError: type object 'IConv' has no attribute 'iconv'
```