summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-10-06 18:52:22 (GMT)
committerGitHub <noreply@github.com>2021-10-06 18:52:22 (GMT)
commitce121fd8755d4db9511ce4aab39d0577165e118e (patch)
tree3f9be283aaf0d26204d87654ecb86ea082650c24
parent4c35a2aa80d7f55573d83651883d8733fac01e31 (diff)
downloadcpython-ce121fd8755d4db9511ce4aab39d0577165e118e.zip
cpython-ce121fd8755d4db9511ce4aab39d0577165e118e.tar.gz
cpython-ce121fd8755d4db9511ce4aab39d0577165e118e.tar.bz2
[doc] Mention __slots__ behavior in weakref.rst (GH-21061) (GH-28772)
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> (cherry picked from commit b24b47e64355224c1bf4e46ed7c4d9f7df4e6f09) Co-authored-by: Jakub Stasiak <jakub@stasiak.at>
-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 b88543e..4b0945c 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])