Author: walter.doerwald
Date: Mon May 21 12:43:34 2007
New Revision: 55488
Modified:
python/branches/py3k-struni/Lib/test/test_xrange.py
python/branches/py3k-struni/Objects/rangeobject.c
Log:
repr(range(10)) now returns 'range(0, 10)' for clarity.
Modified: python/branches/py3k-struni/Lib/test/test_xrange.py
==============================================================================
--- python/branches/py3k-struni/Lib/test/test_xrange.py (original)
+++ python/branches/py3k-struni/Lib/test/test_xrange.py Mon May 21 12:43:34 2007
@@ -57,7 +57,7 @@
self.assertEqual(len(r), sys.maxint)
def test_repr(self):
- self.assertEqual(repr(range(1)), 'range(1)')
+ self.assertEqual(repr(range(1)), 'range(0, 1)')
self.assertEqual(repr(range(1, 2)), 'range(1, 2)')
self.assertEqual(repr(range(1, 2, 3)), 'range(1, 2, 3)')
Modified: python/branches/py3k-struni/Objects/rangeobject.c
==============================================================================
--- python/branches/py3k-struni/Objects/rangeobject.c (original)
+++ python/branches/py3k-struni/Objects/rangeobject.c Mon May 21 12:43:34 2007
@@ -234,24 +234,17 @@
static PyObject *
range_repr(rangeobject *r)
{
- Py_ssize_t istart, istep;
+ Py_ssize_t istep;
/* Check for special case values for printing. We don't always
- need the start or step values. We don't care about errors
+ need the step value. We don't care about errors
(it means overflow), so clear the errors. */
- istart = PyNumber_AsSsize_t(r->start, NULL);
- if (istart != 0 || (istart == -1 && PyErr_Occurred())) {
- PyErr_Clear();
- }
-
istep = PyNumber_AsSsize_t(r->step, NULL);
if (istep != 1 || (istep == -1 && PyErr_Occurred())) {
PyErr_Clear();
}
- if (istart == 0 && istep == 1)
- return PyUnicode_FromFormat("range(%R)", r->stop);
- else if (istep == 1)
+ if (istep == 1)
return PyUnicode_FromFormat("range(%R, %R)", r->start, r->stop);
else
return PyUnicode_FromFormat("range(%R, %R, %R)",
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins