CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PythonWrapper.cc
Go to the documentation of this file.
3 //#include <iostream>
4 namespace edm {
5 
6 void pythonToCppException(const std::string& iType)
7  {
8  using namespace boost::python;
9  PyObject *exc=NULL, *val=NULL, *trace=NULL;
10  PyErr_Fetch(&exc,&val,&trace);
11  PyErr_NormalizeException(&exc,&val,&trace);
12  handle<> hExc(allow_null(exc));
13  handle<> hVal(allow_null(val));
14  handle<> hTrace(allow_null(trace));
15 
16  if(hTrace) {
17  object oTrace(hTrace);
18  handle<> hStringTr(PyObject_Str(oTrace.ptr()));
19  object stringTr(hStringTr);
20 //std::cout << "PR TR " << stringTr << " DONE "<< std::endl;
21  }
22 
23  if(hVal && hExc) {
24  object oExc(hExc);
25  object oVal(hVal);
26  handle<> hStringVal(PyObject_Str(oVal.ptr()));
27  object stringVal( hStringVal );
28 
29  handle<> hStringExc(PyObject_Str(oExc.ptr()));
30  object stringExc( hStringExc);
31 
32  //PyErr_Print();
33  throw cms::Exception(iType) <<"python encountered the error: "
34  << PyString_AsString(stringExc.ptr())<<" "
35  << PyString_AsString(stringVal.ptr())<<"\n";
36  } else {
37  throw cms::Exception(iType)<<" unknown python problem occurred.\n";
38  }
39 }
40 
41 }
42 
43 
void pythonToCppException(const std::string &iType)
Definition: PythonWrapper.cc:6
#define NULL
Definition: scimark2.h:8
double trace(const ROOT::Math::SMatrix< double, N, N > &matrix)