[meld/Python3: 22/54] util.compat: Remove text_type and update users



commit e3f306001071ad86ebc5d3414e689d9f239e6863
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Nov 14 07:10:00 2015 +1000

    util.compat: Remove text_type and update users

 meld/dirdiff.py     |    5 ++---
 meld/filediff.py    |    3 +--
 meld/meldbuffer.py  |    1 -
 meld/util/compat.py |    1 -
 4 files changed, 3 insertions(+), 7 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 05bb5b4..50d6242 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -39,7 +39,6 @@ from . import misc
 from . import recent
 from .ui import gnomeglade
 from .ui import emblemcellrenderer
-from meld.util.compat import text_type
 
 from collections import namedtuple
 from decimal import Decimal
@@ -624,7 +623,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
         # the time we get this far. This is a fallback, and may be wrong!
         locations = list(locations)
         for i, l in enumerate(locations):
-            if not isinstance(l, text_type):
+            if not isinstance(l, str):
                 locations[i] = l.decode(sys.getfilesystemencoding())
         locations = [os.path.abspath(l) if l else '' for l in locations]
         self.current_path = None
@@ -719,7 +718,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
 
                 for e in entries:
                     try:
-                        if not isinstance(e, text_type):
+                        if not isinstance(e, str):
                             e = e.decode('utf8')
                     except UnicodeDecodeError:
                         approximate_name = e.decode('utf8', 'replace')
diff --git a/meld/filediff.py b/meld/filediff.py
index 2096c18..fcee0f9 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -45,7 +45,6 @@ from .ui import gnomeglade
 
 from meld.const import MODE_REPLACE, MODE_DELETE, MODE_INSERT, NEWLINES
 from meld.settings import bind_settings, meldsettings
-from .util.compat import text_type
 from meld.sourceview import LanguageManager, get_custom_encoding_candidates
 
 
@@ -925,7 +924,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         buf = self.textbuffer[pane]
         sel = buf.get_selection_bounds()
         if sel:
-            return text_type(buf.get_text(sel[0], sel[1], False), 'utf8')
+            return buf.get_text(sel[0], sel[1], False)
 
     def on_find_activate(self, *args):
         selected_text = self.get_selected_text()
diff --git a/meld/meldbuffer.py b/meld/meldbuffer.py
index 3bfd24d..e848c2d 100644
--- a/meld/meldbuffer.py
+++ b/meld/meldbuffer.py
@@ -24,7 +24,6 @@ from gi.repository import GtkSource
 from meld.conf import _
 from meld.misc import fallback_decode
 from meld.settings import bind_settings, meldsettings
-from meld.util.compat import text_type
 
 
 class MeldBuffer(GtkSource.Buffer):
diff --git a/meld/util/compat.py b/meld/util/compat.py
index 5bff563..5cf80f8 100644
--- a/meld/util/compat.py
+++ b/meld/util/compat.py
@@ -2,5 +2,4 @@
 import sys
 
 # Python 2/3 compatibility, named as per six
-text_type = str if sys.version_info[0] == 3 else unicode
 string_types = str if sys.version_info[0] == 3 else basestring


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