Commit e71d885b authored by Lars Buitinck's avatar Lars Buitinck

Handle std::ios_base::failure as well as possible

parent f7715b63
...@@ -8228,6 +8228,10 @@ static void __Pyx_CppExn2PyErr() { ...@@ -8228,6 +8228,10 @@ static void __Pyx_CppExn2PyErr() {
PyErr_SetString(PyExc_ValueError, exn.what()); PyErr_SetString(PyExc_ValueError, exn.what());
} catch (const std::bad_alloc& exn) { } catch (const std::bad_alloc& exn) {
PyErr_SetString(PyExc_MemoryError, exn.what()); PyErr_SetString(PyExc_MemoryError, exn.what());
} catch (const std::ios_base::failure& exn) {
// Unfortunately, in standard C++ we have no way of distinguishing EOF
// from other errors here; be careful with the exception mask
PyErr_SetString(PyExc_IOError, 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('ios') # for std::ios_base::failure
env.add_include_file('new') # for std::bad_alloc 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 \
......
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