[C++-sig] frame corruption in python -> c++ -> python scenario
Gennadiy Rozental
rogeeff at gmail.com
Thu Jul 17 20:46:21 CEST 2008
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 modules (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
More information about the Cplusplus-sig
mailing list