From c161cb995530521711e47425170524921fc1b559 Mon Sep 17 00:00:00 2001 From: Neal Norwitz Date: Mon, 11 Jun 2007 07:29:43 +0000 Subject: [PATCH] Bug #1734723: Fix repr.Repr() so it doesn't ignore the maxtuple attribute. Will backport --- Lib/repr.py | 2 +- Lib/test/test_repr.py | 13 +++++++++++++ Misc/NEWS | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Lib/repr.py b/Lib/repr.py index 53b5207e5f6..59015b1a9b4 100644 --- a/Lib/repr.py +++ b/Lib/repr.py @@ -52,7 +52,7 @@ class Repr: return '%s%s%s' % (left, s, right) def repr_tuple(self, x, level): - return self._repr_iterable(x, level, '(', ')', self.maxlist, ',') + return self._repr_iterable(x, level, '(', ')', self.maxtuple, ',') def repr_list(self, x, level): return self._repr_iterable(x, level, '[', ']', self.maxlist) diff --git a/Lib/test/test_repr.py b/Lib/test/test_repr.py index 5fcf815ea3f..a07ed71cbe7 100644 --- a/Lib/test/test_repr.py +++ b/Lib/test/test_repr.py @@ -10,6 +10,7 @@ import unittest from test.test_support import run_unittest from repr import repr as r # Don't shadow builtin repr +from repr import Repr def nestedTuple(nesting): @@ -34,6 +35,18 @@ class ReprTests(unittest.TestCase): expected = repr(s)[:13] + "..." + repr(s)[-14:] eq(r(s), expected) + def test_tuple(self): + eq = self.assertEquals + eq(r((1,)), "(1,)") + + t3 = (1, 2, 3) + eq(r(t3), "(1, 2, 3)") + + r2 = Repr() + r2.maxtuple = 2 + expected = repr(t3)[:-2] + "...)" + eq(r2.repr(t3), expected) + def test_container(self): from array import array from collections import deque diff --git a/Misc/NEWS b/Misc/NEWS index 699f723ef91..a8f28c2ae5f 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -229,6 +229,8 @@ Core and builtins Library ------- +- Bug #1734723: Fix repr.Repr() so it doesn't ignore the maxtuple attribute. + - The urlopen function of urllib2 now has an optional timeout parameter (note that it actually works with HTTP, HTTPS, FTP and FTPS connections).