bpo-36669: add matmul support to weakref.proxy (GH-12932)
This commit is contained in:
@@ -285,6 +285,21 @@ class ReferencesTestCase(TestBase):
|
||||
p //= 5
|
||||
self.assertEqual(p, 21)
|
||||
|
||||
def test_proxy_matmul(self):
|
||||
class C:
|
||||
def __matmul__(self, other):
|
||||
return 1729
|
||||
def __rmatmul__(self, other):
|
||||
return -163
|
||||
def __imatmul__(self, other):
|
||||
return 561
|
||||
o = C()
|
||||
p = weakref.proxy(o)
|
||||
self.assertEqual(p @ 5, 1729)
|
||||
self.assertEqual(5 @ p, -163)
|
||||
p @= 5
|
||||
self.assertEqual(p, 561)
|
||||
|
||||
# The PyWeakref_* C API is documented as allowing either NULL or
|
||||
# None as the value for the callback, where either means "no
|
||||
# callback". The "no callback" ref and proxy objects are supposed
|
||||
|
||||
Reference in New Issue
Block a user