| | |
| |
|
| | #ifndef __Pyx_CppExn2PyErr |
| | #include <new> |
| | #include <typeinfo> |
| | #include <stdexcept> |
| | #include <ios> |
| |
|
| | static void __Pyx_CppExn2PyErr() { |
| | |
| | |
| | try { |
| | if (PyErr_Occurred()) |
| | ; |
| | else |
| | throw; |
| | } catch (const std::bad_alloc& exn) { |
| | PyErr_SetString(PyExc_MemoryError, exn.what()); |
| | } catch (const std::bad_cast& exn) { |
| | PyErr_SetString(PyExc_TypeError, exn.what()); |
| | } catch (const std::bad_typeid& exn) { |
| | PyErr_SetString(PyExc_TypeError, exn.what()); |
| | } catch (const std::domain_error& exn) { |
| | PyErr_SetString(PyExc_ValueError, exn.what()); |
| | } catch (const std::invalid_argument& exn) { |
| | PyErr_SetString(PyExc_ValueError, exn.what()); |
| | } catch (const std::ios_base::failure& exn) { |
| | |
| | |
| | PyErr_SetString(PyExc_IOError, exn.what()); |
| | } catch (const std::out_of_range& exn) { |
| | |
| | PyErr_SetString(PyExc_IndexError, exn.what()); |
| | } catch (const std::overflow_error& exn) { |
| | PyErr_SetString(PyExc_OverflowError, exn.what()); |
| | } catch (const std::range_error& exn) { |
| | PyErr_SetString(PyExc_ArithmeticError, exn.what()); |
| | } catch (const std::underflow_error& exn) { |
| | PyErr_SetString(PyExc_ArithmeticError, exn.what()); |
| | } catch (const std::exception& exn) { |
| | PyErr_SetString(PyExc_RuntimeError, exn.what()); |
| | } |
| | catch (...) |
| | { |
| | PyErr_SetString(PyExc_RuntimeError, "Unknown exception"); |
| | } |
| | } |
| | #endif |
| |
|
| | |
| |
|
| | template <class T> |
| | auto __Pyx_pythran_to_python(T &&value) -> decltype(to_python( |
| | typename pythonic::returnable<typename std::remove_cv<typename std::remove_reference<T>::type>::type>::type{std::forward<T>(value)})) |
| | { |
| | using returnable_type = typename pythonic::returnable<typename std::remove_cv<typename std::remove_reference<T>::type>::type>::type; |
| | return to_python(returnable_type{std::forward<T>(value)}); |
| | } |
| |
|