Skip to content
New issue

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

[BUG]: Get std::bad_cast when a callback return a Python complex type velue #587

Closed
luckymark opened this issue May 20, 2024 · 2 comments
Closed

Comments

@luckymark
Copy link

Problem description

Get std::bad_cast when a callback return a Python complex type velue

Reproducible example code

test.py:
def callback():
    return complex(1.0,2.0)

def test_foo():
    foo(callback)

bind.cpp:
#include <nanobind/nanobind.h>
#include  <nanobind/stl/complex.h>
#include <nanobind/stl/function.h>

void foo(std::function<std::complex<double>()> func) {
    auto result = func();
}

NB_MODULE(lib_ext, module) {
    module.def("foo", &foo);
}
@wjakob
Copy link
Owner

wjakob commented May 22, 2024

Cannot reproduce. I think that there is a difference between the issue reported and the code to demonstrate it.

@wjakob wjakob closed this as completed May 22, 2024
@luckymark
Copy link
Author

I'am so sorry!
After checking my code, it turned out that I had an idiot mistake.
Thank you for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants