fix crash when None is passed to enum::operator==
diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h
index 8a3907e..ea67f7e 100644
--- a/include/pybind11/pybind11.h
+++ b/include/pybind11/pybind11.h
@@ -409,7 +409,6 @@
}
}
}
-
if (kwargs_consumed == nkwargs)
result = it->impl(it, args_, parent);
@@ -937,10 +936,11 @@
((it == entries->end()) ? std::string("???")
: std::string(it->second));
});
- this->def("__init__", [](Type& value, int i) { value = (Type) i; });
+ this->def("__init__", [](Type& value, int i) { value = (Type)i; });
+ this->def("__init__", [](Type& value, int i) { new (&value) Type((Type) i); });
this->def("__int__", [](Type value) { return (int) value; });
- this->def("__eq__", [](const Type &value, Type value2) { return value == value2; });
- this->def("__ne__", [](const Type &value, Type value2) { return value != value2; });
+ this->def("__eq__", [](const Type &value, Type *value2) { return value2 && value == *value2; });
+ this->def("__ne__", [](const Type &value, Type *value2) { return !value2 || value != *value2; });
this->def("__hash__", [](const Type &value) { return (int) value; });
m_entries = entries;
}