Skip to content
Snippets Groups Projects
Commit 6f59154fb604 authored by Nicolas Dumazet's avatar Nicolas Dumazet
Browse files

tests: catch re.error if test line is not a valid regular expression

parent 3cdd6fdc3d9e
No related merge requests found
......@@ -499,6 +499,13 @@
finally:
os.remove(name)
def rematch(el, l):
try:
return re.match(el, l)
except re.error:
# el is an invalid regex
return False
pos = -1
postout = []
for n, l in enumerate(output):
......@@ -513,7 +520,7 @@
if el == l: # perfect match (fast)
postout.append(" " + l)
elif el and re.match(el, l): # fallback regex match
elif el and rematch(el, l): # fallback regex match
postout.append(" " + el)
else: # mismatch - let diff deal with it
postout.append(" " + l)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment