boostorg / boostorg/python

Exposing inherited static member variables as static property with the same name leads to exception

Aberta
#192 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
C++
Estrelas
537
Forks
223
Merge médio
11h 22min
PRs com merge (30d)
2

Descrição

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

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.