diff options
| author | Andrew Dunai <andunai@gmail.com> | 2018-01-04 13:56:40 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-04 13:56:40 +0200 |
| commit | cf0307c500e1d575fec5fc5a37e4ff4e69972b92 (patch) | |
| tree | cbc82f80d72cb15589f50c77847dc4c0ddabd072 /urwid/util.py | |
| parent | 2496a176c00eab88492f1566f2a89c58be4e15d9 (diff) | |
| download | urwid-cf0307c500e1d575fec5fc5a37e4ff4e69972b92.tar.gz | |
Python dual support (#266)
* WIP
* Metaclasses
* String literal fixes
* Remove 2to3 and make tests compatible with both Python 2 & 3
* Removed debug code.
* Added tests for ProgressBar
* Fixed examples.
* future division & font literals fix
* Cleaner fonts initialization.
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 |
