IndexError: list index out of range
ZeroDevNull opened this issue · comments
OS: Ubuntu 20.04
XMLDIFF version: 2.4/2.6.3
When I diff these two files I get the following error:
Traceback (most recent call last):
File "/data/usr/bin/xmlpatch", line 11, in <module>
load_entry_point('xmldiff==2.4', 'console_scripts', 'xmlpatch')()
File "/data/usr/lib/python3/dist-packages/xmldiff/main.py", line 171, in patch_command
result = patch_file(args.patchfile, args.xmlfile)
File "/data/usr/lib/python3/dist-packages/xmldiff/main.py", line 148, in patch_file
tree = patch_tree(actions, tree)
File "/data/usr/lib/python3/dist-packages/xmldiff/main.py", line 124, in patch_tree
return patcher.patch(actions, tree)
File "/data/usr/lib/python3/dist-packages/xmldiff/patch.py", line 15, in patch
self.handle_action(action, result)
File "/data/usr/lib/python3/dist-packages/xmldiff/patch.py", line 22, in handle_action
method(action, tree)
File "/data/usr/lib/python3/dist-packages/xmldiff/patch.py", line 34, in _handle_RenameNode
tree.xpath(action.node)[0].tag = action.tag
IndexError: list index out of range
The commands I run are:
xmldiff cfgspawnabletypes1.xml cfgspawnabletypes2.xml > cfgspawnabletypes.diff
xmlpatch cfgspawnabletypes.diff cfgspawnabletypes1.xml
The exact files used:
xmltest.zip
I've tried to remove all whitepaces and comments but that didn't work.
Well, this is a bug, but these files are huge, and almost every single item has changed, so it's practically impossible to debug this. There are 550 actions before the one that fails, and to figure out why this one fails, I would have to step through all of them and see how they affect the state of the tree to figure out what goes wrong, because it's somewhere in the preceding 550 actions.
If you can make a smaller case with a similar error that could be helpful.
Also, the diffs are larger than the original file, so I'm not sure what the purpose of diffing and patching is in this case.
Hello, I have a similar problem, this is my error message, is it equivalent?
File "/venv/lib/python3.8/site-packages/xmldiff/main.py", line 50, in diff_files
return _diff(etree.parse, left, right,
File "/venv/lib/python3.8/site-packages/xmldiff/main.py", line 38, in _diff
return diff_trees(left_tree, right_tree, diff_options=diff_options,
File "/venv/lib/python3.8/site-packages/xmldiff/main.py", line 30, in diff_trees
return formatter.format(diffs, left)
File "/venv/lib/python3.8/site-packages/xmldiff/formatting.py", line 717, in format
actions.extend(self.handle_action(action, orig_tree))
File "/venv/lib/python3.8/site-packages/xmldiff/formatting.py", line 727, in handle_action
for item in method(action, orig_tree):
File "/venv/lib/python3.8/site-packages/xmldiff/formatting.py", line 758, in _handle_MoveNode
node = orig_tree.xpath(action.node)[0]
IndexError: list index out of range
No, but it may be related. Again, if someone could make a smaller example where this happens I should have time to look at it.