Prevent XPath from returning the same node multiple times in Python3

This commit is contained in:
João Henrique 2019-09-04 15:53:02 -03:00
parent ae2a689a68
commit f15a9f7628
1 changed files with 5 additions and 0 deletions

View File

@ -261,6 +261,11 @@ class XPath(object):
# e.g., //func/*/stat might have a token node for which
# we can't go looking for stat nodes.
matching = element.evaluate(node)
# See issue antlr#370 - Prevents XPath from returning the
# same node multiple times
matching = filter(lambda m: m not in work_next, matching)
work_next.extend(matching)
work = work_next