Repr for string implemented differently in python 2 and 3, handle this in C code