From 189ce33e1de5241c8e8e99312ec31cfb80628a14 Mon Sep 17 00:00:00 2001 From: Duy-Nguyen Ta Date: Mon, 19 Dec 2016 17:53:14 -0500 Subject: [PATCH] Support exceptions so ipython/python can catch and doesn't crash. Trade constness with exception since Cython doesn't allow both. See: http://stackoverflow.com/questions/26904268/cython-both-const-and-except-in-c-method-declaration --- wrap/Method.cpp | 3 ++- wrap/StaticMethod.cpp | 2 +- wrap/TemplateMethod.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/wrap/Method.cpp b/wrap/Method.cpp index 45f5e3114..306ea986d 100644 --- a/wrap/Method.cpp +++ b/wrap/Method.cpp @@ -89,7 +89,8 @@ void Method::emit_cython_pxd(FileWriter& file, const Class& cls) const { << "("; argumentList(i).emit_cython_pxd(file, cls.pxdClassName(), cls.templateArgs); file.oss << ")"; - if (is_const_) file.oss << " const"; + // if (is_const_) file.oss << " const"; + file.oss << " except +"; file.oss << "\n"; } } diff --git a/wrap/StaticMethod.cpp b/wrap/StaticMethod.cpp index 25230fec6..e2a5a31ff 100644 --- a/wrap/StaticMethod.cpp +++ b/wrap/StaticMethod.cpp @@ -65,7 +65,7 @@ void StaticMethod::emit_cython_pxd(FileWriter& file, const Class& cls) const { returnVals_[i].emit_cython_pxd(file, cls.pxdClassName(), cls.templateArgs); file.oss << name_ + ((i>0)?"_" + to_string(i):"") << " \"" << name_ << "\"" << "("; argumentList(i).emit_cython_pxd(file, cls.pxdClassName(), cls.templateArgs); - file.oss << ")\n"; + file.oss << ") except +\n"; } } diff --git a/wrap/TemplateMethod.cpp b/wrap/TemplateMethod.cpp index 6435df7f9..d683fed50 100644 --- a/wrap/TemplateMethod.cpp +++ b/wrap/TemplateMethod.cpp @@ -29,7 +29,7 @@ void TemplateMethod::emit_cython_pxd(FileWriter& file, const Class& cls) const { returnVals_[i].emit_cython_pxd(file, cls.pxdClassName(), templateArgs); file.oss << name_ << "[" << argName << "]" << "("; argumentList(i).emit_cython_pxd(file, cls.pxdClassName(), templateArgs); - file.oss << ")\n"; + file.oss << ") except +\n"; } }