summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBatuhan Taşkaya <47358913+isidentical@users.noreply.github.com>2019-05-20 17:01:07 (GMT)
committerSteve Dower <steve.dower@python.org>2019-05-20 17:01:07 (GMT)
commit5ae1c84bcd13b766989fc3f1e1c851e7bd4c1faa (patch)
tree4a34e4e3ab7cf2a80ebf4644b5c2a9ee9c8c09a2
parent77b3b7701a34ecf6316469e05b79bb91de2addfa (diff)
downloadcpython-5ae1c84bcd13b766989fc3f1e1c851e7bd4c1faa.zip
cpython-5ae1c84bcd13b766989fc3f1e1c851e7bd4c1faa.tar.gz
cpython-5ae1c84bcd13b766989fc3f1e1c851e7bd4c1faa.tar.bz2
bpo-36949: Implement __repr__ on WeakSet (GH-13415)
-rw-r--r--Lib/_weakrefset.py3
-rw-r--r--Lib/test/test_weakset.py3
-rw-r--r--Misc/NEWS.d/next/Library/2019-05-19-06-54-26.bpo-36949.jBlG9F.rst1
3 files changed, 7 insertions, 0 deletions
diff --git a/Lib/_weakrefset.py b/Lib/_weakrefset.py
index 304c66f..7a84823 100644
--- a/Lib/_weakrefset.py
+++ b/Lib/_weakrefset.py
@@ -194,3 +194,6 @@ class WeakSet:
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 691b95e..569facd 100644
--- a/Lib/test/test_weakset.py
+++ b/Lib/test/test_weakset.py
@@ -434,6 +434,9 @@ class TestWeakSet(unittest.TestCase):
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 0000000..e4eeb40
--- /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.