Division assignment operator (/=) is not exported properly to Python3
- 主要语言
- C++
- 星标
- 537
- 派生
- 223
- 平均合并
- 11 小时 22 分钟
- 30 天内合并 PR
- 2
描述
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).
贡献指南
这个仓库没有索引到贡献指南
调研方向
最小复现是 foo.cpp;首先使用所述的 Boost 和 Python 3 设置编译它,并检查导出 Foo::operator/= 如何映射到 __idiv__ 而不是 __itruediv__。完成的标准是 Python 3 调用正确的原地真除法方法且不会发生运行时崩溃,同时 Python 2 的行为保持不变。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- cpp, python
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 30/100