# HG changeset patch # User fschwarz # Date 1300564221 0 # Node ID bf8b876cb8c78c8b8ab2e8f013a3bc3b68e73b03 # Parent b33c36615fe9a8da67c2d1b2cc6654e279aedfc4 babel.messages.pofile should only apply encoding when actually writing a file (eases Python 3 transition, closes #251) diff --git a/babel/messages/pofile.py b/babel/messages/pofile.py --- a/babel/messages/pofile.py +++ b/babel/messages/pofile.py @@ -382,12 +382,11 @@ updating the catalog """ def _normalize(key, prefix=''): - return normalize(key, prefix=prefix, width=width) \ - .encode(catalog.charset, 'backslashreplace') + return normalize(key, prefix=prefix, width=width) def _write(text): if isinstance(text, unicode): - text = text.encode(catalog.charset) + text = text.encode(catalog.charset, 'backslashreplace') fileobj.write(text) def _write_comment(comment, prefix=''):