PyRoot problems with TPair and TDSetElement


I am trying to run some python code with proof and I started to play around with datasets. Now I am stuck on the following problem:

I need access the input element “PROOF_CurrentElement” for proof to know which dataset I am working at and in the proof documentation it says to use the following code within a TSelector class:

if (fInput && (elemPair = dynamic_cast<TPair *>(fInput->FindObject("PROOF_CurrentElement")))) { TDSetElement *fCurrent = dynamic_cast<TDSetElement *>(elemPair->Value()); if (fCurrent) { if (fCurrent->TestBit(TDSetElement::kNewRun)) { Info(fCurrent->GetDataSet()); } if (fCurrent->TestBit(TDSetElement::kNewPacket)) { Info(fCurrent->GetName()); } }

which I translated into python (within the a class inherited from TPySelector class) as:

if self.fInput: elemPair=self.fInput.FindObject("PROOF_CurrentElement") if elemPair != None: fCurrent = elemPair.Value() if fCurrent.TestBit(TDSetElement.kNewRun): print fCurrent.GetDataSet() if fCurrent.TestBit(TDSetElement.kNewPacket): print fCurrent.GetName()

Unfortunately I get a crash at the line “fCurrent = elemPair.Value()” and the crash looks like this:

[code]Thread 2 (Thread 0x417e8940 (LWP 4183522)):
#0 0x0000003dbe2cad26 in poll () from /lib64/
#1 0x00002b18756ed286 in XrdClientSock::RecvRaw (this=0x18935ef0,
buffer=0x19262460, length=8, substreamid=-1,
at /afs/slac/public/software/scalla/releases/v3.2.7/xrootd-3.2.7/src/XrdClient/
#2 0x00002b1875708422 in XrdClientPhyConnection::ReadRaw (this=0x189345e0,
buf=0x19262460, len=8, substreamid=-1, usedsubstreamid=0x417e7d9c)
at /afs/slac/public/software/scalla/releases/v3.2.7/xrootd-3.2.7/src/XrdClient/
#3 0x00002b187570b528 in XrdClientMessage::ReadRaw (this=0x19262420,
at /afs/slac/public/software/scalla/releases/v3.2.7/xrootd-3.2.7/src/XrdClient/
#4 0x00002b1875707bdc in XrdClientPhyConnection::BuildMessage (
this=0x189345e0, IgnoreTimeouts=true, Enqueue=true)
at /afs/slac/public/software/scalla/releases/v3.2.7/xrootd-3.2.7/src/XrdClient/
#5 0x00002b1875708212 in SocketReaderThread (arg=0x189345e0,
at /afs/slac/public/software/scalla/releases/v3.2.7/xrootd-3.2.7/src/XrdClient/
#6 0x00002b187548713f in XrdSysThread_Xeq (myargs=)
at /afs/slac/public/software/scalla/releases/v3.2.7/xrootd-3.2.7/src/XrdSys/
#7 0x0000003dbea0677d in start_thread () from /lib64/
#8 0x0000003dbe2d3c1d in clone () from /lib64/

Thread 1 (Thread 0x2b187362e2f0 (LWP 4183509)):
#0 0x0000003dbe2997ef in waitpid () from /lib64/
#1 0x0000003dbe23c761 in do_system () from /lib64/
#2 0x0000003dbe23cab7 in system () from /lib64/
#3 0x00002b1871d653c6 in TUnixSystem::StackTrace() ()
from /cvmfs/
#4 0x00002b1871d64c9c in TUnixSystem::DispatchSignals(ESignals) ()
from /cvmfs/
#6 0x00002b1871f4584b in TInstrumentedIsAProxy::operator()(void const*) ()
from /cvmfs/
#7 0x00002b1871d2c044 in TClass::GetActualClass(void const*) const ()
from /cvmfs/
#8 0x00002aaab10a6afb in PyROOT::BindRootObject(void*, TClass*, bool) ()
from /cvmfs/
#9 0x00002aaab1091021 in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::CallSafe(void*, bool) ()
from /cvmfs/
#10 0x00002aaab1092e97 in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::Execute(void*, bool) ()
from /cvmfs/
#11 0x00002aaab108f450 in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::operator()(PyROOT::ObjectProxy*, _object*, _object*, long, bool) ()
from /cvmfs/
#12 0x00002aaab1094aa0 in PyROOT::(anonymous namespace)::mp_call(PyROOT::MethodProxy*, _object*, _object*) ()
from /cvmfs/
#13 0x00002aaab1334848 in PyObject_Call (func=0x18e9efd0, arg=0x2aaaac4b5050,
kw=0x0) at Objects/abstract.c:2492
#14 0x00002aaab13dace2 in do_call (f=0x191c8b00,
throwflag=) at Python/ceval.c:3968
#15 call_function (f=0x191c8b00, throwflag=)
at Python/ceval.c:3773
#16 PyEval_EvalFrameEx (f=0x191c8b00, throwflag=)
at Python/ceval.c:2412
#17 0x00002aaab13dd637 in fast_function (f=0x19221220,
throwflag=) at Python/ceval.c:3836
#18 call_function (f=0x19221220, throwflag=)
at Python/ceval.c:3771
#19 PyEval_EvalFrameEx (f=0x19221220, throwflag=)
at Python/ceval.c:2412
#20 0x00002aaab13de847 in PyEval_EvalCodeEx (co=0x2aaaac6bb6c0,
globals=, locals=,
args=0x2aaaac6bcf98, argcount=2, kws=0x0, kwcount=0, defs=0x0, defcount=0,
closure=0x0) at Python/ceval.c:3000
#21 0x00002aaab13633ad in function_call (func=0x2aaaac651e60,
arg=0x2aaaac6bcf80, kw=0x0) at Objects/funcobject.c:524
#22 0x00002aaab1334848 in PyObject_Call (func=0x2aaaac651e60,
arg=0x2aaaac6bcf80, kw=0x0) at Objects/abstract.c:2492
#23 0x00002aaab1345630 in instancemethod_call (func=0x2aaaac651e60,
arg=0x2aaaac6bcf80, kw=0x0) at Objects/classobject.c:2579
#24 0x00002aaab1334848 in PyObject_Call (func=0x18f2f320, arg=0x2aaaac68a610,
kw=0x0) at Objects/abstract.c:2492
#25 0x00002aaab133700e in call_function_tail (callable=0x18f2f320,
format=) at Objects/abstract.c:2524
#26 PyObject_CallFunction (callable=0x18f2f320, format=)
at Objects/abstract.c:2548
#27 0x00002aaab10afc82 in TPySelector::CallSelf(char const*, _object*) ()
from /cvmfs/
#28 0x00002aaab10afea1 in TPySelector::Init(TTree*) ()
from /cvmfs/
#29 0x00002aaaab6b8bae in TEventIterTree::GetNextPacket(long long&, long long&, TEntryList**, TEventList**) ()
from /cvmfs/
#30 0x00002aaaab6f515d in TProofPlayer::Process(TDSet*, char const*, char const*, long long, long long) ()
from /cvmfs/
#31 0x00002b1874ebe795 in TProofServ::HandleProcess(TMessage*, TString*) ()
from /cvmfs/
#32 0x00002b1874ec08d6 in TProofServ::HandleSocketInput(TMessage*, bool) ()
from /cvmfs/
#33 0x00002b1874eb5181 in TProofServ::HandleSocketInput() ()
from /cvmfs/
#34 0x00002b1875222fc9 in TXProofServ::HandleInput(void const*) ()
from /cvmfs/
#35 0x00002b18752336bd in TXSocketHandler::Notify() ()
from /cvmfs/
#36 0x00002b1871d632f4 in TUnixSystem::CheckDescriptors() ()
from /cvmfs/
#37 0x00002b1871d63911 in TUnixSystem::DispatchOneEvent(bool) ()
from /cvmfs/
#38 0x00002b1871cd7476 in TSystem::InnerLoop() ()
from /cvmfs/
#39 0x00002b1871cd973c in TSystem::Run() ()
from /cvmfs/
#40 0x00002b1871c6baef in TApplication::Run(bool) ()
from /cvmfs/
#41 0x0000000000401c55 in main ()

Does it mean that python as problems converting the TObject* in the value of TPair object into its actual class (TDSetElement)? Any workaround for this case?

Sorry I forgot to mention, I am using root ROOT 5.34/10 “heads/v5-34-00-patches@v5-34-10-5-g0e8bac8” straight from CVMFS (this is setup while I setup Proof On Demand from CVMFS).



what is a “TPair” for an object? The typical reason for GetActualClass() to fail, is for virtual inheritance. Is there any?

Also, I’m no fan of “if elemPair != None:” as it may be yield unexpected behavior if the C++ class defines operator!= and/or operator==. Does TPair do that?