This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: optparse: OptionParser.__init__'s "prog" argument ignored
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fdrake Nosy List: fdrake, quiver, yuurei
Priority: normal Keywords:

Created on 2003-11-28 23:48 by yuurei, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg19169 - (view) Author: Paul Mueller (yuurei) Date: 2003-11-28 23:48
optparse uses sys.argv[0] for the program name even if
you supply the   
prog argument to OptionParser.__init__

ie, if you have p = OptionParser(prog='NEW_NAME'),
p.print_usage, p.print_help, p.error, etc. don't use
NEW_NAME as %prog.

This is with Python 2.3.2
msg19170 - (view) Author: George Yoshida (quiver) (Python committer) Date: 2003-12-01 06:06
Logged In: YES 
user_id=671362

I've submitted a patch.
See : http://www.python.org/sf/851902

Please apply the patch and check if "prog" argument 
works.
msg19171 - (view) Author: Paul Mueller (yuurei) Date: 2003-12-01 17:33
Logged In: YES 
user_id=908814

The patch works perfectly.

Thank you.
msg19172 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2004-04-01 07:54
Logged In: YES 
user_id=3066

Unfortunately, the patch breaks some of the existing tests
for optparse.  I've committed a fix that doesn't require
changing the existing tests and that adds new tests so this
doesn't break in the future.

Fixed for Python 2.3.4 and 2.4:

Lib/optparse.py  1.8, 1.5.8.2
Lib/test/test_optparse.py  1.3, 1.2.8.2
History
Date User Action Args
2022-04-11 14:56:01adminsetgithub: 39621
2003-11-28 23:48:09yuureicreate