Shoobx / xmldiff

A library and command line utility for diffing xml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

xmldiff crashes when comparing PI and element

laurent-laporte-pro opened this issue · comments

xmldiff crashes when it compares a processing-instruction with an element.

Using xmldiff v2.4 and lxml v4.4.1

Unit test:

import xmldiff.main
from lxml import etree


def test_xml_diff():
    xmldiff.main.diff_trees(
        etree.XML("<ROOT><?pi?></ROOT>"), etree.XML("<ROOT><ie/></ROOT>"))

Result:

test_xmldiff.py:4 (test_xml_diff)
test_xmldiff.py:6: in test_xml_diff
    xmldiff.main.diff_trees(etree.XML("<ROOT><?pi?></ROOT>"), etree.XML("<ROOT><ie/></ROOT>"))
../../virtualenv/tmp/lib/site-packages/xmldiff/main.py:28: in diff_trees
    return list(diffs)
../../virtualenv/tmp/lib/site-packages/xmldiff/diff.py:439: in diff
    for action in self.update_node_tag(lnode, rnode):
../../virtualenv/tmp/lib/site-packages/xmldiff/diff.py:233: in update_node_tag
    left.tag = right.tag
E   AttributeError: attribute 'tag' of 'lxml.etree._ProcessingInstruction' objects is not writable

It will crash with any sort of processing instruction AFAIK.
See #78