Mercurial > cpython-lru_cache-weakref
diff Lib/pprint.py @ 78212:03cda5360dc6 3.2
Issues #10017 and #14998: Fix TypeError using pprint on dictionaries with unorderable key.
| author | Florent Xicluna <florent.xicluna@gmail.com> |
|---|---|
| date | Sat, 21 Jul 2012 11:17:38 +0200 |
| parents | 9659e8c40079 |
| children | 65943dc15afc 5a2296093645 |
line wrap: on
line diff
--- a/Lib/pprint.py Sat Jul 21 00:45:14 2012 +0200 +++ b/Lib/pprint.py Sat Jul 21 11:17:38 2012 +0200 @@ -86,7 +86,11 @@ 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))
