Skip to content

[Python] Regression in accessing protected data members in ROOT 6.32 after cppyy upgrade #16852

@guitargeek

Description

@guitargeek

Check duplicate issues.

  • Checked for duplicates

Description

Getting access to protected data members when inheriting from a C++ stopped working (for protected functions it still works).

Reproducer

import cppyy

cppyy.cppdef("""

class MyBaseClass {
public:
   virtual ~MyBaseClass() = default;
protected:
   int protectedFunc() { return 5; }
   int _protectedData = 4;
};

""")

class MyDerivedClass(cppyy.gbl.MyBaseClass):
    pass

my_obj = MyDerivedClass()

print(my_obj.protectedFunc()) # works!
print(my_obj._protectedData) # doesn't work with ROOT 6.32!

The reproducer fails on lxplus9 with ROOT 6.32.06 and Python 3.9.18

5
Traceback (most recent call last):
  File "/afs/cern.ch/user/r/rembserj/repro.py", line 21, in <module>
    print(my_obj._protectedData) # doesn't work!
AttributeError: 'MyDerivedClass' object has no attribute '_protectedData'

However, on lxplus8 with ROOT 6.30/08 and Python 3.6.8, it works.

ROOT version

ROOT >=6.32.00

Installation method

Any

Operating system

Any

Additional context

The priority of this issue is set to low, since I'm not aware of any people making use of that feature. The 6.32 release cycle came and went without any complaints at least.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions