# HG changeset patch # User hodgestar # Date 1392576200 0 # Node ID 500573200533496cdfc11fdb6f3a45345c7b59cb # Parent 323d592690dac9892ef74f42c94d5cc0aedb10a6 Add isstring helper. diff --git a/genshi/compat.py b/genshi/compat.py --- a/genshi/compat.py +++ b/genshi/compat.py @@ -35,6 +35,15 @@ 'Python 2 compatibility function. Not usable in Python 3.') +# We need to test if an object is an instance of a string type in places + +if IS_PYTHON2: + def isstring(obj): + return isinstance(obj, basestring) +else: + def isstring(obj): + return isinstance(obj, str) + # We need to differentiate between StringIO and BytesIO in places if IS_PYTHON2: @@ -112,4 +121,3 @@ if not x: return False return True -