Fix Python 3 string type checking