# HG changeset patch # User fschwarz # Date 1300564221 0 # Node ID 12d5425fb4300b40bfed46d74daefd9d488d553d # Parent dde86441b508aa9541a22a6ae320e7dfe5f441a7 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=''):