From c69f245d6f482c8c78c4a4a78f5ce63d1f0eb3c9 Mon Sep 17 00:00:00 2001 From: luz paz Date: Sat, 24 Apr 2021 09:32:38 -0400 Subject: [PATCH] Part: remove py2 code --- src/Mod/Part/App/AppPartPy.cpp | 5 ----- src/Mod/Part/App/AttachEnginePyImp.cpp | 17 ---------------- src/Mod/Part/App/BSplineCurvePyImp.cpp | 8 -------- src/Mod/Part/App/BSplineSurfacePyImp.cpp | 16 --------------- .../Part/App/Geom2d/BSplineCurve2dPyImp.cpp | 20 ------------------- src/Mod/Part/App/GeometryCurvePyImp.cpp | 7 ------- src/Mod/Part/App/PropertyTopoShape.cpp | 8 -------- src/Mod/Part/App/TopoShapeEdgePyImp.cpp | 7 ------- src/Mod/Part/App/TopoShapePyImp.cpp | 10 ---------- src/Mod/Part/App/TopoShapeWirePyImp.cpp | 7 ------- src/Mod/Part/Gui/AppPartGui.cpp | 5 ----- 11 files changed, 110 deletions(-) diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index afffec947d16..a0d8f59febd0 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -2023,13 +2023,8 @@ class Module : public Py::ExtensionModule PyErr_Clear(); PyObject* index_or_value; if (PyArg_ParseTuple(args.ptr(), "sO", &name, &index_or_value)) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(index_or_value)) { int ival = (int)PyLong_AsLong(index_or_value); -#else - if (PyInt_Check(index_or_value)) { - int ival = (int)PyInt_AsLong(index_or_value); -#endif if (!Interface_Static::SetIVal(name, ival)) { std::stringstream str; str << "Failed to set '" << name << "'"; diff --git a/src/Mod/Part/App/AttachEnginePyImp.cpp b/src/Mod/Part/App/AttachEnginePyImp.cpp index 0057a048ae85..31c93ac01e78 100644 --- a/src/Mod/Part/App/AttachEnginePyImp.cpp +++ b/src/Mod/Part/App/AttachEnginePyImp.cpp @@ -277,11 +277,7 @@ PyObject* AttachEnginePy::getModeInfo(PyObject* args) } Py::Dict ret; ret["ReferenceCombinations"] = pyListOfCombinations; -#if PY_MAJOR_VERSION >= 3 ret["ModeIndex"] = Py::Long(mmode); -#else - ret["ModeIndex"] = Py::Int(mmode); -#endif try { Py::Module module(PyImport_ImportModule("PartGui"),true); if (module.isNull() || !module.hasAttr("AttachEngineResources")) { @@ -292,11 +288,7 @@ PyObject* AttachEnginePy::getModeInfo(PyObject* args) Py::Callable method(submod.getAttr("getModeStrings")); Py::Tuple arg(2); arg.setItem(0, Py::String(this->getAttachEnginePtr()->getTypeId().getName())); -#if PY_MAJOR_VERSION >= 3 arg.setItem(1, Py::Long(mmode)); -#else - arg.setItem(1, Py::Int(mmode)); -#endif Py::List strs = method.apply(arg); assert(strs.size() == 2); ret["UserFriendlyName"] = strs[0]; @@ -369,13 +361,8 @@ PyObject* AttachEnginePy::getRefTypeInfo(PyObject* args) AttachEngine &attacher = *(this->getAttachEnginePtr()); eRefType rt = attacher.getRefTypeByName(typeName); Py::Dict ret; -#if PY_MAJOR_VERSION >= 3 ret["TypeIndex"] = Py::Long(rt); ret["Rank"] = Py::Long(AttachEngine::getTypeRank(rt)); -#else - ret["TypeIndex"] = Py::Int(rt); - ret["Rank"] = Py::Int(AttachEngine::getTypeRank(rt)); -#endif try { Py::Module module(PyImport_ImportModule("PartGui"),true); @@ -386,11 +373,7 @@ PyObject* AttachEnginePy::getRefTypeInfo(PyObject* args) Py::Object submod(module.getAttr("AttachEngineResources")); Py::Callable method(submod.getAttr("getRefTypeUserFriendlyName")); Py::Tuple arg(1); -#if PY_MAJOR_VERSION >= 3 arg.setItem(0, Py::Long(rt)); -#else - arg.setItem(0, Py::Int(rt)); -#endif Py::String st = method.apply(arg); ret["UserFriendlyName"] = st; } catch (Py::Exception& e) { diff --git a/src/Mod/Part/App/BSplineCurvePyImp.cpp b/src/Mod/Part/App/BSplineCurvePyImp.cpp index e4c84ca343eb..b6084fe76c74 100644 --- a/src/Mod/Part/App/BSplineCurvePyImp.cpp +++ b/src/Mod/Part/App/BSplineCurvePyImp.cpp @@ -250,11 +250,7 @@ PyObject* BSplineCurvePy::insertKnots(PyObject * args) TColStd_Array1OfInteger m(1,mults.size()); index=1; for (Py::Sequence::iterator it = mults.begin(); it != mults.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long val(*it); -#else - Py::Int val(*it); -#endif m(index++) = (int)val; } @@ -1253,11 +1249,7 @@ PyObject* BSplineCurvePy::buildFromPolesMultsKnots(PyObject *args, PyObject *key Py::Sequence multssq(mults); Standard_Integer index = 1; for (Py::Sequence::iterator it = multssq.begin(); it != multssq.end() && index <= occmults.Length(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long mult(*it); -#else - Py::Int mult(*it); -#endif if (index < occmults.Length() || PyObject_Not(periodic)) { sum_of_mults += static_cast(mult); //sum up the mults to compare them against the number of poles later } diff --git a/src/Mod/Part/App/BSplineSurfacePyImp.cpp b/src/Mod/Part/App/BSplineSurfacePyImp.cpp index da7f502fc6a7..9b368f476fbf 100644 --- a/src/Mod/Part/App/BSplineSurfacePyImp.cpp +++ b/src/Mod/Part/App/BSplineSurfacePyImp.cpp @@ -284,11 +284,7 @@ PyObject* BSplineSurfacePy::insertUKnots(PyObject *args) TColStd_Array1OfInteger m(1,mults.size()); index=1; for (Py::Sequence::iterator it = mults.begin(); it != mults.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long val(*it); -#else - Py::Int val(*it); -#endif m(index++) = (int)val; } @@ -349,11 +345,7 @@ PyObject* BSplineSurfacePy::insertVKnots(PyObject *args) TColStd_Array1OfInteger m(1,mults.size()); index=1; for (Py::Sequence::iterator it = mults.begin(); it != mults.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long val(*it); -#else - Py::Int val(*it); -#endif m(index++) = (int)val; } @@ -1423,11 +1415,7 @@ PyObject* BSplineSurfacePy::buildFromPolesMultsKnots(PyObject *args, PyObject *k Py::Sequence umultssq(umults); Standard_Integer index = 1; for (Py::Sequence::iterator it = umultssq.begin(); it != umultssq.end() && index <= occumults.Length(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long mult(*it); -#else - Py::Int mult(*it); -#endif if (index < occumults.Length() || PyObject_Not(uperiodic)) { sum_of_umults += static_cast(mult); //sum up the mults to compare them against the number of poles later } @@ -1436,11 +1424,7 @@ PyObject* BSplineSurfacePy::buildFromPolesMultsKnots(PyObject *args, PyObject *k Py::Sequence vmultssq(vmults); index = 1; for (Py::Sequence::iterator it = vmultssq.begin(); it != vmultssq.end() && index <= occvmults.Length(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long mult(*it); -#else - Py::Int mult(*it); -#endif if (index < occvmults.Length() || PyObject_Not(vperiodic)) { sum_of_vmults += static_cast(mult); //sum up the mults to compare them against the number of poles later } diff --git a/src/Mod/Part/App/Geom2d/BSplineCurve2dPyImp.cpp b/src/Mod/Part/App/Geom2d/BSplineCurve2dPyImp.cpp index e0f7a8238af9..1c69f6211ec6 100644 --- a/src/Mod/Part/App/Geom2d/BSplineCurve2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/BSplineCurve2dPyImp.cpp @@ -214,11 +214,7 @@ PyObject* BSplineCurve2dPy::insertKnots(PyObject * args) TColStd_Array1OfInteger m(1,mults.size()); index=1; for (Py::Sequence::iterator it = mults.begin(); it != mults.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long val(*it); -#else - Py::Int val(*it); -#endif m(index++) = (int)val; } @@ -649,11 +645,7 @@ PyObject* BSplineCurve2dPy::getMultiplicities(PyObject * args) curve->Multiplicities(m); Py::List mults; for (Standard_Integer i=m.Lower(); i<=m.Upper(); i++) { -#if PY_MAJOR_VERSION >= 3 mults.append(Py::Long(m(i))); -#else - mults.append(Py::Int(m(i))); -#endif } return Py::new_reference_to(mults); } @@ -724,22 +716,14 @@ Py::Object BSplineCurve2dPy::getFirstUKnotIndex(void) const { Handle(Geom2d_BSplineCurve) curve = Handle(Geom2d_BSplineCurve)::DownCast (getGeometry2dPtr()->handle()); -#if PY_MAJOR_VERSION >= 3 return Py::Long(curve->FirstUKnotIndex()); -#else - return Py::Int(curve->FirstUKnotIndex()); -#endif } Py::Object BSplineCurve2dPy::getLastUKnotIndex(void) const { Handle(Geom2d_BSplineCurve) curve = Handle(Geom2d_BSplineCurve)::DownCast (getGeometry2dPtr()->handle()); -#if PY_MAJOR_VERSION >= 3 return Py::Long(curve->LastUKnotIndex()); -#else - return Py::Int(curve->LastUKnotIndex()); -#endif } Py::List BSplineCurve2dPy::getKnotSequence(void) const @@ -1224,11 +1208,7 @@ PyObject* BSplineCurve2dPy::buildFromPolesMultsKnots(PyObject *args, PyObject *k Py::Sequence multssq(mults); Standard_Integer index = 1; for (Py::Sequence::iterator it = multssq.begin(); it != multssq.end() && index <= occmults.Length(); ++it) { -#if PY_MAJOR_VERSION >=3 Py::Long mult(*it); -#else - Py::Int mult(*it); -#endif if (index < occmults.Length() || PyObject_Not(periodic)) { sum_of_mults += (int)mult; //sum up the mults to compare them against the number of poles later } diff --git a/src/Mod/Part/App/GeometryCurvePyImp.cpp b/src/Mod/Part/App/GeometryCurvePyImp.cpp index 813a8932ab11..6cc12f6760f3 100644 --- a/src/Mod/Part/App/GeometryCurvePyImp.cpp +++ b/src/Mod/Part/App/GeometryCurvePyImp.cpp @@ -149,17 +149,10 @@ PyObject* GeometryCurvePy::discretize(PyObject *args, PyObject *kwds) // use no kwds PyObject* dist_or_num; if (PyArg_ParseTuple(args, "O", &dist_or_num)) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(dist_or_num)) { numPoints = PyLong_AsLong(dist_or_num); uniformAbscissaPoints = true; } -#else - if (PyInt_Check(dist_or_num)) { - numPoints = PyInt_AsLong(dist_or_num); - uniformAbscissaPoints = true; - } -#endif else if (PyFloat_Check(dist_or_num)) { distance = PyFloat_AsDouble(dist_or_num); uniformAbscissaDistance = true; diff --git a/src/Mod/Part/App/PropertyTopoShape.cpp b/src/Mod/Part/App/PropertyTopoShape.cpp index ca011e5e4b9b..6743402e0ac1 100644 --- a/src/Mod/Part/App/PropertyTopoShape.cpp +++ b/src/Mod/Part/App/PropertyTopoShape.cpp @@ -507,11 +507,7 @@ PyObject *PropertyFilletEdges::getPyObject(void) int index = 0; for (it = _lValueList.begin(); it != _lValueList.end(); ++it) { Py::Tuple ent(3); -#if PY_MAJOR_VERSION >= 3 ent.setItem(0, Py::Long(it->edgeid)); -#else - ent.setItem(0, Py::Int(it->edgeid)); -#endif ent.setItem(1, Py::Float(it->radius1)); ent.setItem(2, Py::Float(it->radius2)); list[index++] = ent; @@ -528,11 +524,7 @@ void PropertyFilletEdges::setPyObject(PyObject *value) for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { FilletElement fe; Py::Tuple ent(*it); -#if PY_MAJOR_VERSION >= 3 fe.edgeid = (int)Py::Long(ent.getItem(0)); -#else - fe.edgeid = (int)Py::Int(ent.getItem(0)); -#endif fe.radius1 = (double)Py::Float(ent.getItem(1)); fe.radius2 = (double)Py::Float(ent.getItem(2)); values.push_back(fe); diff --git a/src/Mod/Part/App/TopoShapeEdgePyImp.cpp b/src/Mod/Part/App/TopoShapeEdgePyImp.cpp index a915a4a750e0..dd124fef3973 100644 --- a/src/Mod/Part/App/TopoShapeEdgePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeEdgePyImp.cpp @@ -491,17 +491,10 @@ PyObject* TopoShapeEdgePy::discretize(PyObject *args, PyObject *kwds) // use no kwds PyObject* dist_or_num; if (PyArg_ParseTuple(args, "O", &dist_or_num)) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(dist_or_num)) { numPoints = PyLong_AsLong(dist_or_num); uniformAbscissaPoints = true; } -#else - if (PyInt_Check(dist_or_num)) { - numPoints = PyInt_AsLong(dist_or_num); - uniformAbscissaPoints = true; - } -#endif else if (PyFloat_Check(dist_or_num)) { distance = PyFloat_AsDouble(dist_or_num); uniformAbscissaDistance = true; diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index 89dc9c5766af..6d3edd729f0c 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -2150,15 +2150,9 @@ PyObject* TopoShapePy::makeShapeFromMesh(PyObject *args) for (Py::Sequence::iterator it = facets.begin(); it != facets.end(); ++it) { Data::ComplexGeoData::Facet face; Py::Tuple f(*it); -#if PY_MAJOR_VERSION >= 3 face.I1 = (int)Py::Long(f[0]); face.I2 = (int)Py::Long(f[1]); face.I3 = (int)Py::Long(f[2]); -#else - face.I1 = (int)Py::Int(f[0]); - face.I2 = (int)Py::Int(f[1]); - face.I3 = (int)Py::Int(f[2]); -#endif Facets.push_back(face); } @@ -2547,11 +2541,7 @@ PyObject* _getSupportIndex(const char* suppStr, TopoShape* ts, TopoDS_Shape supp break; } } -#if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(supportIndex); -#else - return PyInt_FromLong(supportIndex); -#endif } PyObject* TopoShapePy::proximity(PyObject *args) diff --git a/src/Mod/Part/App/TopoShapeWirePyImp.cpp b/src/Mod/Part/App/TopoShapeWirePyImp.cpp index 800546abb247..95c1aff6814a 100644 --- a/src/Mod/Part/App/TopoShapeWirePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeWirePyImp.cpp @@ -376,17 +376,10 @@ PyObject* TopoShapeWirePy::discretize(PyObject *args, PyObject *kwds) // use no kwds PyObject* dist_or_num; if (PyArg_ParseTuple(args, "O", &dist_or_num)) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(dist_or_num)) { numPoints = PyLong_AsLong(dist_or_num); uniformAbscissaPoints = true; } -#else - if (PyInt_Check(dist_or_num)) { - numPoints = PyInt_AsLong(dist_or_num); - uniformAbscissaPoints = true; - } -#endif else if (PyFloat_Check(dist_or_num)) { distance = PyFloat_AsDouble(dist_or_num); uniformAbscissaDistance = true; diff --git a/src/Mod/Part/Gui/AppPartGui.cpp b/src/Mod/Part/Gui/AppPartGui.cpp index e6c62db27b56..1addb59b7007 100644 --- a/src/Mod/Part/Gui/AppPartGui.cpp +++ b/src/Mod/Part/Gui/AppPartGui.cpp @@ -132,7 +132,6 @@ PyMOD_INIT_FUNC(PartGui) Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/parametric")); Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/tools")); -#if PY_MAJOR_VERSION >= 3 static struct PyModuleDef pAttachEngineTextsModuleDef = { PyModuleDef_HEAD_INIT, "AttachEngineResources", @@ -141,10 +140,6 @@ PyMOD_INIT_FUNC(PartGui) NULL, NULL, NULL, NULL }; PyObject* pAttachEngineTextsModule = PyModule_Create(&pAttachEngineTextsModuleDef); -#else - PyObject* pAttachEngineTextsModule = Py_InitModule3("AttachEngineResources", AttacherGui::AttacherGuiPy::Methods, - "AttachEngine Gui resources"); -#endif Py_INCREF(pAttachEngineTextsModule); PyModule_AddObject(partGuiModule, "AttachEngineResources", pAttachEngineTextsModule);