Exposing inherited static member variables as static property with the same name leads to exception
- 主要語言
- C++
- 星號
- 537
- 分支
- 223
- 平均合併
- 11 小時 22 分鐘
- 30 天內合併 PR
- 2
描述
This bug has been reported by Luke Titley in 2009 on boost-build mailing list. It is still reproducible with the version of boost python 1.65 on Visual C++ 2017. I'm using the Luke's code snippet to show the problem.
There are two boost python classes, one inheriting from the other; each with a static member variable of the same name.
//---------------------------------------------------------------------------------------
// C++ Classes
//---------------------------------------------------------------------------------------
class Base
{
public:
static const wstring Name;
};
const wstring Base::Name(L"Base");
//---------------------------------------------------------------------------------------
class Derived : public Base
{
public:
static const wstring Name;
};
const wstring Derived ::Name(L"Derived");
//---------------------------------------------------------------------------------------
// Boost Python Bindings
//---------------------------------------------------------------------------------------
wstring getBaseName()
{
return Base::Name;
}
void exposeBase()
{
py::class_("Base")
.add_static_property("Name", &getBaseName) ;
}
//---------------------------------------------------------------------------------------
wstring getDerivedName()
{
return Derived::Name;
}
void exposeDerived()
{
py::class_ >("Derived")
.add_static_property("Name", &getDerivedName) ;
}
//---------------------------------------------------------------------------------------
BOOST_PYTHON_MODULE(nmx)
{
exposeBase();
exposeDerived();
}
The import of the module fails and it's caused by throwing exception in exposedDerived (add_static_property).
Best Regards,
Gabriel
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
Start by reproducing the supplied C++ Boost.Python example and trace the failure from add_static_property during exposeDerived. Investigate how inherited static properties with the same name are handled; done means the module imports successfully while Base.Name and Derived.Name remain distinct.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- cpp, python
- 領域
- api
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100