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

vector<string> behaviour in loops in PyROOT 6.20 vs 6.22

    XMLWordPrintable

Details

    • Story
    • Status: Closed (View Workflow)
    • High
    • Resolution: Fixed
    • 6.22/00
    • 6.24/00
    • PyROOT
    • None

    Description

      This is to raise the issue of the new behaviour of strings (and possibly other types) in PyROOT 6.22.

      If you have a C++ function that has a return type std::string the PyROOT type of this return value is

      <class cppyy.gbl.std.string at 0xafdc2c0> in ROOT 6.22
      and
      <type 'str'> in ROOT 6.20

      This problem appears when you want to concatenate these two string representations

      >>> import cppyy
      >>> s1 = cppyy.gbl.std.string("test")
      >>> s2 = "test"
      >>> s1+s2
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      NotImplementedError
      

      The + is not overloaded for this type in cppyy, probably because it's not clear what is the type of the result (str vs. cppyy.gbl.std.string). Or course this can be easily solved by just

      >>> str(s1)+s2
      

      I am raising this because it's not uncommon especially in user code to call e.g a getName of a TObject and then do some string manipulation using + in python. All this type of code is broken.

      What is the ROOT position on this? Is this a bug in terms of ROOT or is this intended behaviour and one has just to fix the code?

      Attachments

        Activity

          People

            etejedor Enric Tejedor Saavedra
            mpetric Marko Petric (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: