Catching ROOT errors from pyROOT


ROOT Version: 6.24/02
Platform: linuxx8664gcc


Hi all,

I have a very similar problem to a ROOT user from many years ago: I’m processing data using pyROOT, and some of it is corrupted and calls to e.g. Get() or GetListOfKeys() print errors like
Error R__unzip_header: error in header. Values: 2054
Error in <TBufferFile::ReadClassBuffer>: Could not find the StreamerInfo for version 10 of the class TF1, object skipped at offset 1194
Error in <TBufferFile::CheckByteCount>: object of class TF1 read too few bytes: 2 instead of 1173
to the console. Processing this data can cause our code to segfault unexpectedly, and it would be ideal to instead catch these errors (either with checks or an except statement).
In another thread, there is some hope that catching these errors from pyROOT would be available in a future ROOT version. Is there a way to catch these errors natively with pyROOT now?

Another solution posed in these threads is to use rootpy’s “dark magic”, but development of rootpy seems abandoned so a native pyROOT method would be preferable.

I guess @etejedor can help you.

Hello,

Unfortunately there is nothing implemented in PyROOT to handle error messages coming from ROOT C++ classes as exceptions.

Perhaps you could try to do some checks when invoking e.g. GetListOfKeys on a corrupted dataset? Does it also e.g. return a nullptr besides printing the error?

It seems the problem comes from upgrading ROOT minor versions (from 6.14 to 6.24), and that’s why the data could no longer be read properly. We’ll start generating the data with a modern ROOT version to prevent this in the future. I’ll check to see if the nullptr checks resolve the issue in pyROOT.

See this note about 6.14; that may be part of the ‘bad files’ issue.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.