Fixed StringIndexOutOfBoundsException when getting repr() of a unicode string that ends with a lone surrogate character (fixes #2190)