@@ -285,6 +285,21 @@ def __ifloordiv__(self, other): |
|
|
285 |
285 |
p //= 5 |
286 |
286 |
self.assertEqual(p, 21) |
287 |
287 |
|
|
288 |
+def test_proxy_matmul(self): |
|
289 |
+class C: |
|
290 |
+def __matmul__(self, other): |
|
291 |
+return 1729 |
|
292 |
+def __rmatmul__(self, other): |
|
293 |
+return -163 |
|
294 |
+def __imatmul__(self, other): |
|
295 |
+return 561 |
|
296 |
+o = C() |
|
297 |
+p = weakref.proxy(o) |
|
298 |
+self.assertEqual(p @ 5, 1729) |
|
299 |
+self.assertEqual(5 @ p, -163) |
|
300 |
+p @= 5 |
|
301 |
+self.assertEqual(p, 561) |
|
302 |
+ |
288 |
303 |
# The PyWeakref_* C API is documented as allowing either NULL or |
289 |
304 |
# None as the value for the callback, where either means "no |
290 |
305 |
# callback". The "no callback" ref and proxy objects are supposed |