cpython: 4d0dcfbdf45b (original) (raw)

Mercurial > cpython

changeset 78213:4d0dcfbdf45b

Issues #10017 and #14998: Fix TypeError using pprint on dictionaries with unorderable key. [#10017]

Florent Xicluna florent.xicluna@gmail.com
date Sat, 21 Jul 2012 11:22:33 +0200
parents f39895c55699(current diff)03cda5360dc6(diff)
children 79d44f4920d9
files Lib/test/test_pprint.py Misc/NEWS
diffstat 3 files changed, 18 insertions(+), 2 deletions(-)[+] [-] Lib/pprint.py 6 Lib/test/test_pprint.py 9 Misc/NEWS 5

line wrap: on

line diff

--- a/Lib/pprint.py +++ b/Lib/pprint.py @@ -86,7 +86,11 @@ class _safe_key: self.obj = obj def lt(self, other):

+ if rv is NotImplemented: rv = (str(type(self.obj)), id(self.obj)) < [](#l1.14) (str(type(other.obj)), id(other.obj))

--- a/Lib/test/test_pprint.py +++ b/Lib/test/test_pprint.py @@ -466,6 +466,15 @@ class QueryTestCase(unittest.TestCase): self.assertEqual(clean(pprint.pformat(dict.fromkeys(keys))), '{' + ','.join('%r:None' % k for k in skeys) + '}')

+

+ + class DottedPrettyPrinter(pprint.PrettyPrinter): def format(self, object, context, maxlevels, level):

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -48,10 +48,13 @@ Core and Builtins