]> granicus.if.org Git - python/commitdiff
Backport 55887:
authorNeal Norwitz <nnorwitz@gmail.com>
Mon, 11 Jun 2007 07:34:07 +0000 (07:34 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Mon, 11 Jun 2007 07:34:07 +0000 (07:34 +0000)
Bug #1734723: Fix repr.Repr() so it doesn't ignore the maxtuple attribute.

Lib/repr.py
Lib/test/test_repr.py
Misc/NEWS

index 53b5207e5f615d6c8058377138588e1f8f057f56..59015b1a9b4d48f70f2b87b3df6235aafb8c76e5 100644 (file)
@@ -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)
index a37499f1f5f717a8d25e844d2faac3885785b545..9f03a1682f7161b0593a209be8e0a71eb933fe98 100644 (file)
@@ -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
index 93cc32d8acf5df1f537f20a3080c32123881f274..449b4e8fa0b597c5ecfd72f5b363b596e6d64ed5 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -14,8 +14,8 @@ Core and builtins
 
 - Patch #1733960: Allow T_LONGLONG to accept ints.
 
-- Prevent expandtabs() on string and unicode objects from causing a segfault when
-  a large width is passed on 32-bit platforms.
+- Prevent expandtabs() on string and unicode objects from causing a segfault
+  when a large width is passed on 32-bit platforms.
 
 - Bug #1733488: Fix compilation of bufferobject.c on AIX.
 
@@ -23,6 +23,8 @@ Core and builtins
 Library
 -------
 
+- Bug #1734723: Fix repr.Repr() so it doesn't ignore the maxtuple attribute.
+
 - Bug #1728403: Fix a bug that CJKCodecs StreamReader hangs when it
   reads a file that ends with incomplete sequence and sizehint argument
   for .read() is specified.