Skip to content

Commit abba9e7

Browse files
committed
Added missing args and kwargs parameters to CachedProperty.wrap_descriptor.
1 parent 5130d5c commit abba9e7

4 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/core/modules/core/core_cache.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,12 @@ void CCachedProperty::__setitem__(str item, object value)
312312

313313

314314
CCachedProperty *CCachedProperty::wrap_descriptor(
315-
object descriptor, object owner=object(), str name=str(), bool unbound=false)
315+
object descriptor, object owner, str name,
316+
bool unbound, boost::python::tuple args, dict kwargs)
316317
{
317318
CCachedProperty *pProperty = new CCachedProperty(
318319
descriptor.attr("__get__"), descriptor.attr("__set__"), descriptor.attr("__delete__"),
319-
extract<const char *>(descriptor.attr("__doc__")), unbound
320+
extract<const char *>(descriptor.attr("__doc__")), unbound, args, kwargs
320321
);
321322

322323
pProperty->__set_name__(owner, name);

src/core/modules/core/core_cache.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ class CCachedProperty
7171
object __getitem__(str item);
7272
void __setitem__(str item, object value);
7373

74-
static CCachedProperty *wrap_descriptor(object descriptor, object owner, str name, bool unbound);
74+
static CCachedProperty *wrap_descriptor(
75+
object descriptor, object owner=object(), str name=str(),
76+
bool unbound=false, boost::python::tuple args=boost::python::tuple(), dict kwargs=dict()
77+
);
7578

7679
private:
7780
object m_fget;

src/core/modules/core/core_cache_wrap.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,19 @@ void export_cached_property(scope _cache)
324324
" The class the wrapped property should be bound to.\n"
325325
":param str name:\n"
326326
" The name of this property.\n"
327+
":param tuple args:\n"
328+
" Extra arguments passed to the getter, setter and deleter functions.\n"
329+
":param dict kwargs:\n"
330+
" Extra keyword arguments passed to the getter, setter and deleter functions.\n"
327331
"\n"
328332
":raises AttributeError:\n"
329333
" If the given descriptor doesn't have the required methods.\n"
330334
":raises TypeError:\n"
331335
" If the getter, setter or deleter are not callable.",
332-
("descriptor", arg("owner")=object(), arg("name")=str(), arg("unbound")=false)
336+
(
337+
"descriptor", arg("owner")=object(), arg("name")=str(),
338+
arg("unbound")=false, arg("args")=boost::python::tuple(), arg("kwargs")=dict()
339+
)
333340
)
334341
.staticmethod("wrap_descriptor");
335342

src/core/utilities/wrap_macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ template<typename T>
164164
T cached_property(T cls, const char *szName)
165165
{
166166
cls.attr(szName) = transfer_ownership_to_python(
167-
CCachedProperty::wrap_descriptor(cls.attr(szName), cls, szName, false)
167+
CCachedProperty::wrap_descriptor(cls.attr(szName), cls, szName)
168168
);
169169
return cls;
170170
};

0 commit comments

Comments
 (0)