diff --git a/Lib/_weakrefset.py b/Lib/_weakrefset.py index 304c66f59bd..7a84823622e 100644 --- a/Lib/_weakrefset.py +++ b/Lib/_weakrefset.py @@ -194,3 +194,6 @@ def union(self, other): def isdisjoint(self, other): return len(self.intersection(other)) == 0 + + def __repr__(self): + return repr(self.data) diff --git a/Lib/test/test_weakset.py b/Lib/test/test_weakset.py index 691b95e77c6..569facdd30c 100644 --- a/Lib/test/test_weakset.py +++ b/Lib/test/test_weakset.py @@ -434,6 +434,9 @@ def test_len_race(self): self.assertGreaterEqual(n2, 0) self.assertLessEqual(n2, n1) + def test_repr(self): + assert repr(self.s) == repr(self.s.data) + if __name__ == "__main__": unittest.main() diff --git a/Misc/NEWS.d/next/Library/2019-05-19-06-54-26.bpo-36949.jBlG9F.rst b/Misc/NEWS.d/next/Library/2019-05-19-06-54-26.bpo-36949.jBlG9F.rst new file mode 100644 index 00000000000..e4eeb4010a2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-05-19-06-54-26.bpo-36949.jBlG9F.rst @@ -0,0 +1 @@ +Implement __repr__ for WeakSet objects.