mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-79512: Fixed names and __module__ value of weakref classes (GH-93719)
Classes ReferenceType, ProxyType and CallableProxyType have now correct atrtributes __module__, __name__ and __qualname__. It makes them (types, not instances) pickleable.
This commit is contained in:
parent
6fd4c8ec77
commit
8352e322e8
3 changed files with 17 additions and 3 deletions
|
@ -2154,6 +2154,17 @@ class FinalizeTestCase(unittest.TestCase):
|
|||
self.assertTrue(b'ZeroDivisionError' in err)
|
||||
|
||||
|
||||
class ModuleTestCase(unittest.TestCase):
|
||||
def test_names(self):
|
||||
for name in ('ReferenceType', 'ProxyType', 'CallableProxyType',
|
||||
'WeakMethod', 'WeakSet', 'WeakKeyDictionary', 'WeakValueDictionary'):
|
||||
obj = getattr(weakref, name)
|
||||
if name != 'WeakSet':
|
||||
self.assertEqual(obj.__module__, 'weakref')
|
||||
self.assertEqual(obj.__name__, name)
|
||||
self.assertEqual(obj.__qualname__, name)
|
||||
|
||||
|
||||
libreftest = """ Doctest for examples in the library reference: weakref.rst
|
||||
|
||||
>>> from test.support import gc_collect
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue