diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2014-08-06 23:31:40 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2014-08-06 23:31:40 (GMT) |
commit | b349e4c929131eb708ff3db569077f0c851338e9 (patch) | |
tree | 3d5b5e89bcc0f2c55587459d3bc91ee34a94d74b /Lib | |
parent | f3440c6881a0fdb24ea30f971ebc0fd091bc7ffb (diff) | |
download | cpython-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')
-rw-r--r-- | Lib/test/test_sys.py | 2 | ||||
-rw-r--r-- | Lib/test/test_weakref.py | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 854e786..c50b20b 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -784,7 +784,7 @@ class SizeofTest(unittest.TestCase): # buffer # XXX # builtin_function_or_method - check(len, size('3P')) # XXX check layout + check(len, size('4P')) # XXX check layout # bytearray samples = [b'', b'u'*100000] for sample in samples: 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) |