[meld/meld-3-14] patchdialog: Hack around difflib not handling unicode file labels
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/meld-3-14] patchdialog: Hack around difflib not handling unicode file labels
- Date: Sat, 3 Oct 2015 20:44:14 +0000 (UTC)
commit def9e8777057c414c51b06eda5a41a9ff66f24c8
Author: Kai Willadsen <kai willadsen gmail com>
Date: Thu Sep 10 07:44:29 2015 +1000
patchdialog: Hack around difflib not handling unicode file labels
meld/patchdialog.py | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/meld/patchdialog.py b/meld/patchdialog.py
index c6c3d8e..6a1dbbd 100644
--- a/meld/patchdialog.py
+++ b/meld/patchdialog.py
@@ -87,11 +87,16 @@ class PatchDialog(gnomeglade.Component):
names = [self.filediff.textbuffer[i].data.label for i in range(3)]
prefix = os.path.commonprefix(names)
names = [n[prefix.rfind("/") + 1:] for n in names]
+ # difflib doesn't handle getting unicode file labels
+ names = [n.encode('utf8') for n in names]
buf = self.textview.get_buffer()
text0, text1 = texts[indices[0]], texts[indices[1]]
name0, name1 = names[indices[0]], names[indices[1]]
- diff_text = "".join(difflib.unified_diff(text0, text1, name0, name1))
+
+ diff = difflib.unified_diff(text0, text1, name0, name1)
+ unicodeify = lambda x: x.decode('utf8') if isinstance(x, str) else x
+ diff_text = "".join(unicodeify(d) for d in diff)
buf.set_text(diff_text)
def run(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]