Index: Objects/rangeobject.c =================================================================== --- Objects/rangeobject.c (revision 62285) +++ Objects/rangeobject.c (working copy) @@ -233,6 +233,97 @@ } static PyObject * +range_str(rangeobject *r) +{ + /* construct a string rep of range like */ + + PyObject *result, *append, *repr; + result = NULL; + append = NULL, + repr = NULL; + + PyObject *rangeitem[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + int i; + Py_ssize_t ilen = range_length(r); + if (ilen < 0) + goto Fail; + + if (ilen < 7) { + result = PyUnicode_FromString("<"); + if (!result) + goto Fail; + for(i=0; i"); + if (!repr) + goto Fail; + append = PyUnicode_Concat(result, repr); + if (!append) + goto Fail; + Py_DECREF(result); + Py_DECREF(repr); + result = append; + } + else + { + if ((rangeitem[0] = range_item(r, 0)) == NULL) + goto Fail; + if ((rangeitem[1] = range_item(r, 1)) == NULL) + goto Fail; + if ((rangeitem[2] = range_item(r, 2)) == NULL) + goto Fail; + if ((rangeitem[3] = range_item(r, ilen-2)) == NULL) + goto Fail; + if ((rangeitem[4] = range_item(r, ilen-1)) == NULL) + goto Fail; + ilen = 5; + result = PyUnicode_FromFormat("<%R, %R, %R, ..., %R, %R>", + rangeitem[0], + rangeitem[1], + rangeitem[2], + rangeitem[3], + rangeitem[4]); + if (!result) + goto Fail; + } + + for(i=0; i