Make sure C++ exceptions do not crash the Python interpreter

This commit is contained in:
Thomas Krijnen
2015-01-26 18:11:48 +00:00
parent b789839e4a
commit 4c79f713ed
2 changed files with 12 additions and 0 deletions
+9
View File
@@ -100,6 +100,10 @@ namespace IfcUtil {
}
%typemap(out) std::pair<IfcUtil::ArgumentType, Argument*> {
// The SWIG %exception directive does not take care
// of our typemap. So the argument conversion block
// is wrapped in a try-catch block manually.
try {
const Argument& arg = *($1.second);
const IfcUtil::ArgumentType type = $1.first;
if (arg.isNull() || type == IfcUtil::Argument_DERIVED) {
@@ -164,6 +168,11 @@ namespace IfcUtil {
break;
}
}
} catch(IfcParse::IfcException& e) {
SWIG_exception(SWIG_RuntimeError, e.what());
} catch(...) {
SWIG_exception(SWIG_RuntimeError, "An unknown error occurred");
}
}
%extend IfcParse::IfcFile {