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

PyROOT cross-inheritance fails to call proper constructor

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: 6.22/02
    • Fix Version/s: master, 6.22/04
    • Component/s: PyROOT
    • Labels:
      None
    • Environment:

      Centos7, gcc9

      Description

      The following reproducer fails when using the '6.22.00-patches' and 'master' branches and does not fail when using 6.22.00 (with the LCG patch) as it is released in LCG_89.

      $ cat test.py
      from __future__ import print_function
      import ROOT
       
      ROOT.gInterpreter.Declare("""
      #include <string>
      class CppAlg  {
        public:
          CppAlg(std::string name) : m_name(name) {} 
          virtual void virtual_method(std::string&) { }
          void call() { virtual_method(m_name); }
          virtual ~CppAlg() {}
        private:
          std::string m_name;
      };
      """)
       
      class Alg(ROOT.CppAlg):
        def __init__(self, name):
          super(Alg, self).__init__(name)
        def virtual_method(self, name):
          print('Overwritten virtual method', name)
      a = Alg('MyAlg')
      a.call()
      

      To reproduce:

      $ source /cvmfs/sft.cern.ch/lcg/views/dev4/latest/x86_64-centos7-gcc9-opt/setup.sh
      $ python test.py
      Traceback (most recent call last):
        File "test.py", line 22, in <module>
          a = Alg('MyAlg')
        File "test.py", line 19, in __init__
          super(Alg, self).__init__(name)
      TypeError: none of the 2 overloaded methods succeeded. Full details:
        no constructor available for 'CppAlg'
        CppAlg::CppAlg(const CppAlg&) =>
          TypeError: could not convert argument 1
      

      while with LCG_98

      $ source /cvmfs/sft.cern.ch/lcg/views/LCG_98/x86_64-centos7-gcc9-opt/setup.sh
      $ python test.py
      Overwritten virtual method MyAlg
      

        Attachments

          Activity

            People

            Assignee:
            etejedor Enric Tejedor Saavedra
            Reporter:
            mato Pere Mato Vila
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: