ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TPyException.cxx
Go to the documentation of this file.
1 // @(#)root/pyroot:$Id$
2 // Author: Scott Snyder, Apr 2004
3 
4 // Bindings
5 #include "PyROOT.h"
6 #include "TPyException.h"
7 
8 
9 //______________________________________________________________________________
10 // C++ exception for throwing python exceptions
11 // ============================================
12 // Purpose: A C++ exception class for throwing python exceptions
13 // through C++ code.
14 // Created: Apr, 2004, sss, from the version in D0's python_util.
15 //
16 // Note: Don't be tempted to declare the virtual functions defined here
17 // as inline.
18 // If you do, you may not be able to properly throw these
19 // exceptions across shared libraries.
20 
21 
22 //- data ---------------------------------------------------------------------
24 void* PyROOT::TPyExceptionMagic = (PyObject*)1;
25 void* PyROOT::TPyCPPExceptionMagic = (PyObject*)2;
26 
27 namespace {
28 
29  class TManageMagic { // ensures that no valid PyObject can occupy the magic
30  public:
31  TManageMagic() {
32  PyROOT::TPyExceptionMagic = new int(1);
33  PyROOT::TPyCPPExceptionMagic = new int(2);
34  }
35  ~TManageMagic() {
36  delete (int*)PyROOT::TPyExceptionMagic;
37  delete (int*)PyROOT::TPyCPPExceptionMagic;
38  }
39  } manageMagic;
40 
41 } // unnamed namespace
42 
43 
44 //- constructors/destructor --------------------------------------------------
46 {
47 // default constructor
48 }
49 
51 {
52 // destructor
53 }
54 
55 
56 //- public members -----------------------------------------------------------
57 const char* PyROOT::TPyException::what() const throw()
58 {
59 // Return reason for throwing this exception: a python exception was raised.
60  return "python exception";
61 }
virtual const char * what() const
R__EXTERN void * TPyExceptionMagic
Definition: TPyException.h:46
#define ClassImp(name)
Definition: Rtypes.h:279
typedef void((*Func_t)())
R__EXTERN void * TPyCPPExceptionMagic
Definition: TPyException.h:47
_object PyObject
Definition: TPyArg.h:22