summaryrefslogtreecommitdiffstats
path: root/Doc/library/weakref.rst
diff options
context:
space:
mode:
authorJakub Stasiak <jakub@stasiak.at>2021-10-06 18:23:02 (GMT)
committerGitHub <noreply@github.com>2021-10-06 18:23:02 (GMT)
commitb24b47e64355224c1bf4e46ed7c4d9f7df4e6f09 (patch)
tree96459b51159feb1440ec1e9e9e1c8f4387fb40f0 /Doc/library/weakref.rst
parent682aecfdeba481c876bfc9f3796c635bd5b5df50 (diff)
downloadcpython-b24b47e64355224c1bf4e46ed7c4d9f7df4e6f09.zip
cpython-b24b47e64355224c1bf4e46ed7c4d9f7df4e6f09.tar.gz
cpython-b24b47e64355224c1bf4e46ed7c4d9f7df4e6f09.tar.bz2
[doc] Mention __slots__ behavior in weakref.rst (GH-21061)
It took me longer than I expected to figure out why a random class I dealt with didn't support weak references. I believe this addition will make the __slots__/weakref interaction more discoverable to people having troubles with this. (Before this patch __slots__ was not mentioned in weakref documentation even once). Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Doc/library/weakref.rst')
-rw-r--r--Doc/library/weakref.rst4
1 files changed, 4 insertions, 0 deletions
diff --git a/Doc/library/weakref.rst b/Doc/library/weakref.rst
index 5a8df4c..1102c63 100644
--- a/Doc/library/weakref.rst
+++ b/Doc/library/weakref.rst
@@ -88,6 +88,10 @@ support weak references but can add support through subclassing::
Extension types can easily be made to support weak references; see
:ref:`weakref-support`.
+When ``__slots__`` are defined for a given type, weak reference support is
+disabled unless a ``'__weakref__'`` string is also present in the sequence of
+strings in the ``__slots__`` declaration.
+See :ref:`__slots__ documentation <slots>` for details.
.. class:: ref(object[, callback])