Commit 1c74aac7 authored by Carlos Ramos Carreño's avatar Carlos Ramos Carreño Committed by Jérome Perrin

Fix po_import behavior in Python 2.

Newer versions of polib accept only unicode strings in the
`pofile` function (because they check if they start by the decoded
version of the BOM).
I changed the `data` that is passed to `pofile` to be a unicode
string in Python 2 too. This seems to work locally in my old
version of polib, so that at least the old behavior should be
kept the same.
parent ceaefc40
...@@ -660,10 +660,7 @@ class MessageCatalog(LanguageManager, ObjectManager, SimpleItem): ...@@ -660,10 +660,7 @@ class MessageCatalog(LanguageManager, ObjectManager, SimpleItem):
messages = self._messages messages = self._messages
# Load the data # Load the data
if isinstance(data, bytes): # six.PY2 data = data.decode("utf-8")
pass
elif isinstance(data, bytes): # six.PY3
data = data.decode()
po = polib.pofile(data) po = polib.pofile(data)
encoding = to_str(po.encoding) encoding = to_str(po.encoding)
for entry in po: for entry in po:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment