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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user