FairShip
Loading...
Searching...
No Matches
pyFairModule.cxx
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP
3// Collaboration
4
5#include "pyFairModule.h"
6
7#include "Python.h" // Needs to be included first to avoid redefinition of _POSIX_C_SOURCE
8#include "TObject.h"
9
10void call_python_method(PyObject* self, const char* method) {
11 // check arguments
12 if (0 == self || 0 == method) {
13 throw std::runtime_error("Invalid Python object and method");
14 }
15 // call Python
16 PyObject* r = PyObject_CallMethod(self, const_cast<char*>(method),
17 const_cast<char*>(""));
18 if (0 == r) {
19 PyErr_Print();
20 return;
21 }
22 // release used objects
23 Py_XDECREF(r);
24 //
25 return;
26}
void call_python_method(PyObject *self, const char *method)
_object PyObject
Definition: pyFairModule.h:9