Fixed exception casting from str to unicode.