Issue #72 resolved

0.6 Using dict.iteritems(), broken on Python 3.

Simon Sapin
created an issue

I’m trying out CFFI 0.6, and got the traceback below while accessing cairo.CAIRO_FORMAT_ARGB32, cairo being returned by ffi.dlopen(), and CAIRO_FORMAT_ARGB32 being an enum value.

  File "/home/simon/.virtualenvs/cairocffi-cffi0.6/lib/python3.3/site-packages/cffi/api.py", line 403, in __getattr__
    make_accessor(name)
  File "/home/simon/.virtualenvs/cairocffi-cffi0.6/lib/python3.3/site-packages/cffi/api.py", line 389, in make_accessor
    for key, tp in ffi._parser._declarations.iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'

My virtualenv happens to run Python 3, which doesn’t have dict.iteritems. In my own code, I often have a compat.py module with code like this:

try:
    iteritems = dict.iteritems
except AttributeError:
    iteritems = dict.items

Then using eg. for k, v in iteritems(some_dict).

I don’t know what else might be broken on Python 3.

Comments (2)

  1. Log in to comment