module_tail.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright David Abrahams 2001.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #if defined(_WIN32)
  6. # ifdef __MWERKS__
  7. # pragma ANSI_strict off
  8. # endif
  9. # include <windows.h>
  10. # ifdef __MWERKS__
  11. # pragma ANSI_strict reset
  12. # endif
  13. # ifdef _MSC_VER
  14. # include <eh.h> // for _set_se_translator()
  15. # pragma warning(push)
  16. # pragma warning(disable:4297)
  17. # pragma warning(disable:4535)
  18. extern "C" void straight_to_debugger(unsigned int, EXCEPTION_POINTERS*)
  19. {
  20. throw;
  21. }
  22. extern "C" void (*old_translator)(unsigned, EXCEPTION_POINTERS*)
  23. = _set_se_translator(straight_to_debugger);
  24. # pragma warning(pop)
  25. # endif
  26. #endif // _WIN32
  27. #include <exception>
  28. #include <boost/python/extract.hpp>
  29. #include <boost/python/str.hpp>
  30. struct test_failure : std::exception
  31. {
  32. test_failure(char const* expr, char const* /*function*/, char const* file, unsigned line)
  33. : msg(file + boost::python::str(":%s:") % line + ": Boost.Python assertion failure: " + expr)
  34. {}
  35. ~test_failure() throw() {}
  36. char const* what() const throw()
  37. {
  38. return boost::python::extract<char const*>(msg)();
  39. }
  40. boost::python::str msg;
  41. };
  42. namespace boost
  43. {
  44. void assertion_failed(char const * expr, char const * function, char const * file, long line)
  45. {
  46. throw ::test_failure(expr,function, file, line);
  47. }
  48. } // namespace boost