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 564070 - Cannot use GOptionGroup raw wrappers with glib.option.OptionParser
Cannot use GOptionGroup raw wrappers with glib.option.OptionParser
Status: RESOLVED OBSOLETE
Product: pygobject
Classification: Bindings
Component: general
Git master
Other Linux
: Normal major
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2008-12-11 06:18 UTC by Laszlo Pandy
Modified: 2018-01-10 19:58 UTC
See Also:
GNOME target: ---
GNOME version: 2.23/2.24


Attachments
Remove the offending code; as far as i can tell the parsing works perfectly without it. (909 bytes, patch)
2009-02-14 00:22 UTC, Laszlo Pandy
needs-work Details | Review
Test case (192 bytes, text/x-python)
2012-04-21 12:04 UTC, Sebastian Pölsterl
  Details

Description Laszlo Pandy 2008-12-11 06:18:55 UTC
$ python -c "import gobject, gstoption; a = gobject.option.OptionParser(); a.add_option_group(gstoption.get_group()); a.parse_args()"

Traceback (most recent call last):
  • File "<string>", line 1 in <module>
  • File "/var/lib/python-support/python2.5/gtk-2.0/glib/option.py", line 344 in parse_args
    for key, value in group.values.__dict__.items():
AttributeError: 'glib.OptionGroup' object has no attribute 'values'

It seems adding a glib option group (as opposed to a purely Python OptParse group) causes an attribute error when parsing args.
Comment 1 Laszlo Pandy 2009-02-14 00:22:41 UTC
Created attachment 128697 [details] [review]
Remove the offending code; as far as i can tell the parsing works perfectly without it.
Comment 2 Paul Pogonyshev 2009-04-23 17:03:47 UTC
What is gstoption?  Can you provide an example without additional dependencies?
Comment 3 Laszlo Pandy 2009-04-23 17:16:10 UTC
Gstoption is the goption group for GStreamer's python bindings. The GOption system in python uses two types of groups internally. Any options which are defined in Python will create a optparse group. Any GOption which is defined in C code will be of the type glib.OptionGroup.

The python bindings for GOption allow both these types of groups to be used simultaneously, and it works fine with optparse groups. However it fails with this error for glib.OptionGroup types. Since anything created in Python will be an optparse group, I believe you must use a C module such as gstoption to create a glib.OptionGroup type.

Therefore I do not know if it is possible to create an example without an extra dependency, but I will investigate this.
Comment 4 Leo Singer 2010-08-19 22:23:48 UTC
I have a gst-python application that has several command line options, so I've come across this issue as well.

(In reply to comment #2)
> What is gstoption?  Can you provide an example without additional dependencies?

Laszlo's example generalizes to any glib.OptionGroup (of which gstoption.get_group() returns an instance).  So the following example produces an almost identical traceback:

$ python -c "import gobject, glib; a = gobject.option.OptionParser();a.add_option_group(glib.OptionGroup('foo', 'bar', 'bat', None)); a.parse_args()"

Traceback (most recent call last):
  • File "<string>", line 1 in <module>
  • File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/gtk-2.0/glib/option.py", line 344 in parse_args
    for key, value in group.values.__dict__.items():
AttributeError: 'glib.OptionGroup' object has no attribute 'values'

Has Laszlo's patch been tested?  Does it work?
Comment 5 Simon van der Linden 2011-01-01 18:56:43 UTC
Review of attachment 128697 [details] [review]:

::: glib/option.py
@@ -343,3 @@
-        for group in self.option_groups:
-            for key, value in group.values.__dict__.items():
-                options.ensure_value(key, value)

Removing this breaks support for glib.option.OptionGroup. This loop merges the values of each group into options.

Instead of removing it, a guard may be added to support GOptionGroup raw wrappers.
Comment 6 Sebastian Pölsterl 2012-04-21 12:04:43 UTC
Created attachment 212495 [details]
Test case

This bug is still applies with latest pygobject. As it used deprecated optparse module, we should move to argparse as well.
Comment 7 GNOME Infrastructure Team 2018-01-10 19:58:04 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/pygobject/issues/2.