Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#317 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp, python
Domain
api

Research direction

The minimal reproduction is foo.cpp; start by compiling it with the stated Boost and Python 3 setup and inspect how exporting Foo::operator/= maps to idiv versus itruediv. Done means Python 3 invokes the correct in-place true-division method without a runtime crash, while Python 2 behavior remains unchanged.

Written by the indexing model from the issue text.

Description

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).

Dominant language
C++
Stars
537
Forks
223
Avg merge
11h 22m
Merged PRs (30d)
2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/python

All issues in boostorg/python

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.