From 5e484d0a92fc3be5fe0e6dddb91f78759d9fd922 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 29 Apr 2018 11:00:28 +0200 Subject: [PATCH] disable Py::Exception(const std::string&) constructor as it will be removed in future PyCXX versions --- src/CXX/Python2/Exception.hxx | 9 +++++---- src/CXX/Python3/Exception.hxx | 1 + src/Mod/Import/App/AppImportPy.cpp | 2 +- src/Mod/TechDraw/App/AppTechDrawPy.cpp | 10 +++++----- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/CXX/Python2/Exception.hxx b/src/CXX/Python2/Exception.hxx index 160fcbd591..26d02461fe 100644 --- a/src/CXX/Python2/Exception.hxx +++ b/src/CXX/Python2/Exception.hxx @@ -62,10 +62,11 @@ namespace Py explicit Exception () {} - Exception (const std::string& reason) - { - PyErr_SetString (Py::_Exc_RuntimeError(), reason.c_str()); - } + // This overloaded constructor will be removed in future PyCXX versions + //Exception (const std::string& reason) + //{ + // PyErr_SetString (Py::_Exc_RuntimeError(), reason.c_str()); + //} Exception (PyObject* exception, const std::string& reason) { diff --git a/src/CXX/Python3/Exception.hxx b/src/CXX/Python3/Exception.hxx index 6cab35c16a..1b558dc4ce 100644 --- a/src/CXX/Python3/Exception.hxx +++ b/src/CXX/Python3/Exception.hxx @@ -63,6 +63,7 @@ namespace Py explicit Exception () {} + // This overloaded constructor will be removed in future PyCXX versions //Exception (const std::string &reason) //{ // PyErr_SetString( Py::_Exc_RuntimeError(), reason.c_str() ); diff --git a/src/Mod/Import/App/AppImportPy.cpp b/src/Mod/Import/App/AppImportPy.cpp index 508edf87e7..b0a11bb3c3 100644 --- a/src/Mod/Import/App/AppImportPy.cpp +++ b/src/Mod/Import/App/AppImportPy.cpp @@ -366,7 +366,7 @@ private: PyObject *shapeObj; char* name; if (!PyArg_ParseTuple(args.ptr(), "Oet", &shapeObj, "utf-8",&name)) { - throw Py::Exception("expected (Page,path"); + throw Py::TypeError("expected (Page,path"); } std::string filePath = std::string(name); diff --git a/src/Mod/TechDraw/App/AppTechDrawPy.cpp b/src/Mod/TechDraw/App/AppTechDrawPy.cpp index 2a586131e0..9f39da835d 100644 --- a/src/Mod/TechDraw/App/AppTechDrawPy.cpp +++ b/src/Mod/TechDraw/App/AppTechDrawPy.cpp @@ -527,7 +527,7 @@ private: char* name; PyObject *alignObj = Py_True; if (!PyArg_ParseTuple(args.ptr(), "Oet|O", &viewObj, "utf-8",&name,&alignObj)) { - throw Py::Exception("expected (view,path"); + throw Py::TypeError("expected (view,path"); } std::string filePath = std::string(name); @@ -559,15 +559,15 @@ private: } return Py::None(); - } + } Py::Object writeDXFPage(const Py::Tuple& args) { 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); std::string layerName = "none"; @@ -576,7 +576,7 @@ private: try { ImpExpDxfWrite writer(filePath); writer.setLayerName(layerName); - + App::DocumentObject* obj = 0; TechDraw::DrawViewPart* dvp = 0; TechDraw::DrawPage* dp = 0;