diff options
Diffstat (limited to 'urwid/util.py')
-rw-r--r-- | urwid/util.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/urwid/util.py b/urwid/util.py index 3569f8c..f57c898 100644 --- a/urwid/util.py +++ b/urwid/util.py @@ -20,8 +20,10 @@ # # Urwid web site: http://excess.org/urwid/ +from __future__ import division, print_function + from urwid import escape -from urwid.compat import bytes +from urwid.compat import bytes, text_type, text_types import codecs @@ -108,7 +110,7 @@ def apply_target_encoding( s ): """ Return (encoded byte string, character set rle). """ - if _use_dec_special and type(s) == unicode: + if _use_dec_special and type(s) == text_type: # first convert drawing characters try: s = s.translate( escape.DEC_SPECIAL_CHARMAP ) @@ -118,7 +120,7 @@ def apply_target_encoding( s ): escape.ALT_DEC_SPECIAL_CHARS): s = s.replace( c, escape.SO+alt+escape.SI ) - if type(s) == unicode: + if type(s) == text_type: s = s.replace(escape.SI+escape.SO, u"") # remove redundant shifts s = codecs.encode(s, _target_encoding, 'replace') @@ -412,7 +414,7 @@ def _tagmarkup_recurse( tm, attr ): attr, element = tm return _tagmarkup_recurse( element, attr ) - if not isinstance(tm,(basestring, bytes)): + if not isinstance(tm, text_types + (bytes,)): raise TagMarkupException("Invalid markup element: %r" % tm) # text |