Enums in distributed modules

29 views
Skip to first unread message

Hakan Ardo

unread,
Sep 27, 2012, 8:11:07 AM9/27/12
to pytho...@googlegroups.com
Hi,
I'm having issues with enums. I have tst.py containing:

from cffi import FFI
ffi = FFI()
ffi.cdef("""
typedef enum {DT_MEIJSTER_2000, ...} dt_algorithm;
""")

lib = ffi.verify("""
typedef enum {DT_MEIJSTER_2000, FOO} dt_algorithm;
""")

which works when used localy:

$ python -c 'import tst; print tst.lib.DT_MEIJSTER_2000'
0

When I install it using "python setup.y install" with setup.py containing:

from distutils.core import setup
import tst
setup(name='bsdopendirtype',
py_modules=['tst'],
ext_modules=[tst.ffi.verifier.get_extension()])

and try to use the centrally installed version, it fails:

$ cd /tmp
$ python -c 'import tst; print tst.lib.DT_MEIJSTER_2000'
[...]
File "/usr/local/lib/python2.7/dist-packages/cffi-0.4-py2.7-linux-x86_64.egg/cffi/vengine_cpy.py",
line 583, in _loading_cpy_enum
for enumerator in tp.enumerators]
AttributeError: 'module' object has no attribute 'DT_MEIJSTER_2000'

If I replace the cdef with:

ffi.cdef("""
typedef int dt_algorithm;
static const int DT_MEIJSTER_2000;
""")

it works as expected.


--
Håkan Ardö

Armin Rigo

unread,
Sep 27, 2012, 1:02:36 PM9/27/12
to pytho...@googlegroups.com
Hi Hakan,

On Thu, Sep 27, 2012 at 2:11 PM, Hakan Ardo <ha...@debian.org> wrote:
> AttributeError: 'module' object has no attribute 'DT_MEIJSTER_2000'

Fixed. Thanks for the bug report :-)

Armin

Hakan Ardo

unread,
Sep 27, 2012, 4:06:06 PM9/27/12
to pytho...@googlegroups.com, ar...@tunes.org
Great, thanx!
Reply all
Reply to author
Forward
0 new messages