Use string_types instead of str in isinstance.

Ready for review/merge.