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 795008 - glib-mkenums breaks if option specified but no nick
glib-mkenums breaks if option specified but no nick
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks: 796051
 
 
Reported: 2018-04-05 17:23 UTC by Alexander Larsson
Modified: 2018-05-24 20:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Ignore other per value options than 'skip' and 'nick' (1.19 KB, patch)
2018-04-28 01:23 UTC, Peter Kjellerstedt
accepted-commit_now Details | Review
tests: Add initial test framework for glib-mkenums (16.57 KB, patch)
2018-05-02 12:58 UTC, Philip Withnall
needs-work Details | Review
tests: Add glib-mkenums test for missing nicks (1.50 KB, patch)
2018-05-02 12:58 UTC, Philip Withnall
none Details | Review

Description Alexander Larsson 2018-04-05 17:23:57 UTC
gegl has an enum like this:

typedef enum {
  GEGL_SAMPLER_NEAREST = 0,   /*< desc="nearest"      >*/
  GEGL_SAMPLER_LINEAR,        /*< desc="linear"       >*/
  GEGL_SAMPLER_CUBIC,         /*< desc="cubic"        >*/
  GEGL_SAMPLER_LOHALO         /*< desc="lohalo"       >*/
} GeglSamplerType;

I.e. it has an options field, but it doesn't specify the nick.
The new glib-mkenums crashes on this with:

Traceback (most recent call last):
  • File "/usr/bin/glib-mkenums", line 709 in <module>
    process_file(fname)
  • File "/usr/bin/glib-mkenums", line 505 in process_file
    parse_entries(curfile, curfilename)
  • File "/usr/bin/glib-mkenums", line 221 in parse_entries
    entries.append((name, value, options['nick']))
KeyError: 'nick'

Because apparently this code:

    if options is not None:
        options = parse_trigraph(options)
        if 'skip' not in options:
            entries.append((name, value, options['nick']))

Does not handle skip not being set, and nick being unset.

This should probably be options.get('nick', None) or something.
Comment 1 Peter Kjellerstedt 2018-04-28 01:23:41 UTC
Created attachment 371481 [details] [review]
Ignore other per value options than 'skip' and  'nick'

I stumbled upon this problem today, and made this patch before I went looking to see if anyone else had seen it too.
Comment 2 Peter Kjellerstedt 2018-04-28 01:28:07 UTC
The patch also applies to the 2.54 branch and the 2.56 branch, and should be applied there in addition to master.
Comment 3 Philip Withnall 2018-05-02 12:58:20 UTC
Review of attachment 371481 [details] [review]:

Seems reasonable, thanks. I’ve written some tests for it which I’ll attach for review shortly.
Comment 4 Philip Withnall 2018-05-02 12:58:48 UTC
Created attachment 371611 [details] [review]
tests: Add initial test framework for glib-mkenums

This allows running glib-mkenums with different C headers and checking
its output.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Comment 5 Philip Withnall 2018-05-02 12:58:58 UTC
Created attachment 371612 [details] [review]
tests: Add glib-mkenums test for missing nicks

This adds a test to verify the change from bug #795008.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Comment 6 Philip Withnall 2018-05-02 13:18:46 UTC
Review of attachment 371611 [details] [review]:

This needs autotools support, and needs tests for other historic glib-mkenums bugs to be added. The overall approach and framework is ready to review though.
Comment 7 GNOME Infrastructure Team 2018-05-24 20:21:08 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/1360.