Issue #22721: An order of multiline pprint output of set or dict containing

orderable and non-orderable elements no longer depends on iteration order of
set or dict.
This commit is contained in:
Serhiy Storchaka 2015-04-06 22:52:44 +03:00
parent 01362da7d0
commit 62aa7dc7c9
3 changed files with 46 additions and 7 deletions

View file

@ -86,14 +86,10 @@ class _safe_key:
def __lt__(self, other):
try:
rv = self.obj.__lt__(other.obj)
return self.obj < 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))
return rv
return ((str(type(self.obj)), id(self.obj)) < \
(str(type(other.obj)), id(other.obj)))
def _safe_tuple(t):
"Helper function for comparing 2-tuples"