boostorg / python

Boost.org python module
http://boostorg.github.io/python
Boost Software License 1.0
472 stars 201 forks source link

Division assignment operator (/=) is not exported properly to Python3 #317

Open acalloo opened 4 years ago

acalloo commented 4 years ago

The minimal example I have is for g++8.3.0 and boost1.67 on Ubuntu19.04 (although I have tested boost1.74 on a CentOS7.8 platform).

My understanding of the issue is that when the operator "/=" is exported for Python3, it is binded to __idiv and not __itruediv, therefore causing a crash upon runtime. For Python2, there is no problem observed.

The problem solved by explicitly doing .def("__itruediv__", &Foo::operator/=). Is this a desired behaviour?

PS: Compiling on Ubuntu19.04 as: g++ foo.cpp -Wall -Wextra -shared -fPIC -o myModule.so -Wfatal-errors -I/usr/include/python3.7 -lboost_python3 (boost1.67 library and boost1.67-dev installed from packages).

acalloo commented 4 years ago

foo.zip Add forgotten example.

colinRawlings commented 3 years ago

I believe this issue is related: https://github.com/boostorg/python/issues/278