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