Hello, Sorry I cannot test it right now (my exaile instalation is on the different pc). But here is simple test for unicode and optparse:
davidov@theatre:~/tmp/optparse$ python test1.py --help Traceback (most recent call last): File "test1.py", line 7, in <module> (options, args) = parser.parse_args() File "/usr/lib/python2.6/optparse.py", line 1394, in parse_args stop = self._process_args(largs, rargs, values) File "/usr/lib/python2.6/optparse.py", line 1434, in _process_args self._process_long_opt(rargs, values) File "/usr/lib/python2.6/optparse.py", line 1509, in _process_long_opt option.process(opt, value, values, self) File "/usr/lib/python2.6/optparse.py", line 788, in process self.action, self.dest, opt, value, values, parser) File "/usr/lib/python2.6/optparse.py", line 810, in take_action parser.print_help() File "/usr/lib/python2.6/optparse.py", line 1664, in print_help file.write(self.format_help().encode(encoding, "replace")) UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 116: ordinal not in range(128) davidov@theatre:~/tmp/optparse$ python test2.py --help Usage: test2.py [options]
Options: -h, --help show this help message and exit -f FILE, --file=FILE файл
davidov@theatre:~/tmp/optparse$ diff -u test1.py test2.py --- test1.py 2010-03-02 12:44:32.639580195 +0300 +++ test2.py 2010-03-02 12:45:06.829555252 +0300 @@ -2,6 +2,6 @@ from optparse import OptionParser parser = OptionParser() parser.add_option("-f", "--file", dest="filename", - help="файл", metavar="FILE") + help=u"файл", metavar="FILE")
(options, args) = parser.parse_args()
So you have just to use unicode strings for uncode help messages; that seems not to be optparse bug.
Hello,
Sorry I cannot test it right now (my exaile instalation is on the different pc).
But here is simple test for unicode and optparse:
davidov@ theatre: ~/tmp/optparse$ python test1.py --help python2. 6/optparse. py", line 1394, in parse_args args(largs, rargs, values) python2. 6/optparse. py", line 1434, in _process_args _process_ long_opt( rargs, values) python2. 6/optparse. py", line 1509, in _process_long_opt process( opt, value, values, self) python2. 6/optparse. py", line 788, in process python2. 6/optparse. py", line 810, in take_action print_help( ) python2. 6/optparse. py", line 1664, in print_help write(self. format_ help(). encode( encoding, "replace")) theatre: ~/tmp/optparse$ python test2.py --help
Traceback (most recent call last):
File "test1.py", line 7, in <module>
(options, args) = parser.parse_args()
File "/usr/lib/
stop = self._process_
File "/usr/lib/
self.
File "/usr/lib/
option.
File "/usr/lib/
self.action, self.dest, opt, value, values, parser)
File "/usr/lib/
parser.
File "/usr/lib/
file.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 116: ordinal not in range(128)
davidov@
Usage: test2.py [options]
Options:
-h, --help show this help message and exit
-f FILE, --file=FILE файл
davidov@ theatre: ~/tmp/optparse$ diff -u test1.py test2.py add_option( "-f", "--file", dest="filename",
--- test1.py 2010-03-02 12:44:32.639580195 +0300
+++ test2.py 2010-03-02 12:45:06.829555252 +0300
@@ -2,6 +2,6 @@
from optparse import OptionParser
parser = OptionParser()
parser.
- help="файл", metavar="FILE")
+ help=u"файл", metavar="FILE")
(options, args) = parser.parse_args()
So you have just to use unicode strings for uncode help messages; that seems not to be optparse bug.