boostorg / boostorg/python

nullptr as default argument results in unreported exception during import

オープン
#60 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
C++-11
主要言語
C++
スター
537
フォーク
223
平均マージ
11時間 22分
マージ済み PR(30日)
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 を短くまとめたダイジェスト。