Patches item #1713041, was opened at 2007-05-04 15:13 Message generated for change (Settings changed) made by draghuram You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1713041&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Library (Lib) Group: Python 2.6 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Raghuram Devarakonda (draghuram) Assigned to: Nobody/Anonymous (nobody) >Summary: fix for 1712742: corrects pprint's handling of 'depth' Initial Comment: The patch is really simple. Just change the way "maxlevels" is checked. I couldn't find a way to have a test case for this bug. ---------------------------------------------------------------------- Comment By: Raghuram Devarakonda (draghuram) Date: 2007-05-07 10:49 Message: Logged In: YES user_id=984087 Originator: YES josm, thanks for the test case. I incorporated it into the patch. BTW, I changed "str" to "repr" as I think "repr" is closer to what pformat does. File Added: pprint.patch ---------------------------------------------------------------------- Comment By: jos (josm) Date: 2007-05-05 05:02 Message: Logged In: YES user_id=1776568 Originator: NO Your patch looks good and worked fine. Wouldn't it be nice to add a test case for this problem to test_pprint.py? The following is just draft patch to add the test case. Index: Lib/test/test_pprint.py =================================================================== --- Lib/test/test_pprint.py (revision 55144) +++ Lib/test/test_pprint.py (working copy) @@ -195,7 +195,22 @@ others.should.not.be: like.this}""" self.assertEqual(DottedPrettyPrinter().pformat(o), exp) + def test_depth(self): + nested_tuple = (1, (2, (3, (4, (5, 6))))) + nested_dict = {1: {2: {3: {4: {5: {6: 6}}}}}} + nested_list = [1, [2, [3, [4, [5, [6, []]]]]]] + self.assertEqual(pprint.pformat(nested_tuple), str(nested_tuple)) + self.assertEqual(pprint.pformat(nested_dict), str(nested_dict)) + self.assertEqual(pprint.pformat(nested_list), str(nested_list)) + + lv1_tuple = '(1, (...))' + lv1_dict = '{1: {...}}' + lv1_list = '[1, [...]]' + self.assertEqual(pprint.pformat(nested_tuple, depth=1), lv1_tuple) + self.assertEqual(pprint.pformat(nested_dict, depth=1), lv1_dict) + self.assertEqual(pprint.pformat(nested_list, depth=1), lv1_list) + ---------------------------------------------------------------------- Comment By: Raghuram Devarakonda (draghuram) Date: 2007-05-04 15:15 Message: Logged In: YES user_id=984087 Originator: YES File Added: pprint_test.py ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1713041&group_id=5470 _______________________________________________ Patches mailing list Patches@python.org http://mail.python.org/mailman/listinfo/patches