Fix string type checking in Python 3.x