summaryrefslogtreecommitdiff
path: root/Lib/pprint.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2012-07-21 11:22:33 +0200
committerFlorent Xicluna <florent.xicluna@gmail.com>2012-07-21 11:22:33 +0200
commit6a01fc5d4114ac56105ecbfb4ae3cbe043818449 (patch)
treed09a5ce0c25ed803f9d8c1f8e54bcf1ca5e5847e /Lib/pprint.py
parent5116704ec5f12e68835bc0280bb8547eb457a5c7 (diff)
parentd6da90f93d6d44365f5c9f6a2290be90ccfc8d60 (diff)
downloadcpython-git-6a01fc5d4114ac56105ecbfb4ae3cbe043818449.tar.gz
Issues #10017 and #14998: Fix TypeError using pprint on dictionaries with unorderable key.
Diffstat (limited to 'Lib/pprint.py')
-rw-r--r--Lib/pprint.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/pprint.py b/Lib/pprint.py
index b8417f5922..ae96dde1e0 100644
--- a/Lib/pprint.py
+++ b/Lib/pprint.py
@@ -86,7 +86,11 @@ class _safe_key:
self.obj = obj
def __lt__(self, other):
- rv = self.obj.__lt__(other.obj)
+ try:
+ rv = self.obj.__lt__(other.obj)
+ except TypeError:
+ rv = NotImplemented
+
if rv is NotImplemented:
rv = (str(type(self.obj)), id(self.obj)) < \
(str(type(other.obj)), id(other.obj))