[New-bugs-announce] [issue29755] python3 gettext.lgettext sometimes returns bytes, not string
Petri Savolainen
report at bugs.python.org
Wed Mar 8 04:17:48 EST 2017
New submission from Petri Savolainen:
On Debian stable (Python 3.4), with the LANGUAGE environment variable set to "C" or "en_US.UTF-8", the following produces a string:
d = gettext.textdomain('apt-listchanges')
print(gettext.lgettext("Informational notes"))
However, setting the language, for example fi_FI.UTF-8, it will output a bytes object. Same apparently happens with some other languages, too.
Why is this? The discrepancy is not documented anywhere, AFAIK. Is this a bug or intended behavior depending on some (undocumented) circumstances? Given both the above examples define UTF-8 as the encoding, the result value does not depend directly on the encoding.
The docs say lgettext should merely return the translation in a particular encoding. It does not say the return value will be switched from a string to bytes as well.
I saw this originally in the Debian bug tracker and thought the issue merits at least clarification here as well (link to Debian bug below for reference).
(https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=818728)
No idea if this happens on Python > 3.4 or another platforms. I would guess so, but have not had time to confirm.
----------
messages: 289220
nosy: petri
priority: normal
severity: normal
status: open
title: python3 gettext.lgettext sometimes returns bytes, not string
type: behavior
versions: Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29755>
_______________________________________
More information about the New-bugs-announce
mailing list