New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optparse and non-ascii help strings #48569
Comments
(copied from the Optik bug tracker) Related bug: Hi all, It seems to me that the workaround to the above bug in optparse.py versio $ cat test.py
#!/usr/bin/env python
# -*- coding:latin-1 -*- import optparse
parser = optparse.OptionParser()
parser.add_option("--test",help="This does not work: é")
parser.parse_args() When called with "$ ./test.py --help", this script fails with the following $ ./test.py -h
Traceback (most recent call last):
File "./test.py", line 7, in <module>
parser.parse_args()
File "/usr/lib/python2.5/optparse.py", line 1385, in parse_args
stop = self._process_args(largs, rargs, values)
File "/usr/lib/python2.5/optparse.py", line 1429, in _process_args
self._process_short_opts(rargs, values)
File "/usr/lib/python2.5/optparse.py", line 1536, in _process_short_opts
option.process(opt, value, values, self)
File "/usr/lib/python2.5/optparse.py", line 782, in process
self.action, self.dest, opt, value, values, parser)
File "/usr/lib/python2.5/optparse.py", line 804, in take_action
parser.print_help()
File "/usr/lib/python2.5/optparse.py", line 1655, in print_help
file.write(self.format_help().encode(encoding, "replace"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 117:
ordinal not in range(128) This behaviour can be reproduced with utf-8 encoded strings as well. If I understand correctly, line 1655 of optparse.py only works if I think this is either a bug and should be fixed, or very misleading (and I hope to have helped even a little. Cheers, |
There's nothing to fix here, I think... There's no point in allowing IMHO, this issue should be closed. And see also bpo-2931 for remaining i18n |
While I think there is indeed an expectations bug here, I also think it is no longer worth fixing. argparse is the New Way, as is 3.x and its Strings. Closing as wont fix. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: