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.

Author Sean.Wang
Recipients Sean.Wang, akuchling, aronacher, ash, bethard, eric.araujo, ezio.melotti, gward, ivilata, loewis, sampablokuper, vstinner
Date 2016-01-21.08:01:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1453363296.52.0.208084180874.issue2931@psf.upfronthosting.co.za>
In-reply-to
Content
This bug still exists in Python 2.7.10 with optparse version 1.5.3.
When the default_value is not ASCII encoded, it would raise `UnicodeEncodeError: 'ascii' codec can't encode characters`

this error is due to the `str` usage in `expand_default` method:

    def expand_default(self, option):
        if self.parser is None or not self.default_tag:
            return option.help

        default_value = self.parser.defaults.get(option.dest)
        if default_value is NO_DEFAULT or default_value is None:
            default_value = self.NO_DEFAULT_VALUE

        return option.help.replace(self.default_tag, str(default_value))
History
Date User Action Args
2016-01-21 08:01:36Sean.Wangsetrecipients: + Sean.Wang, loewis, akuchling, gward, bethard, ivilata, vstinner, aronacher, ezio.melotti, ash, eric.araujo, sampablokuper
2016-01-21 08:01:36Sean.Wangsetmessageid: <1453363296.52.0.208084180874.issue2931@psf.upfronthosting.co.za>
2016-01-21 08:01:36Sean.Wanglinkissue2931 messages
2016-01-21 08:01:36Sean.Wangcreate