ATLAS Offline Software
Loading...
Searching...
No Matches
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
std::string str (PyObject *o)
 returns the string representation of a python object equivalent of calling str(o) in python
StatusCode callPyMethod ATLAS_NOT_THREAD_SAFE (PyObject *self, const char *method, PyObject *arg=nullptr)
 call the python method
StatusCode queryInterface ATLAS_NOT_THREAD_SAFE (PyObject *self, const InterfaceID &riid, void **ppvInterface)
 query interface binding
void pyAudit ATLAS_NOT_THREAD_SAFE (PyObject *self, const char *method, const char *evt, const char *component)
 helper function for PyAthena::Aud
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
void throw_py_exception (bool display=true)
 helper function to capture the boilerplate code for user friendly stack trace display

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}
_object PyObject
void throw_py_exception(bool display=true)
helper function to capture the boilerplate code for user friendly stack trace display
std::pair< std::string, bool > PyGetString(PyObject *s)
Convert python string -> C++ string for py2 and py3.
Definition PyGetString.h:40

◆ 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 PyObject* fstr = PyUnicode_FromString ("flush");
154 PyObject* x = PyObject_CallMethodObjArgs (f, fstr, NULL);
155 Py_XDECREF (x);
156 Py_XDECREF (fstr);
157 Py_XDECREF (f);
158 }
159 }
160 throw CPyCppyy::PyException();
161}
#define x