boostorg / boostorg/python

nullptr as default argument results in unreported exception during import

未关闭
#60 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
C++-11
主要语言
C++
星标
537
派生
223
平均合并
11 小时 22 分钟
30 天内合并 PR
2

描述

The code at the bottom can be compiled like so:

```
clang++ -std=c++11 -I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -shared -o foo.so nullptr_error.cpp -L/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib -lpython3.5 -L/opt/local/lib -lboost_python
```

When importing the resulting module in Python I see the following error:

```
>>> import foo
Traceback (most recent call last):
File "", line 1, in
SystemError: initialization of foo raised unreported exception
```

If I replace `nullptr` with `NULL`, then there is no error. This is with Boost 1.59 installed via MacPorts on the latest version of OS X with the latest version of Xcode.

``` c++
#include

struct Foo
{
Foo() : foo_(1) {}
void setFoo(int * foo = nullptr) { foo_ = foo ? *foo : 1; }
int getFoo() { return foo_; }
int foo_;
};

BOOST_PYTHON_MODULE(foo)
{
boost::python::class_("Foo", boost::python::init<>())
.def("setFoo", &Foo::setFoo, ( boost::python::arg("foo")=nullptr))
.def("getFoo", &Foo::getFoo)
;
}
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。