Fix str type-checking for py2/3