Py3: fix crash if class is not part of a module any more

This commit is contained in:
wmayer
2019-06-02 18:06:46 +02:00
parent 09679c18aa
commit f5706be874

View File

@@ -333,6 +333,12 @@ void PropertyPythonObject::Restore(Base::XMLReader &reader)
if (mod.isNull())
throw Py::Exception();
PyObject* cls = mod.getAttr(reader.getAttribute("class")).ptr();
if (!cls) {
std::stringstream s;
s << "Module " << reader.getAttribute("module")
<< " has no class " << reader.getAttribute("class");
throw Py::AttributeError(s.str());
}
#if PY_MAJOR_VERSION >= 3
if (PyType_Check(cls)) {
#else