AttributeError: dict object has no attribute iteritems

Bug #1160386 reported by Jason R. Coombs
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Fix Released
Low
scoder

Bug Description

I get this stack trace when trying to invoke lxml.html functionality on Python 3.3 64-bit on Windows 8:

Traceback (most recent call last):
  File "c:\python\lib\runpy.py", line 160, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python\lib\runpy.py", line 73, in _run_code
    exec(code, run_globals)
  File "C:\Users\jaraco\AppData\Roaming\Python\Python33\site-packages\yg.deploy-14.4.1dev-py3.3.egg\yg\deploy\swarms.py", line 105, in <module>
    reswarm()
  File "C:\Users\jaraco\AppData\Roaming\Python\Python33\site-packages\yg.deploy-14.4.1dev-py3.3.egg\yg\deploy\swarms.py", line 102, in reswarm
    [swarm(swarms[name], args.tag) for name in matched_names]
  File "C:\Users\jaraco\AppData\Roaming\Python\Python33\site-packages\yg.deploy-14.4.1dev-py3.3.egg\yg\deploy\swarms.py", line 102, in <listcomp>
    [swarm(swarms[name], args.tag) for name in matched_names]
  File "C:\Users\jaraco\AppData\Roaming\Python\Python33\site-packages\yg.deploy-14.4.1dev-py3.3.egg\yg\deploy\swarms.py", line 91, in swarm
    form.fields = dict(tag=tag)
  File "c:\python\lib\site-packages\lxml-3.1.0-py3.3-win-amd64.egg\lxml\html\__init__.py", line 772, in _fields__set
    for key, value in value.iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'

The issue is that iteritems isn't a method name in Python 3. It should be just 'items'.

I'm using lxml 3.1.0.

How is lxml source generated for Python 3? Does it run through 2to3 or is it a unified code base? I've installed lxml from the Windows installer provided here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml

I recognize it's possible the bug resides with the way the package was built for Windows. If you believe that is the case, can you indicate to me where the 2to3 conversion would happen to account for that change?

Otherwise, I suspect this issue might reside on other platforms/builds as well. Please advise.

Revision history for this message
scoder (scoder) wrote :

Thanks! Fix is here:

https://github.com/lxml/lxml/commit/a79e1d19665bbff2388494e33b435ad32e63f9fc

2to3 isn't used, all Python code runs in Py2 and Py3 alike (well, except for bugs like this...)

Changed in lxml:
assignee: nobody → Stefan Behnel (scoder)
importance: Undecided → Low
status: New → Fix Committed
Revision history for this message
scoder (scoder) wrote :

Fixed in lxml 3.1.1.

Changed in lxml:
status: Fix Committed → Fix Released
Revision history for this message
Jason R. Coombs (jaraco) wrote :

Thanks so much for the super-prompt fix and release!

scoder (scoder)
Changed in lxml:
milestone: none → 3.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.