PythonElementClassLookup throws error when reaches comments

Bug #1722776 reported by david greisen on 2017-10-11
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Low
scoder

Bug Description

Python : sys.version_info(major=3, minor=6, micro=2, releaselevel='final', serial=0)
lxml.etree : (4, 0, 0, 0)
libxml used : (2, 9, 5)
libxml compiled : (2, 9, 5)
libxslt used : (1, 1, 30)

To reproduce:

import lxml.etree as et
class MyLookup(et.PythonElementClassLookup):
    def lookup(self, document, element):
        return None

parser = et.XMLParser()
parser.set_element_class_lookup(MyLookup())

el = et.fromstring('<a><!-- hello world --></a>', parser)
el.getchildren()
# File "<stdin>", line 1, in <module>
# File "src/lxml/lxml.etree.pyx", line 1351, in lxml.etree._Element.getchildren (src/lxml/lxml.etree.c:57046)
# File "src/lxml/apihelpers.pxi", line 805, in lxml.etree._collectChildren (src/lxml/lxml.etree.c:25788)
# File "src/lxml/lxml.etree.pyx", line 1617, in lxml.etree._elementFactory (src/lxml/lxml.etree.c:60167)
# File "src/lxml/classlookup.pxi", line 405, in lxml.etree._parser_class_lookup (src/lxml/lxml.etree.c:93219)
# File "src/lxml/classlookup.pxi", line 526, in lxml.etree._python_class_lookup (src/lxml/lxml.etree.c:94017)
# TypeError: Cannot convert lxml.etree._ReadOnlyProxy to lxml.etree._ReadOnlyElementProxy

david greisen (dgreisen) on 2017-10-11
description: updated
scoder (scoder) wrote :
Changed in lxml:
assignee: nobody → scoder (scoder)
importance: Undecided → Low
status: New → Fix Committed
scoder (scoder) on 2017-10-13
Changed in lxml:
milestone: none → 4.1.0
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers