fix exception handling for python 3
fixed incompatibility with python 3 for isinstance unicode