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.

classification
Title: getttext defaults with unicode
Type: Stage:
Components: Unicode Versions: Python 2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: barry Nosy List: anglerud, barry, lemburg, loewis
Priority: normal Keywords:

Created on 2002-06-03 15:09 by anglerud, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (5)
msg11041 - (view) Author: Rikard Anglerud (anglerud) Date: 2002-06-03 15:09
When using gettext, and a token is not translated, for
example:
print _('Foo')
the output will be 'Foo', as expected. 
However, if that entry is:
print _(u'Foo')
we get:
Traceback (most recent call last):
  File "./translation.py", line 12, in ?
    print _(u'Foo')
  File "/usr/lib/python2.2/gettext.py", line 195, in
ugettext
    return unicode(tmsg, self._charset)
TypeError: decoding Unicode is not supported
msg11042 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-06-04 09:28
Logged In: YES 
user_id=21627

I'm not sure this is a bug: they keys in a message catalog
are really byte strings. So it is an error to use Unicode
strings as arguments to _.
msg11043 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2002-06-04 09:35
Logged In: YES 
user_id=38388

Barry will know what to do...
msg11044 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2002-06-04 15:54
Logged In: YES 
user_id=12800

I agree with Martin, you shouldn't be passing unicode
strings to ugettext().  I don't think it's worth doing a
type test in ugettext(); maybe we simply need to improve the
documentation?
msg11045 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2002-06-13 20:03
Logged In: YES 
user_id=12800

I will shortly post a patch that clarifies the documentation
to describe the GNU gettext recommendation that the source
message string should be us-ascii.  As that fixes things in
my mind, I'm closing this bug report.
History
Date User Action Args
2022-04-10 16:05:23adminsetgithub: 36692
2002-06-03 15:09:40anglerudcreate