From ed47e962d2c821bf1792889f6d7bdf457dcf6c9e Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 2 Jun 2019 18:06:46 +0200 Subject: [PATCH] Py3: fix crash if class is not part of a module any more --- src/App/PropertyPythonObject.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/App/PropertyPythonObject.cpp b/src/App/PropertyPythonObject.cpp index 906debfd13..7a1ebd0c25 100644 --- a/src/App/PropertyPythonObject.cpp +++ b/src/App/PropertyPythonObject.cpp @@ -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