[Python-bugs-list] [ python-Bugs-563915 ] getttext defaults with unicode

noreply@sourceforge.net noreply@sourceforge.net
Thu, 13 Jun 2002 13:03:32 -0700


Bugs item #563915, was opened at 2002-06-03 11:09
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=563915&group_id=5470

Category: Unicode
Group: Python 2.2.1
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Rikard Anglerud (anglerud)
Assigned to: Barry A. Warsaw (bwarsaw)
Summary: getttext defaults with unicode

Initial Comment:
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

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

>Comment By: Barry A. Warsaw (bwarsaw)
Date: 2002-06-13 16:03

Message:
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.

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

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2002-06-04 11:54

Message:
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?

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

Comment By: M.-A. Lemburg (lemburg)
Date: 2002-06-04 05:35

Message:
Logged In: YES 
user_id=38388

Barry will know what to do...

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

Comment By: Martin v. Löwis (loewis)
Date: 2002-06-04 05:28

Message:
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 _.

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

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