pybind / pybind11

Seamless operability between C++11 and Python

Home Page:https://pybind11.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"error_already_set at memory location" exception throws when python call pybind function with std::variant<> argument

aungkhant0911 opened this issue · comments

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

latest release build

Problem description

The exception occurs in call() function's reinterpret_steal. As the title mentioned, the problem persist, as long as the argument of doS is variant. I am not sure what I am missing.

Reproducible example code

pybind code:

void doS(variant<bool, int> var) {
	cout << "value of 'b' is " << get<0>(var) << endl;
}

int main() {
	py::scoped_interpreter guard{};
	py::module_ te = py::module_::import("testing");	
	
	te.def("blah", &doS);
	te.attr("h")();	
	return 0;	
}

testing.py :

def h(): 
    print("H H HH H ")
    blah(345)

Is this a regression? Put the last known working version here if it is.

Not a regression

resolved