Minimal Boost Python example not working
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 32/100
Research direction
Run the shown C++20 Boost.Python module with Python 3.10 and the my_module.printStr call, then inspect the boundary around def("printStr", printStr) and the std::string conversion. Capture the build and runtime configuration needed to reproduce the fault, and confirm completion when the call prints BEFORE, the message, and AFTER without a segmentation fault.
Written by the indexing model from the issue text.
Description
I'm having trouble getting boost python to work with this minimal example. I've emailed the mailing list but have had no response.
I'm using C++20
#include <boost/python.hpp>
#include <iostream>
#include <string>
void printStr(const std::string &testStr) {
std::cout << "BEFORE" <<std::endl;
std::cout << testStr <<std::endl;
std::cout << "AFTER" <<std::endl;
}
BOOST_PYTHON_MODULE(my_module) {
using namespace boost::python;
def("printStr", printStr);
}
This compiles fine, but I get a segmentation fault when I attempt to call the function from python (using 3.10):
import my_module
message = "This is a test"
my_module.printStr(message)
The output I get:
BEFORE
Segmentation fault
Can you tell me what I'm doing wrong? Thanks in advance
- Dominant language
- C++
- Stars
- 540
- Forks
- 224
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/python
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
Windows CI does not fail if one or more tests failPossibly taken @stephengtuggy claimed this 148 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
-
BoostDetectToolset-1.90.0.cmake file not found in an include() call in boost_python-config.cmakeOpen
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Windows CI: vcpkg dependency caching not workingPossibly taken @stephengtuggy claimed this 148 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
bot-triaged module: correctness (silent) module: fft triage review
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
patrickjquinn/Marathon-Shell#84 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
sav-oss-org/ptusa_main#1610 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
open-astro/AlpacaBridge#2606 · 1 comment ·
Maintainers usually reply within 1 day
-
Refactor force_torque_system integration test to use EcmScopePossibly taken @patelshivani2283-lab claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day