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

cannot convert bytes to std::string

    Details

    • Type: Story
    • Status: Closed (View Workflow)
    • Priority: Low
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: PyROOT
    • Labels:
      None

      Description

      Dear colleagues,
      I am trying to migrate COOL to python3 and I have an issue.
      I would like to use a method with bytes instead of str.
      It seems that str gets converted to string in Pyroot, but not bytes.
      the error I get is this:

      >>> f.attribute().setValue("std::string")(b"normal string")
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      TypeError: void coral::Attribute::setValue<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(const string& value) =>
          could not convert argument 1
      

      When I do this with a str it works fine:

      >>> f.attribute().setValue("std::string")("normal string")
      >>> f.attribute().data("std::string")()
      'normal string'
      

      Could you help me figure out if it is something I can fix on my side, or if it should be done in PyROOT?

      Cheers,
      Charles

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                etejedor Enric Tejedor Saavedra
                Reporter:
                cdelort Charles Delort
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  PlannedEnd:
                  PlannedStart: