From: Corbin Simpson Date: Fri, 3 Sep 2010 20:26:08 +0000 (-0700) Subject: ExprNodes: Add C++ error handling for std::invalid_argument. X-Git-Tag: 0.14.alpha0~351 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=184482af6eb1e68f2a1c063cd5be4ab18aab88d0;p=cython.git ExprNodes: Add C++ error handling for std::invalid_argument. Also expand comments slightly. --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 549779b7..be4bf507 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -7050,8 +7050,13 @@ static void __Pyx_CppExn2PyErr() { ; // let the latest Python exn pass through and ignore the current one else throw; + } catch (const std::invalid_argument& exn) { + // Catch a handful of different errors here and turn them into the + // equivalent Python errors. + // Change invalid_argument to ValueError + PyErr_SetString(PyExc_ValueError, exn.what()); } catch (const std::out_of_range& exn) { - // catch out_of_range explicitly so the proper Python exn may be raised + // Change out_of_range to IndexError PyErr_SetString(PyExc_IndexError, exn.what()); } catch (const std::exception& exn) { PyErr_SetString(PyExc_RuntimeError, exn.what());