[Python-checkins] bpo-36949: Implement __repr__ on WeakSet (GH-13415)
Steve Dower
webhook-mailer at python.org
Mon May 20 13:01:11 EDT 2019
https://github.com/python/cpython/commit/5ae1c84bcd13b766989fc3f1e1c851e7bd4c1faa
commit: 5ae1c84bcd13b766989fc3f1e1c851e7bd4c1faa
branch: master
author: Batuhan Taşkaya <47358913+isidentical at users.noreply.github.com>
committer: Steve Dower <steve.dower at python.org>
date: 2019-05-20T10:01:07-07:00
summary:
bpo-36949: Implement __repr__ on WeakSet (GH-13415)
files:
A Misc/NEWS.d/next/Library/2019-05-19-06-54-26.bpo-36949.jBlG9F.rst
M Lib/_weakrefset.py
M Lib/test/test_weakset.py
diff --git a/Lib/_weakrefset.py b/Lib/_weakrefset.py
index 304c66f59bd1..7a84823622ee 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 691b95e77c6a..569facdd30c1 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 000000000000..e4eeb4010a23
--- /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.
More information about the Python-checkins
mailing list