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
--- /dev/null
+Fixed names and ``__module__`` value of :mod:`weakref` classes
+:class:`~weakref.ReferenceType`, :class:`~weakref.ProxyType`,
+:class:`~weakref.CallableProxyType`. It makes them pickleable.
PyTypeObject
_PyWeakref_RefType = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
- .tp_name = "weakref",
+ .tp_name = "weakref.ReferenceType",
.tp_basicsize = sizeof(PyWeakReference),
.tp_dealloc = weakref_dealloc,
.tp_vectorcall_offset = offsetof(PyWeakReference, vectorcall),
PyTypeObject
_PyWeakref_ProxyType = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
- "weakproxy",
+ "weakref.ProxyType",
sizeof(PyWeakReference),
0,
/* methods */
PyTypeObject
_PyWeakref_CallableProxyType = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
- "weakcallableproxy",
+ "weakref.CallableProxyType",
sizeof(PyWeakReference),
0,
/* methods */