Skip to content

Commit b664ef0

Browse files
committed
Added a warning to CachedProperty's documentation regarding circular references.
Updated some docstrings.
1 parent de055b8 commit b664ef0

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

src/core/modules/core/core_cache_wrap.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ void export_cached_property(scope _cache)
8989
" Extra keyword arguments passed to the getter, setter and deleter functions.\n"
9090
"\n"
9191
":raises TypeError:\n"
92-
" If the given getter, setter or deleter is not callable."
92+
" If the given getter, setter or deleter is not callable.\n"
93+
"\n"
94+
".. warning ::\n"
95+
" If a cached object hold a strong reference of the instance it belongs to,"
96+
" this will result in a circular reference preventing their garbage collection."
9397
)
9498
);
9599

@@ -185,13 +189,19 @@ void export_cached_property(scope _cache)
185189
CachedProperty.def_readwrite(
186190
"args",
187191
&CCachedProperty::m_args,
188-
"The extra arguments passed to the getter, setter and deleter functions."
192+
"The extra arguments passed to the getter, setter and deleter functions.\n"
193+
"\n"
194+
":rtype:\n"
195+
" tuple"
189196
);
190197

191198
CachedProperty.def_readwrite(
192199
"kwargs",
193200
&CCachedProperty::m_kwargs,
194-
"The extra keyword arguments passed to the getter, setter and deleter functions."
201+
"The extra keyword arguments passed to the getter, setter and deleter functions.\n"
202+
"\n"
203+
":rtype:\n"
204+
" dict"
195205
);
196206

197207
CachedProperty.def(
@@ -263,7 +273,21 @@ void export_cached_property(scope _cache)
263273
"wrap_descriptor",
264274
&CCachedProperty::wrap_descriptor,
265275
manage_new_object_policy(),
266-
"Wraps a descriptor as a cached property.",
276+
"Wraps a descriptor as a cached property.\n"
277+
"\n"
278+
":param property descriptor:\n"
279+
" Property descriptor to wrap.\n"
280+
" Must have a __get__, __set__ and a __del__ methods bound to it, either"
281+
" callable or set to None.\n"
282+
":param class owner:\n"
283+
" The class the wrapped property should be bound to.\n"
284+
":param str name:\n"
285+
" The name of this property.\n"
286+
"\n"
287+
":raises AttributeError:\n"
288+
" If the given descriptor doesn't have the required methods.\n"
289+
":raises TypeError:\n"
290+
" If the getter, setter or deleter are not callable.",
267291
("descriptor", arg("owner")=object(), arg("name")=str())
268292
)
269293
.staticmethod("wrap_descriptor");

0 commit comments

Comments
 (0)