Boost logo

Boost :

From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2008-06-10 17:34:34


Hi,

I am experiencing strange issue I can't find solution for. Sorry I'll need a bit
lengthy explanation to describe it.

I am using boost python for both automation and embedding the same time. I
wrote trivial unit test module (can't use standard one). It has function check
like this:

def check( val ):
   check_impl( val )

def check_impl( val ):
    ...
    print "Error at line " + str(sys._getframe(2).f_lineno+1) ...
    ...

This supposedly should produce error line location. And it does. Sometimes.

test1.py:
...
8> check( False )

produces:

Error in line 8: ...

I've noticed though that in some cases line numbers are incorrect. I was able to
narrow it down to the single function

   mymodule.foo()

Before this function call line numbers are correct. After it incorrect.

foo is a function implemented in c++ and exported using boost.python. I was able
further to identify that the line at fault inside function foo implementation is
the one invoking python function:

void foo()
{
  ...
  boost::python::object obj = ...

  obj();
  ...
}

So. Finally the question:

Is there way to fix/circumvent this somehow?

Thanks,

Gennadiy


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk