[meld] recent: Fix some handling of unicode paths in recent files (bgo#731376)
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] recent: Fix some handling of unicode paths in recent files (bgo#731376)
- Date: Sun, 8 Jun 2014 21:50:51 +0000 (UTC)
commit a63ee6bda276f540933bb53b7e292f893e6bfeae
Author: Kai Willadsen <kai willadsen gmail com>
Date: Mon Jun 9 07:48:13 2014 +1000
recent: Fix some handling of unicode paths in recent files (bgo#731376)
meld/recent.py | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/meld/recent.py b/meld/recent.py
index 2998e6c..42a5fbd 100644
--- a/meld/recent.py
+++ b/meld/recent.py
@@ -48,6 +48,14 @@ TYPE_MERGE = "Merge"
COMPARISON_TYPES = (TYPE_FILE, TYPE_FOLDER, TYPE_VC, TYPE_MERGE)
+def unicodeify(s):
+ if s is None:
+ return None
+ if isinstance(s, str):
+ return s.decode(sys.getfilesystemencoding(), 'replace')
+ return s
+
+
class RecentFiles(object):
mime_type = "application/x-meld-comparison"
@@ -85,6 +93,7 @@ class RecentFiles(object):
if None in paths:
return
+ paths = [unicodeify(p) for p in paths]
# If a (type, paths) comparison is already registered, then re-add
# the corresponding comparison file
comparison_key = (comp_type, tuple(paths))
@@ -145,6 +154,7 @@ class RecentFiles(object):
return comp_type, paths, flags
def _write_recent_file(self, comp_type, paths):
+ paths = [p.encode(sys.getfilesystemencoding()) for p in paths]
# TODO: Use GKeyFile instead, and return a Gio.File. This is why we're
# using ';' to join comparison paths.
with tempfile.NamedTemporaryFile(prefix='recent-',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]