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 serhiy.storchaka
Recipients barry, loewis, petri, serhiy.storchaka
Date 2017-06-18.11:35:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1497785752.52.0.56701471522.issue29755@psf.upfronthosting.co.za>
In-reply-to
Content
In Python 2 both gettext() and lgettext() are purposed to return 8-bit strings. The difference between them is only that gettext() encodes the translation back to the encoding of the translation file if the output encoding is not explicitly specified, while lgettext() encodes it to the preferred locale encoding. ugettext() returns Unicode strings.

In Python 3 ugettext() is renamed to gettext() and always returns Unicode strings. lgettext() should return a byte string, as in Python 2. The problem is that if the translation is not found, the untranslated message usually is returned, which is a Unicode string in Python 3. It should be encoded to a byte string, so that lgettext() always returns the same type -- bytes.

PR 2266 fixes lgettext() and related functions, updates the documentation, and adds tests.

Frankly, the usefulness of lgettext() in Python 3 looks questionable to me. gettext() can be used instead, with explicit encoding the result to the desired charset.
History
Date User Action Args
2017-06-18 11:35:52serhiy.storchakasetrecipients: + serhiy.storchaka, loewis, barry, petri
2017-06-18 11:35:52serhiy.storchakasetmessageid: <1497785752.52.0.56701471522.issue29755@psf.upfronthosting.co.za>
2017-06-18 11:35:52serhiy.storchakalinkissue29755 messages
2017-06-18 11:35:52serhiy.storchakacreate