46 char **argv =
nullptr;
48 if (ignoreCmdLineOpts) {
49 argv =
new char *[argc];
52 PyObject *argl = PySys_GetObject(
"argv");
57 argc =
static_cast<int>(
size);
60 argv =
new char *[argc];
62 for (
int i = 1; i < argc; ++i) {
63 PyObject *item = PyList_GetItem(argl, i);
64 const char *argi = PyUnicode_AsUTF8AndSize(item,
nullptr);
66 if (strcmp(argi,
"-") == 0 || strcmp(argi,
"--") == 0) {
71 argv[i] =
const_cast<char *
>(argi);
75 argv[0] = (
char *)
"python";
115 static const char *emptyString =
"";
117 location = emptyString;
125 PyErr_WarnExplicit(NULL, (
char *)msg, (
char *)location, 0, (
char *)
"ROOT", NULL);
148 int argc = PyTuple_Size(args);
150 PyObject *ignoreCmdLineOpts = PyTuple_GetItem(args, 0);
152 if (!PyBool_Check(ignoreCmdLineOpts)) {
153 PyErr_SetString(PyExc_TypeError,
"Expected boolean type as argument.");
162 PyErr_Format(PyExc_TypeError,
"Expected 1 argument, %d passed.", argc);
182 Gl_histinit((
char *)
"-");
189static int (*sOldInputHook)() =
nullptr;
190static PyThreadState *sInputHookEventThreadState =
nullptr;
192static int EventInputHook()
196 PyEval_RestoreThread(sInputHookEventThreadState);
203 return sOldInputHook();
216 if (PyOS_InputHook && PyOS_InputHook != &EventInputHook)
217 sOldInputHook = PyOS_InputHook;
219 sInputHookEventThreadState = PyThreadState_Get();
221 PyOS_InputHook = (
int (*)()) & EventInputHook;
static void ErrMsgHandler(int level, Bool_t abort, const char *location, const char *msg)
Translate ROOT error/warning to Python.
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Boolean (0=false, 1=true) (bool).
externTApplication * gApplication
externTBenchmark * gBenchmark
void DefaultErrorHandler(Int_t level, Bool_t abort_bool, const char *location, const char *msg)
The default error handler function.
void(* ErrorHandlerFunc_t)(int level, Bool_t abort, const char *location, const char *msg)
externInt_t gErrorIgnoreLevel
errors with level below this value will be ignored. Default is kUnset.
ErrorHandlerFunc_t SetErrorHandler(ErrorHandlerFunc_t newhandler)
Set an errorhandler function. Returns the old handler.
externconst char * gProgName
externTVirtualMutex * gGlobalMutex
static PyObject * InstallGUIEventInputHook(PyObject *self, PyObject *args)
Install a method hook for sending events to the GUI.
static void InitROOTMessageCallback()
Install the ROOT message handler which will turn ROOT error messages into Python exceptions.
RPyROOTApplication(const char *name, int *argc, char **argv)
Construct a TApplication for PyROOT.
static PyObject * InitApplication(PyObject *self, PyObject *args)
Initialize an RPyROOTApplication.
static bool CreateApplication(int ignoreCmdLineOpts)
Create an RPyROOTApplication.
static void InitROOTGlobals()
Setup the basic ROOT globals gBenchmark, gStyle and gProgname, if not already set.
TApplication(const TApplication &)=delete
void SetReturnFromRun(Bool_t ret)
static void CreateApplication()
Static function used to create a default application environment.
This class is a ROOT utility to help benchmarking applications.
TStyle objects may be created to define special styles.