summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2014-11-23 05:56:23 (GMT)
committerRaymond Hettinger <python@rcn.com>2014-11-23 05:56:23 (GMT)
commit828d932a2c4da5eb7c05e85dfe51f5f6db68084d (patch)
treeb5ef3264ae6c338c1dbdf019ded3b98c3a8b123c /Lib
parent1bf472933bb66ba146ed5938cb8beb06e67bd234 (diff)
downloadcpython-828d932a2c4da5eb7c05e85dfe51f5f6db68084d.zip
cpython-828d932a2c4da5eb7c05e85dfe51f5f6db68084d.tar.gz
cpython-828d932a2c4da5eb7c05e85dfe51f5f6db68084d.tar.bz2
PEP 479: Don't let StopIteration bubble out of calls to next() inside a generator.
Diffstat (limited to 'Lib')
-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: