BUGFIX: isinstance(str) -> isinstance(basestring)

Support unicode too.