diff -r cf70f030a744 Lib/gettext.py --- a/Lib/gettext.py Wed Jun 18 23:07:46 2014 -0400 +++ b/Lib/gettext.py Mon Jun 23 21:50:29 2014 +0300 @@ -308,7 +308,12 @@ elif lastk: self._info[lastk] += '\n' + item if k == 'content-type': - self._charset = v.split('charset=')[1] + try: + unicode + except NameError: + pass + else: + self._charset = v.split('charset=')[1] elif k == 'plural-forms': v = v.split(';') plural = v[1].split('plural=')[1] diff -r cf70f030a744 Lib/test/test_gettext.py --- a/Lib/test/test_gettext.py Wed Jun 18 23:07:46 2014 -0400 +++ b/Lib/test/test_gettext.py Mon Jun 23 21:50:29 2014 +0300 @@ -138,17 +138,18 @@ # Install the translation object t.install() eq(_('nudge nudge'), 'wink wink') - # Try unicode return type - t.install(unicode=True) - eq(_('mullusk'), 'bacon') - # Test installation of other methods - import __builtin__ - t.install(unicode=True, names=["gettext", "lgettext"]) - eq(_, t.ugettext) - eq(__builtin__.gettext, t.ugettext) - eq(lgettext, t.lgettext) - del __builtin__.gettext - del __builtin__.lgettext + if test_support.have_unicode: + # Try unicode return type + t.install(unicode=True) + eq(_('mullusk'), 'bacon') + # Test installation of other methods + import __builtin__ + t.install(unicode=True, names=["gettext", "lgettext"]) + eq(_, t.ugettext) + eq(__builtin__.gettext, t.ugettext) + eq(lgettext, t.lgettext) + del __builtin__.gettext + del __builtin__.lgettext class GettextTestCase2(GettextBaseTest): @@ -292,6 +293,7 @@ raises(ValueError, gettext.c2py, "os.chmod('/etc/passwd',0777)") +@test_support.requires_unicode class UnicodeTranslationsTest(GettextBaseTest): def setUp(self): GettextBaseTest.setUp(self)