Skip to content

Commit 83726f6

Browse files
authored
feat: special case for reading std::string from a TDirectory (#1160)
* feat: special case for reading std::string from a TDirectory * less hacky, but this way calls the std::string a TString * added a test; should be done now * revert to the original solution
1 parent accc1ca commit 83726f6

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/uproot/reading.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2473,9 +2473,13 @@ def get(self):
24732473
else:
24742474
chunk, cursor = self.get_uncompressed_chunk_cursor()
24752475
start_cursor = cursor.copy()
2476-
cls = self._file.class_named(self._fClassName)
24772476
context = {"breadcrumbs": (), "TKey": self}
24782477

2478+
if self._fClassName == "string":
2479+
return cursor.string(chunk, context)
2480+
2481+
cls = self._file.class_named(self._fClassName)
2482+
24792483
try:
24802484
out = cls.read(chunk, cursor, context, self._file, selffile, parent)
24812485

tests/test_0692_fsspec_reading.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ def test_issue_1035(handler):
395395
assert len(data) == 40
396396

397397

398+
@pytest.mark.skip(reason="This test occasionally takes too long: GitHub kills it.")
398399
@pytest.mark.network
399400
@pytest.mark.xrootd
400401
@pytest.mark.parametrize(
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot5/blob/main/LICENSE
2+
3+
import json
4+
5+
import skhep_testdata
6+
7+
import uproot
8+
9+
10+
def test():
11+
with uproot.open(skhep_testdata.data_path("string-example.root")) as file:
12+
assert json.loads(file["FileSummaryRecord"]) == {
13+
"LumiCounter.eventsByRun": {
14+
"counts": {},
15+
"empty": True,
16+
"type": "LumiEventCounter",
17+
},
18+
"guid": "5FE9437E-D958-11EE-AB88-3CECEF1070AC",
19+
}

0 commit comments

Comments
 (0)