Skip to content

TObjFlag.__repr__ raises on valid fBits, and several enum members mislabel class-specific bits as TObject bits #109

Description

@nsmith-

🤖 AI generated content

1. repr() of a successfully read object can raise. src/rootfilespec/bootstrap/TObject.py:53-63 raises ValueError: Invalid bits set in TObjFlag: 0x… for any bit not in the enum. The class's own docstring (:15-17) quotes the rule that makes this unsatisfiable: "Bits 14 - 23 can be used in different class hierarchies". Reproduced: repr(TObjFlag(0x200)) (TH1::kNoStats, i.e. any histogram after SetStats(0)), TObjFlag(0x800) (a TAxis bit) and TObjFlag(0x100) (TObject::kNoContextMenu, BIT(8), simply missing from the enum) all raise. The read succeeds; print() crashes.

2. Mislabelled members (TObject.py:41-50). These are class-specific bits that happened to show up on TStreamerInfo/TStreamerElement/TList objects, not TObject bits. Reviewers checked the pinned ROOT tree (TVirtualStreamerInfo.h:72-88, TStreamerElement.h:69-78, TObject.h:70-96):

Member Value Actually
kNotSure 0x10000 TStreamerInfo::kIsCompiled (BIT 16); TCollection::kUseRWLock
kMysteryStreamer 0x20000 TStreamerInfo::kBuildOldUsed (BIT 17)
kMysteryStreamer2 0x1000 TStreamerElement::kWrite / TStreamerInfo::kCannotOptimize / TClonesArray::kBypassStreamer (BIT 12)
kDoNotDelete 0x2000 TObject::kInvalidObject / TStreamerElement::kDoNotDelete / TStreamerInfo::kIgnoreTObjectStreamer (BIT 13)
kListOfRules 0x4000 TCollection::kIsOwner (BIT 14) — the listOfRules list has it because it is an owner, not because it holds rules

Three of these are load-bearing in the spec and tested nowhere in the code: kIgnoreTObjectStreamer on a TStreamerInfo (Streamer-driven reading §4.2, see #94), kHasRange = BIT(6) on a TStreamerElement (value 0x40, which the enum calls kCannotPick; needed by #41), and kBypassStreamer on a TClonesArray (Collections §12).

Suggested fix: make __repr__ total (print unknown bits as hex; drop the TODO on :52 about validating at construction — validation is impossible by design). Keep only genuine TObject bits (0–13 plus the private 24–27, adding kNoContextMenu = 0x100, kInvalidObject = 0x2000) in TObjFlag, and define per-class flag enums (TStreamerInfo, TStreamerElement, TCollection, TClonesArray) where the code needs them.

Severity / size: medium (exception from repr on ordinary histograms) / S.

Related: #41 (kHasRange), #94, #101, #110 (read fBits unsigned), #100.

Assisted-by: claude-code:claude-fable-5-1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions