Issue 1698944: dtdparser discards last line (original) (raw)
The DTD parser in xml.parsers.xmlproc.dtdparser sometimes simply ignores the last line of the input file. Here is the Python program I used to test it:
------begin
from xml.parsers.xmlproc.dtdparser import DTDParser,
DTDConsumer, DTDConsumerPE
import tracer
def parse_dtd(dtd): parser = DTDParser() handler = DTDConsumerPE() parser.set_dtd_consumer(handler) parser.feed(dtd)
tracer.trace(DTDConsumer)
parse_dtd('''
<!ENTITY % score PUBLIC
"-//Recordare//ELEMENTS MusicXML 1.1 Score//EN"
"t.dtd">
%score;
''') ------end
where the file t.dtd contained:
------begin ------end
The tracer package (my own code) indicated that the opus element was never parsed. The same was true if I added a blank line after the %score; entity reference. However, if I added two blank lines after the entity reference, the element declaration was processed.
I would note that while the bug exists in the original xmlproc package (at least in xmlproc 0.70, downloadable from http://www.garshol.priv.no/download/software/xmlproc/), the bug does not exist in the PyXML package (downloadable from http://sourceforge.net/projects/pyxml).