diff bitten/upgrades.py @ 519:384e59137bf8

Support unicode by converting everything to UTF-8 on write and back to unicode on read - should fix #369
author dfraser
date Fri, 13 Mar 2009 14:52:51 +0000
parents 18485105d1c3
children b661ea254972
line wrap: on
line diff
--- a/bitten/upgrades.py
+++ b/bitten/upgrades.py
@@ -15,6 +15,7 @@
 import sys
 
 from trac.db import DatabaseManager
+from trac.util.text import to_unicode
 
 __docformat__ = 'restructuredtext en'
 
@@ -324,8 +325,8 @@
         message_file = open(full_filename, "w")
         level_file = open(full_filename+".level", "w")
         for message, level in message_cursor.fetchall() or []:
-            message_file.write(message + "\n")
-            level_file.write(level + "\n")
+            message_file.write(to_unicode(message).encode('UTF-8') + "\n")
+            level_file.write(to_unicode(level).encode('UTF-8') + "\n")
         message_file.close()
         level_file.close()
         update_cursor.execute("UPDATE bitten_log SET filename=%s WHERE id=%s", (filename, log_id))
Copyright (C) 2012-2017 Edgewall Software