Comment 3 for bug 1369362

Revision history for this message
Milorad Pop-Tosic (pop-0) wrote :

I am still getting this error on the latest lxml 3.4.1 on Python 3.4.0.

lxml.etree: (3, 4, 1, 0)
libxml used: (2, 9, 1)
libxml compiled: (2, 9, 1)
libxslt used: (1, 1, 28)
libxslt compiled: (1, 1, 28)
Traceback (most recent call last):
  File "test.py", line 24, in <module>
    cleaned = cleaner.clean_html(html_string)
  File "/home/milorad/envs/hiri-py3/lib/python3.4/site-packages/lxml/html/clean.py", line 504, in clean_html
    self(doc)
  File "/home/milorad/envs/hiri-py3/lib/python3.4/site-packages/lxml/html/clean.py", line 262, in __call__
    for aname in attrib.keys():
RuntimeError: dictionary changed size during iteration

This should simply be a matter of iterating over list(attrib.keys()) here:
https://github.com/lxml/lxml/blob/50a8cbbb4fb35a794977c3d8ecc43ddac4f4413e/src/lxml/html/clean.py#L271

And possibly here:
https://github.com/lxml/lxml/blob/50a8cbbb4fb35a794977c3d8ecc43ddac4f4413e/src/lxml/html/clean.py#L262