prepare for PyCXX 7.0

This commit is contained in:
wmayer
2018-04-18 19:20:50 +02:00
parent 08286c407e
commit 99ec96acd5
36 changed files with 226 additions and 239 deletions

View File

@@ -1277,7 +1277,7 @@ private:
PyObject *pleft=Py_False;
if (!PyArg_ParseTuple(args.ptr(), "ddd|dO!", &pitch, &height, &radius, &angle,
&(PyBool_Type), &pleft)) {
throw Py::Exception("Part.makeLongHelix fails on parms");
throw Py::RuntimeError("Part.makeLongHelix fails on parms");
}
try {

View File

@@ -148,7 +148,7 @@ void ArcOfConicPy::setAxis(Py::Object arg)
conic->SetAxis(axis);
}
catch (Standard_Failure) {
throw Py::Exception("cannot set axis");
throw Py::RuntimeError("cannot set axis");
}
}
@@ -188,7 +188,7 @@ void ArcOfConicPy::setXAxis(Py::Object arg)
conic->SetPosition(pos);
}
catch (Standard_Failure) {
throw Py::Exception("cannot set X axis");
throw Py::RuntimeError("cannot set X axis");
}
}
@@ -228,7 +228,7 @@ void ArcOfConicPy::setYAxis(Py::Object arg)
conic->SetPosition(pos);
}
catch (Standard_Failure) {
throw Py::Exception("cannot set Y axis");
throw Py::RuntimeError("cannot set Y axis");
}
}

View File

@@ -296,7 +296,7 @@ void ConePy::setAxis(Py::Object arg)
this_surf->SetAxis(axis);
}
catch (Standard_Failure) {
throw Py::Exception("cannot set axis");
throw Py::RuntimeError("cannot set axis");
}
}

View File

@@ -151,7 +151,7 @@ void ConicPy::setAxis(Py::Object arg)
conic->SetAxis(axis);
}
catch (Standard_Failure) {
throw Py::Exception("cannot set axis");
throw Py::RuntimeError("cannot set axis");
}
}
@@ -187,7 +187,7 @@ void ConicPy::setXAxis(Py::Object arg)
conic->SetPosition(pos);
}
catch (Standard_Failure) {
throw Py::Exception("cannot set X axis");
throw Py::RuntimeError("cannot set X axis");
}
}
@@ -223,7 +223,7 @@ void ConicPy::setYAxis(Py::Object arg)
conic->SetPosition(pos);
}
catch (Standard_Failure) {
throw Py::Exception("cannot set Y axis");
throw Py::RuntimeError("cannot set Y axis");
}
}

View File

@@ -293,7 +293,7 @@ void CylinderPy::setAxis(Py::Object arg)
this_surf->SetAxis(axis);
}
catch (Standard_Failure) {
throw Py::Exception("cannot set axis");
throw Py::RuntimeError("cannot set axis");
}
}

View File

@@ -163,7 +163,7 @@ void Line2dPy::setLocation(Py::Object arg)
try {
GCE2d_MakeLine ms(pnt, dir);
if (!ms.IsDone()) {
throw Py::Exception(gce_ErrorStatusText(ms.Status()));
throw Py::RuntimeError(gce_ErrorStatusText(ms.Status()));
}
// get Geom_Line of line
@@ -171,8 +171,7 @@ void Line2dPy::setLocation(Py::Object arg)
this_line->SetLin2d(that_line->Lin2d());
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}
@@ -218,7 +217,7 @@ void Line2dPy::setDirection(Py::Object arg)
try {
GCE2d_MakeLine ms(pnt, dir);
if (!ms.IsDone()) {
throw Py::Exception(gce_ErrorStatusText(ms.Status()));
throw Py::RuntimeError(gce_ErrorStatusText(ms.Status()));
}
// get Geom_Line of line
@@ -226,8 +225,7 @@ void Line2dPy::setDirection(Py::Object arg)
this_line->SetLin2d(that_line->Lin2d());
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}

View File

@@ -240,7 +240,7 @@ void Line2dSegmentPy::setStartPoint(Py::Object arg)
Standard_Failure::Raise("Both points are equal");
GCE2d_MakeSegment ms(p1, p2);
if (!ms.IsDone()) {
throw Py::Exception(gce_ErrorStatusText(ms.Status()));
throw Py::RuntimeError(gce_ErrorStatusText(ms.Status()));
}
// get Geom_Line of line segment
@@ -252,8 +252,7 @@ void Line2dSegmentPy::setStartPoint(Py::Object arg)
this_curv->SetTrim(that_curv->FirstParameter(), that_curv->LastParameter());
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}
@@ -301,7 +300,7 @@ void Line2dSegmentPy::setEndPoint(Py::Object arg)
Standard_Failure::Raise("Both points are equal");
GCE2d_MakeSegment ms(p1, p2);
if (!ms.IsDone()) {
throw Py::Exception(gce_ErrorStatusText(ms.Status()));
throw Py::RuntimeError(gce_ErrorStatusText(ms.Status()));
}
// get Geom_Line of line segment
@@ -313,8 +312,7 @@ void Line2dSegmentPy::setEndPoint(Py::Object arg)
this_curv->SetTrim(that_curv->FirstParameter(), that_curv->LastParameter());
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}

View File

@@ -122,8 +122,7 @@ void OffsetCurve2dPy::setBasisCurve(Py::Object arg)
curve2->SetBasisCurve(curve);
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}
}

View File

@@ -161,7 +161,7 @@ void LinePy::setLocation(Py::Object arg)
try {
GC_MakeLine ms(pnt, dir);
if (!ms.IsDone()) {
throw Py::Exception(gce_ErrorStatusText(ms.Status()));
throw Py::RuntimeError(gce_ErrorStatusText(ms.Status()));
}
// get Geom_Line of line
@@ -169,8 +169,7 @@ void LinePy::setLocation(Py::Object arg)
this_curv->SetLin(that_curv->Lin());
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}
@@ -211,7 +210,7 @@ void LinePy::setDirection(Py::Object arg)
try {
GC_MakeLine ms(pnt, dir);
if (!ms.IsDone()) {
throw Py::Exception(gce_ErrorStatusText(ms.Status()));
throw Py::RuntimeError(gce_ErrorStatusText(ms.Status()));
}
// get Geom_Line of line
@@ -219,8 +218,7 @@ void LinePy::setDirection(Py::Object arg)
this_curv->SetLin(that_curv->Lin());
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}

View File

@@ -196,7 +196,6 @@ PyObject* LineSegmentPy::setParameterRange(PyObject *args)
this_curve->SetTrim(first, last);
}
catch (Standard_Failure& e) {
PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
return NULL;
}
@@ -244,7 +243,7 @@ void LineSegmentPy::setStartPoint(Py::Object arg)
Standard_Failure::Raise("Both points are equal");
GC_MakeSegment ms(p1, p2);
if (!ms.IsDone()) {
throw Py::Exception(gce_ErrorStatusText(ms.Status()));
throw Py::RuntimeError(gce_ErrorStatusText(ms.Status()));
}
// get Geom_Line of line segment
@@ -256,8 +255,7 @@ void LineSegmentPy::setStartPoint(Py::Object arg)
this_curv->SetTrim(that_curv->FirstParameter(), that_curv->LastParameter());
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}
@@ -301,7 +299,7 @@ void LineSegmentPy::setEndPoint(Py::Object arg)
Standard_Failure::Raise("Both points are equal");
GC_MakeSegment ms(p1, p2);
if (!ms.IsDone()) {
throw Py::Exception(gce_ErrorStatusText(ms.Status()));
throw Py::RuntimeError(gce_ErrorStatusText(ms.Status()));
}
// get Geom_Line of line segment
@@ -313,8 +311,7 @@ void LineSegmentPy::setEndPoint(Py::Object arg)
this_curv->SetTrim(that_curv->FirstParameter(), that_curv->LastParameter());
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}

View File

@@ -145,8 +145,7 @@ void OffsetCurvePy::setBasisCurve(Py::Object arg)
curve2->SetBasisCurve(curve);
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}
}

View File

@@ -120,8 +120,7 @@ void OffsetSurfacePy::setBasisSurface(Py::Object arg)
surf2->SetBasisSurface(surf);
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}
}

View File

@@ -208,8 +208,7 @@ void PlanePy::setPosition(Py::Object arg)
this_surf->SetLocation(loc);
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}
@@ -252,7 +251,7 @@ void PlanePy::setAxis(Py::Object arg)
this_surf->SetAxis(axis);
}
catch (Standard_Failure) {
throw Py::Exception("cannot set axis");
throw Py::RuntimeError("cannot set axis");
}
}

View File

@@ -144,8 +144,7 @@ void PointPy::setX(Py::Float X)
this_point->SetX(double(X));
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}
@@ -165,8 +164,7 @@ void PointPy::setY(Py::Float Y)
this_point->SetY(double(Y));
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}
@@ -186,8 +184,7 @@ void PointPy::setZ(Py::Float Z)
this_point->SetZ(double(Z));
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}

View File

@@ -177,7 +177,7 @@ void SpherePy::setAxis(Py::Object arg)
this_surf->SetAxis(axis);
}
catch (Standard_Failure) {
throw Py::Exception("cannot set axis");
throw Py::RuntimeError("cannot set axis");
}
}

View File

@@ -139,8 +139,7 @@ void SurfaceOfExtrusionPy::setBasisCurve(Py::Object arg)
curve2->SetBasisCurve(curve);
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}
}

View File

@@ -166,8 +166,7 @@ void SurfaceOfRevolutionPy::setBasisCurve(Py::Object arg)
curve2->SetBasisCurve(curve);
}
catch (Standard_Failure& e) {
throw Py::Exception(e.GetMessageString());
throw Py::RuntimeError(e.GetMessageString());
}
}
}

View File

@@ -1000,7 +1000,7 @@ Py::Dict TopoShapeEdgePy::getPrincipalProperties(void) const
Py::Boolean TopoShapeEdgePy::getClosed(void) const
{
if (getTopoShapePtr()->getShape().IsNull())
throw Py::Exception("Cannot determine the 'Closed'' flag of an empty shape");
throw Py::RuntimeError("Cannot determine the 'Closed'' flag of an empty shape");
Standard_Boolean ok = BRep_Tool::IsClosed(getTopoShapePtr()->getShape());
return Py::Boolean(ok ? true : false);
}

View File

@@ -873,14 +873,14 @@ Py::Object TopoShapeFacePy::getOuterWire(void) const
{
const TopoDS_Shape& clSh = getTopoShapePtr()->getShape();
if (clSh.IsNull())
throw Py::Exception("Null shape");
throw Py::RuntimeError("Null shape");
if (clSh.ShapeType() == TopAbs_FACE) {
TopoDS_Face clFace = (TopoDS_Face&)clSh;
TopoDS_Wire clWire = ShapeAnalysis::OuterWire(clFace);
return Py::Object(new TopoShapeWirePy(new TopoShape(clWire)),true);
}
else {
throw Py::Exception("Internal error, TopoDS_Shape is not a face!");
throw Py::TypeError("Internal error, TopoDS_Shape is not a face!");
}
}

View File

@@ -119,7 +119,7 @@ void ToroidPy::setMajorRadius(Py::Float arg)
torus->SetMajorRadius((double)arg);
}
catch (Standard_Failure) {
throw Py::Exception("Major radius must be positive and higher than minor radius");
throw Py::RuntimeError("Major radius must be positive and higher than minor radius");
}
}
@@ -138,7 +138,7 @@ void ToroidPy::setMinorRadius(Py::Float arg)
torus->SetMinorRadius((double)arg);
}
catch (Standard_Failure) {
throw Py::Exception("Minor radius must be positive and lower than major radius");
throw Py::RuntimeError("Minor radius must be positive and lower than major radius");
}
}
@@ -205,7 +205,7 @@ void ToroidPy::setAxis(Py::Object arg)
this_surf->SetAxis(axis);
}
catch (Standard_Failure) {
throw Py::Exception("cannot set axis");
throw Py::RuntimeError("cannot set axis");
}
}

View File

@@ -168,7 +168,7 @@ void CommandPy::setParameters(Py::Dict arg)
#endif
}
else {
throw Py::Exception("The dictionary can only contain string keys");
throw Py::TypeError("The dictionary can only contain string keys");
}
boost::to_upper(ckey);
@@ -185,7 +185,7 @@ void CommandPy::setParameters(Py::Dict arg)
cvalue = PyFloat_AsDouble(value);
}
else {
throw Py::Exception("The dictionary can only contain number values");
throw Py::TypeError("The dictionary can only contain number values");
}
getCommandPtr()->Parameters[ckey]=cvalue;
}
@@ -202,7 +202,7 @@ PyObject* CommandPy::toGCode(PyObject *args)
return PyString_FromString(getCommandPtr()->toGCode().c_str());
#endif
}
throw Py::Exception("This method accepts no argument");
throw Py::TypeError("This method accepts no argument");
}
PyObject* CommandPy::setFromGCode(PyObject *args)
@@ -214,7 +214,7 @@ PyObject* CommandPy::setFromGCode(PyObject *args)
Py_INCREF(Py_None);
return Py_None;
}
throw Py::Exception("Argument must be a string");
throw Py::TypeError("Argument must be a string");
}
// Placement attribute get/set
@@ -231,7 +231,7 @@ void CommandPy::setPlacement(Py::Object arg)
if(arg.isType(PlacementType)) {
getCommandPtr()->setFromPlacement( *static_cast<Base::PlacementPy*>((*arg))->getPlacementPtr() );
} else
throw Py::Exception("Argument must be a placement");
throw Py::TypeError("Argument must be a placement");
}
PyObject* CommandPy::transform(PyObject *args)
@@ -242,7 +242,7 @@ PyObject* CommandPy::transform(PyObject *args)
Path::Command trCmd = getCommandPtr()->transform( *p->getPlacementPtr() );
return new CommandPy(new Path::Command(trCmd));
} else
throw Py::Exception("Argument must be a placement");
throw Py::TypeError("Argument must be a placement");
}
// custom attributes get/set

View File

@@ -100,7 +100,7 @@ void PathPy::setCommands(Py::List list)
Path::Command &cmd = *static_cast<Path::CommandPy*>((*it).ptr())->getCommandPtr();
getToolpathPtr()->addCommand(cmd);
} else {
throw Py::Exception("The list can only contain Path Commands");
throw Py::TypeError("The list can only contain Path Commands");
}
}
}
@@ -124,7 +124,7 @@ PyObject* PathPy::copy(PyObject * args)
if (PyArg_ParseTuple(args, "")) {
return new PathPy(new Path::Toolpath(*getToolpathPtr()));
}
throw Py::Exception("This method accepts no argument");
throw Py::TypeError("This method accepts no argument");
}
PyObject* PathPy::addCommands(PyObject * args)
@@ -184,7 +184,7 @@ PyObject* PathPy::toGCode(PyObject * args)
return PyString_FromString(result.c_str());
#endif
}
throw Py::Exception("This method accepts no argument");
throw Py::TypeError("This method accepts no argument");
}
PyObject* PathPy::setFromGCode(PyObject * args)
@@ -196,7 +196,7 @@ PyObject* PathPy::setFromGCode(PyObject * args)
Py_INCREF(Py_None);
return Py_None;
}
throw Py::Exception("Argument must be a string");
throw Py::TypeError("Argument must be a string");
}
// custom attributes get/set

View File

@@ -223,7 +223,7 @@ PyObject* ToolPy::copy(PyObject * args)
if (PyArg_ParseTuple(args, "")) {
return new ToolPy(new Path::Tool(*getToolPtr()));
}
throw Py::Exception("This method accepts no argument");
throw Py::TypeError("This method accepts no argument");
}
PyObject* ToolPy::setFromTemplate(PyObject * args)
@@ -276,7 +276,7 @@ PyObject* ToolPy::templateAttrs(PyObject * args)
PyDict_SetItemString(dict, "cuttingEdgeHeight", PyFloat_FromDouble(getToolPtr()->CuttingEdgeHeight));
return dict;
}
throw Py::Exception("This method accepts no argument");
throw Py::TypeError("This method accepts no argument");
}
PyObject* ToolPy::getToolTypes(PyObject * args)
@@ -290,7 +290,7 @@ PyObject* ToolPy::getToolTypes(PyObject * args)
}
return list;
}
throw Py::Exception("This method accepts no argument");
throw Py::TypeError("This method accepts no argument");
}
PyObject* ToolPy::getToolMaterials(PyObject * args)
@@ -304,7 +304,7 @@ PyObject* ToolPy::getToolMaterials(PyObject * args)
}
return list;
}
throw Py::Exception("This method accepts no argument");
throw Py::TypeError("This method accepts no argument");
}
@@ -405,7 +405,7 @@ void TooltablePy::setTools(Py::Dict arg)
Py_DECREF(success);
}
} else {
throw Py::Exception("The dictionary can only contain int:tool pairs");
throw Py::TypeError("The dictionary can only contain int:tool pairs");
}
}
}
@@ -417,7 +417,7 @@ PyObject* TooltablePy::copy(PyObject * args)
if (PyArg_ParseTuple(args, "")) {
return new TooltablePy(new Path::Tooltable(*getTooltablePtr()));
}
throw Py::Exception("This method accepts no argument");
throw Py::TypeError("This method accepts no argument");
}
PyObject* TooltablePy::addTools(PyObject * args)

View File

@@ -79,13 +79,13 @@ PyObject *DocumentProtectorPy::method_varargs_ext_handler(PyObject *_self_and_na
return pycxx_handler(_self_and_name_tuple, _args);
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
}

View File

@@ -134,7 +134,7 @@ private:
PyObject *pcObj;
PyObject *inclBig = Py_True;
if (!PyArg_ParseTuple(args.ptr(), "O!|O", &(PyList_Type), &pcObj, &inclBig)) {
throw Py::Exception("expected (listofedges,boolean");
throw Py::TypeError("expected (listofedges,boolean");
}
std::vector<TopoDS_Edge> edgeList;
@@ -191,7 +191,7 @@ private:
{
PyObject *pcObj;
if (!PyArg_ParseTuple(args.ptr(), "O!", &(PyList_Type), &pcObj)) {
throw Py::Exception("expected (listofedges)");
throw Py::TypeError("expected (listofedges)");
}
std::vector<TopoDS_Edge> edgeList;
@@ -248,7 +248,7 @@ private:
if (!PyArg_ParseTuple(args.ptr(), "OdO", &pcObjShape,
&scale,
&pcObjDir)) {
throw Py::Exception("expected (shape,scale,direction");
throw Py::TypeError("expected (shape,scale,direction");
}
if (!PyObject_TypeCheck(pcObjShape, &(TopoShapePy::Type))) {
@@ -308,7 +308,7 @@ private:
{
PyObject *viewObj;
if (!PyArg_ParseTuple(args.ptr(), "O", &viewObj)) {
throw Py::Exception("expected (DrawViewPart)");
throw Py::TypeError("expected (DrawViewPart)");
}
Py::String dxfReturn;
@@ -363,7 +363,7 @@ private:
{
PyObject *viewObj;
if (!PyArg_ParseTuple(args.ptr(), "O", &viewObj)) {
throw Py::Exception("expected (DrawViewPart)");
throw Py::TypeError("expected (DrawViewPart)");
}
Py::String svgReturn;
std::string grpHead1 = "<g fill=\"none\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"";

View File

@@ -43,7 +43,7 @@ PyObject* DrawViewSymbolPy::dumpSymbol(PyObject *args)
} else {
std::string error = std::string("Can't write ");
error += fileSpec;
throw Py::Exception(error);
throw Py::RuntimeError(error);
}
Py_Return;
}

View File

@@ -110,7 +110,7 @@ private:
PyObject *pageObj;
char* name;
if (!PyArg_ParseTuple(args.ptr(), "Oet", &pageObj, "utf-8",&name)) {
throw Py::Exception("expected (Page,path");
throw Py::TypeError("expected (Page,path");
}
std::string filePath = std::string(name);
@@ -151,7 +151,7 @@ private:
PyObject *pageObj;
char* name;
if (!PyArg_ParseTuple(args.ptr(), "Oet", &pageObj, "utf-8",&name)) {
throw Py::Exception("expected (Page,path");
throw Py::TypeError("expected (Page,path");
}
std::string filePath = std::string(name);