We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overriding the pure virtual function in class result in trace trap error in python 3.12
Python: 3.12 nanobind: 2.1.0
#include <iostream> #include <nanobind/nanobind.h> #include <nanobind/stl/string.h> #include <nanobind/trampoline.h> class Base { public: std::string name; Base(const std::string &name) : name(name) { std::cout << "Base constructor" << std::endl; } virtual std::string bark() = 0; }; class PyBase : public Base { public: PyBase(const std::string &s) : Base(s) { std::cout << "PyBase constructor" << std::endl; } NB_TRAMPOLINE(Base, 1); std::string bark() override { NB_OVERRIDE_PURE(bark); } }; void alarm1(Base *base, size_t count = 3) { for (size_t i = 0; i < count; ++i) std::cout << base->bark() << std::endl; } NB_MODULE(my_ext, m) { m.attr("__version__") = "0.0.1"; nb::class_<Base, PyBase>(m, "Base") .def(nb::init<const std::string &>()) .def("bark", &Base::bark); m.def("alarm1", &alarm1, "base"_a, "count"_a = 3); }
The text was updated successfully, but these errors were encountered:
I have doubts that there is a bug here, as the ability to override virtual calls (or not) is already tested on Python 3.12 by the CI test suite.
Your reproducer is missing the Python part.
What I suspect might be happening is that you overrode __init__ and did not call super().__init__().
__init__
super().__init__()
Sorry, something went wrong.
Closing due to a lack of response. Feel free to post here if there is more information, and I will reopen the PR.
No branches or pull requests
Problem description
Overriding the pure virtual function in class result in trace trap error in python 3.12
Reproducible example code
The text was updated successfully, but these errors were encountered: