changeset 547:bf8b876cb8c7

babel.messages.pofile should only apply encoding when actually writing a file (eases Python 3 transition, closes #251)
author fschwarz
date Sat, 19 Mar 2011 19:50:21 +0000
parents b33c36615fe9
children 59db0f962e00
files babel/messages/pofile.py
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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=''):
Copyright (C) 2012-2017 Edgewall Software