Something like this will get you some more info. 

 

Try: 

                Dopythonstuff()

Catch:

          if (PyErr_Occurred())

            {

                PyErr_Print();

            }

 

You should probably re throw that error, too. 

 

From:
cplusplus-sig-bounces+matthew.scouten=tradingtechnologies....@python.org
[mailto:cplusplus-sig-bounces+matthew.scouten=tradingtechnologies....@py
thon.org] On Behalf Of Charles Solar
Sent: Wednesday, June 09, 2010 2:12 PM
To: Development of Python/C++ integration
Subject: [C++-sig] Python exceptions in functions called from C++

 

I have a boost python library that I build python scripts with.  I am
not embedding python, I think that is worth mentioning right off the
bat.
In my C++ library I have a separate thread calling into python
occasionally and I am finding that if the function I call in python has
a python error in it, eg:

def callMe():
  crash = "Hello world"
  return crash()

When my C++ app calls that I get the error_already_set exception from
boost python.  My problem with that is it offers no information from
python like 'Strings are not callable on line 200 in crash.py'  So my
question is how can I connect the error_already_set exception on the
other thread to python's exception handler so if python produces an
exception while calling from C++ I get the python exception information
and not just 'error already set'?

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to