Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-9768

Char array branches not correctly retrieved as Python strings

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.22/00
    • Component/s: PyROOT
    • Labels:
    • Environment:

      Centos7, Python2

      Description

      When retrieving the value of a branch of type `Char_t`, with the following code:

      import ROOT
      f = ROOT.TFile("run0_Cu10MeV_BeThk0.5mm_E78.2MeV_D850mm_r3cm_d280mm_noshield.root")
      for entry in f.Detector:
       print(entry.Name)

      the resulting Python string is not well decoded from the C string, and instead all the elements of the branch array buffer are part of the string, independently of the length of the latter. For example:

      >>> import ROOT
      >>> f = ROOT.TFile("run0_Cu10MeV_BeThk0.5mm_E78.2MeV_D850mm_r3cm_d280mm_noshield.root")
      >>> f.Detector.GetEntry(0)
      87
      >>> f.Detector.Name
      'proton\x00\x00'
      >>> f.Detector.GetEntry(136)
      83
      >>> f.Detector.Name
      'e-\x00ton\x00\x00' 

       

      The input file used is available at:

      https://drive.google.com/open?id=160Agehi-nr4RnjRWBFqGokWXtOHAfzao

       

      This issue is fixed in the experimental PyROOT.

       

        Attachments

          Activity

            People

            • Assignee:
              etejedor Enric Tejedor Saavedra
              Reporter:
              etejedor Enric Tejedor Saavedra
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: