From d0793d22d8aef52fc625dfe04d2d3bc9695a0a55 Mon Sep 17 00:00:00 2001 From: Nick Smith Date: Tue, 10 Jun 2025 13:13:23 -0500 Subject: [PATCH 1/2] Reading a TPad Need to add the example file to scikit-hep test data --- src/rootfilespec/bootstrap/TList.py | 12 ++++-------- src/rootfilespec/bootstrap/TObject.py | 4 ++++ src/rootfilespec/bootstrap/__init__.py | 2 ++ src/rootfilespec/bootstrap/assumed.py | 15 +++++++++++++++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/rootfilespec/bootstrap/TList.py b/src/rootfilespec/bootstrap/TList.py index 7343c17..c2f90b4 100644 --- a/src/rootfilespec/bootstrap/TList.py +++ b/src/rootfilespec/bootstrap/TList.py @@ -46,14 +46,10 @@ def update_members(cls, members: Members, buffer: ReadBuffer): msg = f"Expected TObject but got {item!r}" raise ValueError(msg) # No idea why there is a null pad byte here - pad, buffer = buffer.consume(1) - if pad != b"\x00": - if pad == b"\x01": - # TODO: understand this case (e.g. uproot-issue-350.root) - (mystery,), buffer = buffer.unpack(">B") - else: - msg = f"Unexpected pad byte in TList: {pad!r}" - raise ValueError(msg) + (pad,), buffer = buffer.unpack(">B") + if pad != 0: + # TODO: understand this case (e.g. uproot-issue-350.root) + mystery, buffer = buffer.consume(pad) items.append(item) members["items"] = items return members, buffer diff --git a/src/rootfilespec/bootstrap/TObject.py b/src/rootfilespec/bootstrap/TObject.py index 15c42d5..7eb3509 100644 --- a/src/rootfilespec/bootstrap/TObject.py +++ b/src/rootfilespec/bootstrap/TObject.py @@ -50,6 +50,10 @@ class TObjFlag(IntFlag): """TStreamerElement status bit or kInvalidObject""" kListOfRules = 0x4000 """The schema evolution rules stored at the end of the streamer info""" + kMysteryCanvas1 = 0x100000 + """Appears in some TCanvas objects, not sure what it means.""" + kMysteryCanvas2 = 0x200000 + """Appears in some TCanvas objects, not sure what it means.""" # TODO: validate on initialization that no bits are set that are not defined in this class def __repr__(self): diff --git a/src/rootfilespec/bootstrap/__init__.py b/src/rootfilespec/bootstrap/__init__.py index 1667f3a..8aed44e 100644 --- a/src/rootfilespec/bootstrap/__init__.py +++ b/src/rootfilespec/bootstrap/__init__.py @@ -18,6 +18,7 @@ RooLinkedList, TAtt3D, TFormula, + TQObject, TVirtualIndex, Uninterpreted, ) @@ -75,6 +76,7 @@ "TNamed", "TObjArray", "TObject", + "TQObject", "TSeqCollection", "TStreamerBase", "TStreamerBasicPointer", diff --git a/src/rootfilespec/bootstrap/assumed.py b/src/rootfilespec/bootstrap/assumed.py index 6d9ae32..08f1b6a 100644 --- a/src/rootfilespec/bootstrap/assumed.py +++ b/src/rootfilespec/bootstrap/assumed.py @@ -140,3 +140,18 @@ def update_members(cls, members: Members, buffer: ReadBuffer): DICTIONARY["TFormula"] = TFormula + + +@serializable +class TQObject(ROOTSerializable): + """Qt object communication object for ROOT GUIs + + Nothing is serialized + """ + + @classmethod + def update_members(cls, members: Members, buffer: ReadBuffer): + return members, buffer + + +DICTIONARY["TQObject"] = TQObject From 13574b98d4b668252e47ccc760800dfe5492f4cf Mon Sep 17 00:00:00 2001 From: Nick Smith Date: Tue, 10 Jun 2025 13:23:16 -0500 Subject: [PATCH 2/2] Some more strange TObject bits --- src/rootfilespec/bootstrap/TObject.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/rootfilespec/bootstrap/TObject.py b/src/rootfilespec/bootstrap/TObject.py index 7eb3509..04e9854 100644 --- a/src/rootfilespec/bootstrap/TObject.py +++ b/src/rootfilespec/bootstrap/TObject.py @@ -54,6 +54,13 @@ class TObjFlag(IntFlag): """Appears in some TCanvas objects, not sure what it means.""" kMysteryCanvas2 = 0x200000 """Appears in some TCanvas objects, not sure what it means.""" + kMysteryPad1 = 0x200 + """Appears in some TCanvas objects, not sure what it means.""" + kMysteryPad2 = 0x400 + """Appears in some TCanvas objects, not sure what it means.""" + kMysteryPad3 = 0x800 + """Appears in some TCanvas objects, not sure what it means.""" + # TODO: there are too many of these mystery bits, we should remove invalid bit checks # TODO: validate on initialization that no bits are set that are not defined in this class def __repr__(self):