bpo-36144: Add union operators to WeakValueDictionary584 (#19127)
diff --git a/Lib/weakref.py b/Lib/weakref.py
index 759ad6d..5fa851d 100644
--- a/Lib/weakref.py
+++ b/Lib/weakref.py
@@ -310,6 +310,25 @@
self._commit_removals()
return list(self.data.values())
+ def __ior__(self, other):
+ self.update(other)
+ return self
+
+ def __or__(self, other):
+ if isinstance(other, _collections_abc.Mapping):
+ c = self.copy()
+ c.update(other)
+ return c
+ return NotImplemented
+
+ def __ror__(self, other):
+ if isinstance(other, _collections_abc.Mapping):
+ c = self.__class__()
+ c.update(other)
+ c.update(self)
+ return c
+ return NotImplemented
+
class KeyedRef(ref):
"""Specialized reference that includes a key corresponding to the value.