Make gettext work with strict str/bytes.

This commit is contained in:
Guido van Rossum 2007-08-29 03:08:55 +00:00
parent 83800a6578
commit 9600f93db6
1 changed files with 3 additions and 3 deletions

View File

@ -292,7 +292,7 @@ class GNUTranslations(NullTranslations):
if mlen == 0: if mlen == 0:
# Catalog description # Catalog description
lastk = k = None lastk = k = None
for b_item in tmsg.split(os.linesep): for b_item in tmsg.split(os.linesep.encode("ascii")):
item = str(b_item).strip() item = str(b_item).strip()
if not item: if not item:
continue continue
@ -321,8 +321,8 @@ class GNUTranslations(NullTranslations):
# if the Unicode conversion fails. # if the Unicode conversion fails.
if b'\x00' in msg: if b'\x00' in msg:
# Plural forms # Plural forms
msgid1, msgid2 = msg.split('\x00') msgid1, msgid2 = msg.split(b'\x00')
tmsg = tmsg.split('\x00') tmsg = tmsg.split(b'\x00')
if self._charset: if self._charset:
msgid1 = str(msgid1, self._charset) msgid1 = str(msgid1, self._charset)
tmsg = [str(x, self._charset) for x in tmsg] tmsg = [str(x, self._charset) for x in tmsg]