uproot5 icon indicating copy to clipboard operation
uproot5 copied to clipboard

`parse_typename` fails on const pointer members

Open veprbl opened this issue 8 months ago • 0 comments

wget -O uproot-issue-XXX.root https://github.com/scikit-hep/scikit-hep-testdata/raw/7387822903e0c0de02cee4b98dbb9677f7bfba2a/src/skhep_testdata/data/uproot-issue-1229.root
>>> import uproot
>>> uproot.__version__
'5.3.7'
>>> uproot.open("uproot-issue-XXX.root")["tree"]["branch/pointer"].typename
'TFooMember*'
>>> uproot.open("uproot-issue-XXX.root")["tree"]["branch/const_pointer"].typename
Traceback (most recent call last):
  File "/nix/store/bz0s89q09d1jxb96bcpjad38sqw6nimk-python3.11-uproot-5.3.7/lib/python3.11/site-packages/uproot/interpretation/identify.py", line 385, in interpretation_of
    from_dtype = _leaf_to_dtype(leaf, getdims=False).newbyteorder(">")
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/bz0s89q09d1jxb96bcpjad38sqw6nimk-python3.11-uproot-5.3.7/lib/python3.11/site-packages/uproot/interpretation/identify.py", line 103, in _leaf_to_dtype
    return numpy.dtype((_ftype_to_dtype(leaf.member("fType")), dims))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/bz0s89q09d1jxb96bcpjad38sqw6nimk-python3.11-uproot-5.3.7/lib/python3.11/site-packages/uproot/interpretation/identify.py", line 61, in _ftype_to_dtype
    raise NotNumerical()
uproot.interpretation.identify.NotNumerical

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nix/store/bz0s89q09d1jxb96bcpjad38sqw6nimk-python3.11-uproot-5.3.7/lib/python3.11/site-packages/uproot/behaviors/TBranch.py", line 1942, in typename
    if self.interpretation is None:
       ^^^^^^^^^^^^^^^^^^^
  File "/nix/store/bz0s89q09d1jxb96bcpjad38sqw6nimk-python3.11-uproot-5.3.7/lib/python3.11/site-packages/uproot/behaviors/TBranch.py", line 1926, in interpretation
    self._interpretation = uproot.interpretation.identify.interpretation_of(
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/bz0s89q09d1jxb96bcpjad38sqw6nimk-python3.11-uproot-5.3.7/lib/python3.11/site-packages/uproot/interpretation/identify.py", line 467, in interpretation_of
    model_cls = parse_typename(
                ^^^^^^^^^^^^^^^
  File "/nix/store/bz0s89q09d1jxb96bcpjad38sqw6nimk-python3.11-uproot-5.3.7/lib/python3.11/site-packages/uproot/interpretation/identify.py", line 1134, in parse_typename
    _parse_error(tokens[i].start(), typename, file)
  File "/nix/store/bz0s89q09d1jxb96bcpjad38sqw6nimk-python3.11-uproot-5.3.7/lib/python3.11/site-packages/uproot/interpretation/identify.py", line 537, in _parse_error
    raise ValueError(
ValueError: invalid C++ type name syntax at char 6

    const TFooMember*
----------^
in file uproot-issue-XXX.root

veprbl avatar Jun 10 '24 09:06 veprbl