[ python-Bugs-1498146 ] optparse does not hande unicode help strings

SourceForge.net noreply at sourceforge.net
Sat Jun 3 22:28:12 CEST 2006


Bugs item #1498146, was opened at 2006-05-31 07:52
Message generated for change (Settings changed) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1498146&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Unicode
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Tom Cato Amundsen (tomcato)
>Assigned to: Greg Ward (gward)
Summary: optparse does not hande unicode help strings

Initial Comment:
Unicode strings with non-ascii chars in generate a
UnicodeEncodeError

  File "/usr/lib/python2.3/optparse.py", line 1370, in
print_help
    file.write(self.format_help())
UnicodeEncodeError: 'ascii' codec can't encode
characters in position 200-202:
+ordinal not in range(128)

I'm subclassing OptionParser and adds the following
method to get it to work. Should something like this be
done for python 2.5?

def print_help(self, file=None):
    if file is None:
        file = sys.stdout
    file.write(self.format_help().encode(file.encoding,
'replace'))


Tom Cato

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1498146&group_id=5470


More information about the Python-bugs-list mailing list