2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-24 18:12:43 +00:00

Handle __doc__ attributes by forwarding all attribute accesses on BoundFunction

objects to the target function.


[SVN r8042]
This commit is contained in:
Dave Abrahams
2000-10-28 17:40:29 +00:00
parent fafd76ee51
commit b0e3e0c062

View File

@@ -113,8 +113,12 @@ Ptr BoundFunction::create(Ptr target, Ptr fn)
return Ptr(result, Ptr::new_ref);
}
// The singleton class whose instance represents the type of BoundFunction
// objects in Python. BoundFunctions must be GetAttrable so the __doc__
// attribute of built-in Python functions can be accessed when bound.
struct BoundFunction::TypeObject :
Singleton<BoundFunction::TypeObject, Callable<py::TypeObject<BoundFunction> > >
Singleton<BoundFunction::TypeObject,
Getattrable<Callable<py::TypeObject<BoundFunction> > > >
{
TypeObject() : SingletonBase(&PyType_Type) {}
@@ -148,6 +152,11 @@ BoundFunction::call(PyObject* args, PyObject* keywords) const
return PyEval_CallObjectWithKeywords(m_unbound_function.get(), all_arguments.get(), keywords);
}
PyObject* BoundFunction::getattr(const char* name)
{
return PyObject_GetAttrString(m_unbound_function.get(), const_cast<char*>(name));
}
void BoundFunction::TypeObject::dealloc(BoundFunction* instance) const
{
instance->m_free_list_link = free_list;