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 425847 - Silently overrides some functions of default module optparse
Silently overrides some functions of default module optparse
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-python
git master
Other Linux
: Normal normal
: 0.10.9
Assigned To: Johan (not receiving bugmail) Dahlin
GStreamer Maintainers
Depends on: 492701
Blocks:
 
 
Reported: 2007-04-03 12:45 UTC by Luca Bruno
Modified: 2012-05-20 18:16 UTC
See Also:
GNOME target: ---
GNOME version: 2.15/2.16


Attachments
patch (3.95 KB, patch)
2007-11-02 14:06 UTC, Johan (not receiving bugmail) Dahlin
none Details | Review
v2: with pygobject version check (5.73 KB, patch)
2007-11-05 17:44 UTC, Johan (not receiving bugmail) Dahlin
committed Details | Review

Description Luca Bruno 2007-04-03 12:45:57 UTC
Please describe the problem:
gst-python seems to influence the behaviour of optparse.OptionParser() when invoke with --help.
Doing and `import gst` in a python program using optparse will cause all help text to be displayed like this:

Usage:
  istanbul [OPTION...] - GStreamer initialization

Help Options:
  -?, --help                      Show help options
  --help-all                      Show all help options
  --help-gst                      Show GStreamer Options

Application Options:

If you import gst after parsing the arguments, all works fine, displaying original help text.
This bug is being worked around in many applications (like istanbul and jokosher) just postponing `import gst`, but it would be better fixed directly in gst-python 

Steps to reproduce:
1. import gst, optparse
2. implement optparse.OptionParser()
3. launch your app with --help
4. try again without importing gst to see the difference


Actual results:
steps 1,2,3: a fixed help text which says:

Usage:
  istanbul [OPTION...] - GStreamer initialization

Help Options:
  -?, --help                      Show help options
  --help-all                      Show all help options
  --help-gst                      Show GStreamer Options

Application Options:

Expected results:
the same as step 4: see my custom help text :).

Does this happen every time?
Yes

Other information:
Comment 1 René Stadler 2007-04-03 14:40:14 UTC
The problem is unrelated to optparse though.  Consider this simple example session:

>>> import sys
>>> sys.argv.append ("--help")
>>> import pygst; pygst.require ("0.10"); import gst
Usage:
  . [OPTION...] - GStreamer initialization

Help Options:
  -?, --help                      Show help options
  --help-all                      Show all help options
  --help-gst                      Show GStreamer Options

Application Options:


The problem is that the gst module does not act like library.  Instead, it performs the I'm-a-simple/stupid-program procedure by calling gst_init_check.
Comment 2 Johan (not receiving bugmail) Dahlin 2007-11-02 12:23:55 UTC
I can confirm this.

The problem is that when you do "import gst" in your program the python bindings will parse the command line arguments using GOption internally so you will not have a chance to hook in your own arguments with the ones provided by GStreamer.
Comment 3 Johan (not receiving bugmail) Dahlin 2007-11-02 14:06:16 UTC
Created attachment 98377 [details] [review]
patch

Here is a way to solve this. The patch includes an example.
This depends on bug 492701.
Comment 4 Johan (not receiving bugmail) Dahlin 2007-11-05 17:44:48 UTC
Created attachment 98578 [details] [review]
v2: with pygobject version check
Comment 5 Johan (not receiving bugmail) Dahlin 2007-11-08 10:51:49 UTC
2007-11-05  Johan Dahlin  <johan@gnome.org>

	* gstoptionmodule.c:
	* Makefile.am:
	* configure.ac:
	Add a new module, gstoption which allows you to fetch the
	GOptionGroup from gstreamer without initializing and parsing
	the command line arguments. Requires PyGObject 2.15.0
	Fixes #425847
	
	* examples/option-parser.py (main): Example
Comment 6 Laszlo Pandy 2008-06-01 16:03:51 UTC
Would it be possible to remove the automatic parsing behaviour from gstreamer, so our programs can import gst at the top of the file, instead of delaying it? It would really be nice to not have to work around this, and be able to do gst.get_group(), but maybe this is a backwards compatibility issue.

Btw, is there any documentation/example for getting the option group from gtk?
Comment 7 Derek Kulinski 2012-04-16 07:08:18 UTC
This bug is still not fixed. Can we make pygst to not parse options (best) or at least not have to hack around by putting import gst after parsing?
Comment 8 Adrian Sampson 2012-05-20 18:16:52 UTC
I can confirm that this is not fixed. The gstreamer module should only parse options if specifically asked to do so.