summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_weakref.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-08-06 23:31:40 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-08-06 23:31:40 (GMT)
commitb349e4c929131eb708ff3db569077f0c851338e9 (patch)
tree3d5b5e89bcc0f2c55587459d3bc91ee34a94d74b /Lib/test/test_weakref.py
parentf3440c6881a0fdb24ea30f971ebc0fd091bc7ffb (diff)
downloadcpython-b349e4c929131eb708ff3db569077f0c851338e9.zip
cpython-b349e4c929131eb708ff3db569077f0c851338e9.tar.gz
cpython-b349e4c929131eb708ff3db569077f0c851338e9.tar.bz2
Issue #22116: C functions and methods (of the 'builtin_function_or_method' type) can now be weakref'ed. Patch by Wei Wu.
Diffstat (limited to 'Lib/test/test_weakref.py')
-rw-r--r--Lib/test/test_weakref.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index adb923f..7476273 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -92,6 +92,18 @@ class ReferencesTestCase(TestBase):
self.check_basic_callback(create_function)
self.check_basic_callback(create_bound_method)
+ @support.cpython_only
+ def test_cfunction(self):
+ import _testcapi
+ create_cfunction = _testcapi.create_cfunction
+ f = create_cfunction()
+ wr = weakref.ref(f)
+ self.assertIs(wr(), f)
+ del f
+ self.assertIsNone(wr())
+ self.check_basic_ref(create_cfunction)
+ self.check_basic_callback(create_cfunction)
+
def test_multiple_callbacks(self):
o = C()
ref1 = weakref.ref(o, self.callback)