root icon indicating copy to clipboard operation
root copied to clipboard

Enums are not correctly resolved by PyROOT when using an alias within a class/struct

Open paguenther opened this issue 4 years ago • 4 comments

  • [x] Checked for duplicates

Describe the bug

PyROOT is not able correctly resolve an enum when it is aliased in a struct.

Expected behavior

Giving a different name to the enum should not cause PyROOT to fail to correctly resolve it.

To Reproduce

Python 3.9.6 (default, Sep  6 2021, 15:36:22) 
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>> gROOT = ROOT.gROOT
>>> gROOT.ProcessLine('enum Enum { a,b,c }')
0
>>> ROOT.Enum
<class 'ROOT._facade.Enum'>
>>> ROOT.Enum.a
0
>>> ROOT.Enum.b
1
>>>> gROOT.ProcessLine('struct Track { using Type = Enum; }')
0
>>> ROOT.Track.Type.a
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'int' has no attribute 'a'
>>> ROOT.Enum.a
0
>>> 

Setup

ROOT 6.24.06 from LCG101 on CentOS7

Additional context

paguenther avatar Nov 05 '21 09:11 paguenther

@martamaja10

paguenther avatar Oct 16 '23 11:10 paguenther

slight ping because this has been open for nearly two years now, and still has this problem more recent ROOT versions

paguenther avatar Oct 20 '23 10:10 paguenther

Thanks @paguenther for the ping! PyROOT uses cppyy to create the automatic Python bindings, so these kind of problems are good to also post there: https://github.com/wlav/cppyy/issues/214

guitargeek avatar Feb 05 '24 14:02 guitargeek

Maybe also related: https://github.com/root-project/cling/issues/521

ferdymercury avatar Apr 12 '24 09:04 ferdymercury