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 
6 #if defined(_WIN32)
7 # ifdef __MWERKS__
8 #  pragma ANSI_strict off
9 # endif
10 # include <windows.h>
11 # ifdef __MWERKS__
12 #  pragma ANSI_strict reset
13 # endif
14 
15 # ifdef _MSC_VER
16 #  include <eh.h> // for _set_se_translator()
17 #  pragma warning(push)
18 #  pragma warning(disable:4297)
19 #  pragma warning(disable:4535)
straight_to_debugger(unsigned int,EXCEPTION_POINTERS *)20 extern "C" void straight_to_debugger(unsigned int, EXCEPTION_POINTERS*)
21 {
22     throw;
23 }
24 extern "C" void (*old_translator)(unsigned, EXCEPTION_POINTERS*)
25          = _set_se_translator(straight_to_debugger);
26 #  pragma warning(pop)
27 # endif
28 
29 #endif // _WIN32
30 
31 #include <exception>
32 #include <boost/python/extract.hpp>
33 #include <boost/python/str.hpp>
34 struct test_failure : std::exception
35 {
test_failuretest_failure36     test_failure(char const* expr, char const* /*function*/, char const* file, unsigned line)
37       : msg(file + boost::python::str(":%s:") % line + ": Boost.Python assertion failure: " + expr)
38     {}
39 
~test_failuretest_failure40     ~test_failure() throw() {}
41 
whattest_failure42     char const* what() const throw()
43     {
44         return boost::python::extract<char const*>(msg)();
45     }
46 
47     boost::python::str msg;
48 };
49 
50 namespace boost
51 {
52 
assertion_failed(char const * expr,char const * function,char const * file,long line)53 void assertion_failed(char const * expr, char const * function, char const * file, long line)
54 {
55     throw ::test_failure(expr,function, file, line);
56 }
57 
58 } // namespace boost
59