Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Classes | Typedefs | Functions
PyAthena Namespace Reference

Classes

class  Alg
 
class  Aud
 
class  PyComponentMgr
 
class  Svc
 
class  Tool
 

Typedefs

typedef ::AthAlgorithm AlgBase_t
 
typedef ::AthService SvcBase_t
 
typedef ::AthAlgTool ToolBase_t
 

Functions

std::string repr (PyObject *o)
 returns the string representation of a python object equivalent of calling repr(o) in python More...
 
std::string str (PyObject *o)
 returns the string representation of a python object equivalent of calling str(o) in python More...
 
StatusCode callPyMethod ATLAS_NOT_THREAD_SAFE (PyObject *self, const char *method, PyObject *arg=nullptr)
 call the python method More...
 
StatusCode queryInterface ATLAS_NOT_THREAD_SAFE (PyObject *self, const InterfaceID &riid, void **ppvInterface)
 query interface binding More...
 
void pyAudit ATLAS_NOT_THREAD_SAFE (PyObject *self, const char *method, const char *evt, const char *component)
 helper function for PyAthena::Aud More...
 
void pyAudit ATLAS_NOT_THREAD_SAFE (PyObject *self, const char *method, const char *evt, const char *component, const StatusCode &sc)
 helper function for PyAthena::Aud More...
 
void throw_py_exception (bool display=true)
 helper function to capture the boilerplate code for user friendly stack trace display More...
 

Typedef Documentation

◆ AlgBase_t

Definition at line 29 of file PyAthenaAlg.h.

◆ SvcBase_t

Definition at line 30 of file PyAthenaSvc.h.

◆ ToolBase_t

Definition at line 29 of file PyAthenaTool.h.

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE() [1/4]

void pyAudit PyAthena::ATLAS_NOT_THREAD_SAFE ( PyObject self,
const char *  method,
const char *  evt,
const char *  component 
)

helper function for PyAthena::Aud

◆ ATLAS_NOT_THREAD_SAFE() [2/4]

void pyAudit PyAthena::ATLAS_NOT_THREAD_SAFE ( PyObject self,
const char *  method,
const char *  evt,
const char *  component,
const StatusCode &  sc 
)

helper function for PyAthena::Aud

◆ ATLAS_NOT_THREAD_SAFE() [3/4]

StatusCode callPyMethod PyAthena::ATLAS_NOT_THREAD_SAFE ( PyObject self,
const char *  method,
PyObject arg = nullptr 
)

call the python method

◆ ATLAS_NOT_THREAD_SAFE() [4/4]

StatusCode queryInterface PyAthena::ATLAS_NOT_THREAD_SAFE ( PyObject self,
const InterfaceID &  riid,
void **  ppvInterface 
)

query interface binding

◆ repr()

std::string PyAthena::repr ( PyObject o)

returns the string representation of a python object equivalent of calling repr(o) in python

Definition at line 106 of file PyAthenaUtils.cxx.

107 {
108  // PyObject_Repr returns a new ref.
110  PyObject* py_repr = PyObject_Repr( o );
111 
112  auto [cpp_repr, flag] = RootUtils::PyGetString (py_repr);
113  Py_DECREF( py_repr );
114  if (!flag) {
116  }
117  return cpp_repr;
118 }

◆ str()

std::string PyAthena::str ( PyObject o)

returns the string representation of a python object equivalent of calling str(o) in python

Definition at line 121 of file PyAthenaUtils.cxx.

122 {
123  // PyObject_Str returns a new ref.
125  PyObject* py_str = PyObject_Str( o );
126  auto [cpp_str, flag] = RootUtils::PyGetString (py_str);
127  Py_DECREF( py_str );
128  if ( !flag ) {
130  }
131  return cpp_str;
132 }

◆ throw_py_exception()

void PyAthena::throw_py_exception ( bool  display = true)

helper function to capture the boilerplate code for user friendly stack trace display

Definition at line 135 of file PyAthenaUtils.cxx.

136 {
137  if (display) {
139  // fetch error
140  PyObject* pytype = 0, *pyvalue = 0, *pytrace = 0;
141  PyErr_Fetch (&pytype, &pyvalue, &pytrace);
142  Py_XINCREF (pytype);
143  Py_XINCREF (pyvalue);
144  Py_XINCREF (pytrace);
145  // restore...
146  PyErr_Restore (pytype, pyvalue, pytrace);
147  // and print
148  PyErr_Print();
149  {
150  // With py3, need to explicitly flush the python stderr
151  // for the error to be visible.
152  PyObject* f = PySys_GetObject (const_cast<char*>("stderr"));
153 #if PY_VERSION_HEX < 0x03000000
154  PyObject* fstr = PyString_FromString ("flush");
155 #else
156  PyObject* fstr = PyUnicode_FromString ("flush");
157 #endif
158  PyObject* x = PyObject_CallMethodObjArgs (f, fstr, NULL);
159  Py_XDECREF (x);
160  Py_XDECREF (fstr);
161  Py_XDECREF (f);
162  }
163  }
164  throw CPyCppyy::PyException();
165 }
RootUtils::PyException
CPyCppyy::PyException PyException
Definition: Utility.h:24
PyAthena::throw_py_exception
void throw_py_exception(bool display=true)
helper function to capture the boilerplate code for user friendly stack trace display
Definition: PyAthenaUtils.cxx:135
x
#define x
RootUtils::PyGILStateEnsure
Definition: PyAthenaGILStateEnsure.h:20
master.flag
bool flag
Definition: master.py:29
hist_file_dump.f
f
Definition: hist_file_dump.py:141
pyroot.display
display
Definition: pyroot.py:44
RootUtils::PyGetString
std::pair< std::string, bool > PyGetString(PyObject *s)
Convert python string -> C++ string for py2 and py3.
Definition: PyGetString.h:40
PyObject
_object PyObject
Definition: IPyComponent.h:26