mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Bug #1153: repr.repr() now doesn't require set and dictionary items
to be orderable to properly represent them. (backport from rev. 58122)
This commit is contained in:
parent
226910f52d
commit
fed6bb7d70
3 changed files with 28 additions and 5 deletions
|
@ -197,6 +197,16 @@ class ReprTests(unittest.TestCase):
|
|||
x = classmethod(C.foo)
|
||||
self.failUnless(repr(x).startswith('<classmethod object at 0x'))
|
||||
|
||||
def test_unsortable(self):
|
||||
# Repr.repr() used to call sorted() on sets, frozensets and dicts
|
||||
# without taking into account that not all objects are comparable
|
||||
x = set([1j, 2j, 3j])
|
||||
y = frozenset(x)
|
||||
z = {1j: 1, 2j: 2}
|
||||
r(x)
|
||||
r(y)
|
||||
r(z)
|
||||
|
||||
def touch(path, text=''):
|
||||
fp = open(path, 'w')
|
||||
fp.write(text)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue