iterparse cannot load entity definitions from local dtd file
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Fix Released
|
Medium
|
six degree |
Bug Description
$python ./iterparse_bug.py
Python : sys.version_
lxml.etree : (3, 4, 4, 0)
libxml used : (2, 9, 0)
libxml compiled : (2, 9, 0)
libxslt used : (1, 1, 28)
libxslt compiled : (1, 1, 28)
end: leaf
end: root
Traceback (most recent call last):
File "./iterparse_
for action, elem in context:
File "iterparse.pxi", line 208, in lxml.etree.
lxml.etree.
The python script, the xml and the dtd are attached. Since those files are really simple, I'll also briefly show their contents here.
The main part of the python script looks like:
context = etree.iterparse
for action, elem in context:
print("%s: %s" % (action, elem.tag))
The xml file is:
<?xml version="1.0" encoding=
<!DOCTYPE foo SYSTEM "foo.dtd">
<root>
<leaf>
</root>
The dtd file is:
<!ELEMENT root (leaf)*>
<!ELEMENT leaf (#PCDATA)>
<!ENTITY bar "ö" >
I've tried to validate the xml with xmllint (xmllint --dtdvalid foo.dtd --noout foo.xml), and it was successful.
Also, when I use the following python code
import lxml.etree as etree
parser = etree.XMLParser
etree.parse(
it was also successful.
So it seems that the problem is with the iterparse function.
description: | updated |
Changed in lxml: | |
status: | New → Fix Released |
Changed in lxml: | |
milestone: | none → 3.6.1 |
importance: | Undecided → Medium |
Does "Fix released" mean that you found a version (3.6?) in which this is fixed? Can this ticket be closed then?