Commit b510608e authored by Lars Buitinck's avatar Lars Buitinck

Translate std::bad_alloc to MemoryError

parent 91a18881
...@@ -8226,6 +8226,8 @@ static void __Pyx_CppExn2PyErr() { ...@@ -8226,6 +8226,8 @@ static void __Pyx_CppExn2PyErr() {
// equivalent Python errors. // equivalent Python errors.
// Change invalid_argument to ValueError // Change invalid_argument to ValueError
PyErr_SetString(PyExc_ValueError, exn.what()); PyErr_SetString(PyExc_ValueError, exn.what());
} catch (const std::bad_alloc& exn) {
PyErr_SetString(PyExc_MemoryError, exn.what());
} catch (const std::out_of_range& exn) { } catch (const std::out_of_range& exn) {
// Change out_of_range to IndexError // Change out_of_range to IndexError
PyErr_SetString(PyExc_IndexError, exn.what()); PyErr_SetString(PyExc_IndexError, exn.what());
......
...@@ -577,6 +577,7 @@ class CFuncDeclaratorNode(CDeclaratorNode): ...@@ -577,6 +577,7 @@ class CFuncDeclaratorNode(CDeclaratorNode):
exc_val = None exc_val = None
exc_check = 0 exc_check = 0
if self.exception_check == '+': if self.exception_check == '+':
env.add_include_file('new') # for std::bad_alloc
env.add_include_file('stdexcept') env.add_include_file('stdexcept')
if return_type.is_pyobject \ if return_type.is_pyobject \
and (self.exception_value or self.exception_check) \ and (self.exception_value or self.exception_check) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment