diff -r 06244031b608 Lib/test/test_builtin.py --- a/Lib/test/test_builtin.py Thu Aug 22 17:53:16 2013 +0300 +++ b/Lib/test/test_builtin.py Fri Aug 23 16:17:32 2013 +0300 @@ -1287,6 +1287,13 @@ a = {} a[0] = a self.assertEqual(repr(a), '{0: {...}}') + if have_unicode: + class T(object): + def __repr__(self): + return unichr(0x20ac) + r = repr(T()) + self.assertEqual(r, r'\u20ac') + self.assertIs(type(r), str) def test_round(self): self.assertEqual(round(0.0), 0.0) diff -r 06244031b608 Objects/object.c --- a/Objects/object.c Thu Aug 22 17:53:16 2013 +0300 +++ b/Objects/object.c Fri Aug 23 16:17:32 2013 +0300 @@ -384,7 +384,7 @@ #ifdef Py_USING_UNICODE if (PyUnicode_Check(res)) { PyObject* str; - str = PyUnicode_AsEncodedString(res, NULL, NULL); + str = PyUnicode_AsEncodedString(res, NULL, "backslashreplace"); Py_DECREF(res); if (str) res = str;