use __qualname__ to compute bound method repr (closes #21389)

Patch from Steven Barker.
This commit is contained in:
Benjamin Peterson 2014-08-20 18:41:57 -05:00
parent 2b7ccbda90
commit 48ad7c0b01
4 changed files with 75 additions and 33 deletions

View file

@ -157,8 +157,9 @@ class TestDefaultDict(unittest.TestCase):
def _factory(self):
return []
d = sub()
self.assertTrue(repr(d).startswith(
"defaultdict(<bound method sub._factory of defaultdict(..."))
self.assertRegex(repr(d),
r"defaultdict\(<bound method .*sub\._factory "
r"of defaultdict\(\.\.\., \{\}\)>, \{\}\)")
# NOTE: printing a subclass of a builtin type does not call its
# tp_print slot. So this part is essentially the same test as above.