List Info

Thread: C++ assertion




C++ assertion
user name
2007-03-05 18:10:07
I am in the process of wrapping a C++ class using Boost.Python. Things are progressing well, however the underlying C++ library uses assert() for various error checks. Out of curiousity I triggerred one of the asserts() on an exported C++ function from within Python. Sure enough the assertion error printed ( o.k.) AND the Python interpreter quit (not o.k.).

So, is there a way to implement some Python code to capture the underlying C++ assertions, or do I have to modify the underlying library code?

-Simon
Re: C++ assertion
country flaguser name
United States
2007-03-05 18:19:46
Simon Wood wrote:
> I am in the process of wrapping a C++ class using
Boost.Python. Things
> are progressing well, however the underlying C++
library uses assert()
> for various error checks. Out of curiousity I
triggerred one of the
> asserts() on an exported C++ function from within
Python. Sure enough
> the assertion error printed ( o.k.) AND the Python
interpreter quit (not
> o.k.).
> 
> So, is there a way to implement some Python code to
capture the
> underlying C++ assertions, or do I have to modify the
underlying library
> code?

The latter. An assertion is just that. It asserts a certain
statement
to be true, else aborts the running process. (If an
assertion is false
your program is likely to be in an invalid state, so there
is no point
continuing.)
If you want something else you may consider throwing an
exception.

Regards,
		Stefan

-- 

      ...ich hab' noch einen Koffer in Berlin...
_______________________________________________
C++-sig mailing list
C++-sigpython.org
http:
//mail.python.org/mailman/listinfo/c++-sig

Re: C++ assertion
user name
2007-03-06 07:46:20
The latter. An assertion is just that. It asserts a certain statement
to be true, else aborts the running process. (If an assertion is false
your program is likely to be in an invalid state, so there is no point
continuing.)
If you want something else you may consider throwing an exception.

Regards,
  ;           ;   Stefan


This is more or less what I figured to be true. Thanks for the confirmation.

-Simon
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )