:modify: isinstance(..., str) to isinstance(..., basestring)