From 9d605171a7d0735244806d2e453e945466a17255 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Thu, 12 Feb 2015 13:55:27 -0800 Subject: [PATCH] Didn't port isbasestring/isunicodestring from kitchen so switch to isinstance --- lib/ansible/utils/unicode.py | 8 ++++---- v2/ansible/utils/unicode.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/ansible/utils/unicode.py b/lib/ansible/utils/unicode.py index b2fcf65161..7bd035c007 100644 --- a/lib/ansible/utils/unicode.py +++ b/lib/ansible/utils/unicode.py @@ -116,12 +116,12 @@ def to_unicode(obj, encoding='utf-8', errors='replace', nonstring=None): simple = obj.__str__() except (UnicodeError, AttributeError): simple = u'' - if isbytestring(simple): + if isinstance(simple, str): return unicode(simple, encoding, errors) return simple elif nonstring in ('repr', 'strict'): obj_repr = repr(obj) - if isbytestring(obj_repr): + if isinstance(obj_repr, str): obj_repr = unicode(obj_repr, encoding, errors) if nonstring == 'repr': return obj_repr @@ -221,7 +221,7 @@ def to_bytes(obj, encoding='utf-8', errors='replace', nonstring=None): simple = obj.__unicode__() except (AttributeError, UnicodeError): simple = '' - if isunicodestring(simple): + if isinstance(simple, unicode): simple = simple.encode(encoding, 'replace') return simple elif nonstring in ('repr', 'strict'): @@ -229,7 +229,7 @@ def to_bytes(obj, encoding='utf-8', errors='replace', nonstring=None): obj_repr = obj.__repr__() except (AttributeError, UnicodeError): obj_repr = '' - if isunicodestring(obj_repr): + if isinstance(obj_repr, unicode): obj_repr = obj_repr.encode(encoding, errors) else: obj_repr = str(obj_repr) diff --git a/v2/ansible/utils/unicode.py b/v2/ansible/utils/unicode.py index b2fcf65161..7bd035c007 100644 --- a/v2/ansible/utils/unicode.py +++ b/v2/ansible/utils/unicode.py @@ -116,12 +116,12 @@ def to_unicode(obj, encoding='utf-8', errors='replace', nonstring=None): simple = obj.__str__() except (UnicodeError, AttributeError): simple = u'' - if isbytestring(simple): + if isinstance(simple, str): return unicode(simple, encoding, errors) return simple elif nonstring in ('repr', 'strict'): obj_repr = repr(obj) - if isbytestring(obj_repr): + if isinstance(obj_repr, str): obj_repr = unicode(obj_repr, encoding, errors) if nonstring == 'repr': return obj_repr @@ -221,7 +221,7 @@ def to_bytes(obj, encoding='utf-8', errors='replace', nonstring=None): simple = obj.__unicode__() except (AttributeError, UnicodeError): simple = '' - if isunicodestring(simple): + if isinstance(simple, unicode): simple = simple.encode(encoding, 'replace') return simple elif nonstring in ('repr', 'strict'): @@ -229,7 +229,7 @@ def to_bytes(obj, encoding='utf-8', errors='replace', nonstring=None): obj_repr = obj.__repr__() except (AttributeError, UnicodeError): obj_repr = '' - if isunicodestring(obj_repr): + if isinstance(obj_repr, unicode): obj_repr = obj_repr.encode(encoding, errors) else: obj_repr = str(obj_repr)