Change checks of str and bytes to be compat.basestring