Testing whether imported function failed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    Testing whether imported function failed

    To all,

    I have to make a lot of calls to a C++ library binded to python.
    The problem is that the functions/methods don't raise
    exceptions when they fail to do their job. Instead they return
    a 0 for a failure and a 1 for a successful completion.[color=blue][color=green][color=darkred]
    >>> do_something(ob ject)[/color][/color][/color]
    1[color=blue][color=green][color=darkred]
    >>> do_something(ob ject)[/color][/color][/color]
    0

    I spent two days tracking down a bug that could have easily
    been found if the call loudly failed. Is there anyway to
    blanket test this integer 1/0 output so I can catch these
    errors before they become untraceable?

    Thank you,
    Brian

Working...