[pypy-issue] [issue1561] cppyy error binding enums

Alex Stewart tracker at bugs.pypy.org
Sat Jul 27 01:28:05 CEST 2013


New submission from Alex Stewart <foogod at gmail.com>:

For C++ classes which use enum types, the bindings generated by cppyy create a 
binding for the enum type (it shows up in 'dir(cppyy.gbl)'), but attempting to 
reference it produces an error:

>>>> import cppyy
>>>> cppyy.load_reflection_info('libMyClass.so')
<CPPLibrary object at 0x00007f2b7c210730>
>>>> dir(cppyy.gbl)
['MyClass', 'MyEnum']
>>>> cppyy.gbl.MyClass
<class '__main__.MyClass'>
>>>> cppyy.gbl.MyEnum
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: <class '__main__.::'> object has no attribute 'MyEnum' (details: 
<class '__main__.::'> object has no attribute 'unsigned int' (details: '<class 
'__main__.::'>' has no attribute 'unsigned int'))

This is arguably mainly cosmetic, as enums map to ints, so it's never normally 
necessary to instantiate the enum type explicitly anyway, but it can still 
potentially cause some annoyance/confusion in some scenarios.

(For example, I discovered this because I have a sanity-check script which I run 
against any generated bindings to make sure that all the generated symbols are 
loadable, which fails on any library that references any enums currently...)

----------
files: MyClass.h
messages: 5988
nosy: Foogod, pypy-issue
priority: bug
status: unread
title: cppyy error binding enums

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1561>
________________________________________


More information about the pypy-issue mailing list