summaryrefslogtreecommitdiffstats
path: root/Lib/xml/etree/ElementPath.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/xml/etree/ElementPath.py')
-rw-r--r--Lib/xml/etree/ElementPath.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/Lib/xml/etree/ElementPath.py b/Lib/xml/etree/ElementPath.py
index d914ddb..4b4d8cf 100644
--- a/Lib/xml/etree/ElementPath.py
+++ b/Lib/xml/etree/ElementPath.py
@@ -114,7 +114,10 @@ def prepare_self(next, token):
return select
def prepare_descendant(next, token):
- token = next()
+ try:
+ token = next()
+ except StopIteration:
+ return
if token[0] == "*":
tag = "*"
elif not token[0]:
@@ -148,7 +151,10 @@ def prepare_predicate(next, token):
signature = []
predicate = []
while 1:
- token = next()
+ try:
+ token = next()
+ except StopIteration:
+ return
if token[0] == "]":
break
if token[0] and token[0][:1] in "'\"":
@@ -261,7 +267,10 @@ def iterfind(elem, path, namespaces=None):
if path[:1] == "/":
raise SyntaxError("cannot use absolute path on element")
next = iter(xpath_tokenizer(path, namespaces)).__next__
- token = next()
+ try:
+ token = next()
+ except StopIteration:
+ return
selector = []
while 1:
try: