Author tomcato
Recipients
Date 2006-05-31.11:52:05
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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
History
Date User Action Args
2007-08-23 14:40:20adminlinkissue1498146 messages
2007-08-23 14:40:20admincreate