[meld] dirdiff: Handle unicode dates in non-UTF8 locales (bgo#763728)



commit 89b53a1320a34ae64712d12792e9508106eeb3a9
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Apr 16 08:49:51 2016 +1000

    dirdiff: Handle unicode dates in non-UTF8 locales (bgo#763728)
    
    While this can happen on unix systems, this is a more common case on
    Windows, the upshot of which is that we stop setting extra metadata on
    the tree rows in question.

 meld/dirdiff.py |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 02ab2a7..ba4ad2a 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -21,6 +21,7 @@ import copy
 import datetime
 import errno
 import functools
+import locale
 import os
 import re
 import shutil
@@ -1319,6 +1320,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
             all_present_same = self.file_compare(lof, regexes)
         different = 1
         one_isdir = [None for i in range(self.model.ntree)]
+        locale_encoding = locale.getpreferredencoding()
         for j in range(self.model.ntree):
             if mod_times[j]:
                 isdir = os.path.isdir( files[j] )
@@ -1346,6 +1348,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
                 TIME = self.model.column_index(COL_TIME, j)
                 mod_datetime = datetime.datetime.fromtimestamp(mod_times[j])
                 time_str = mod_datetime.strftime("%a %d %b %Y %H:%M:%S")
+                time_str = time_str.decode(locale_encoding, errors='replace')
                 self.model.set_value(it, TIME, time_str)
 
                 def natural_size(bytes):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]