Commit 94c75ee7 authored by Stefan Behnel's avatar Stefan Behnel

Clean up some file open/close usages in the test runner.

parent 2f01ea64
...@@ -460,8 +460,7 @@ def memoize(f): ...@@ -460,8 +460,7 @@ def memoize(f):
def parse_tags(filepath): def parse_tags(filepath):
tags = defaultdict(list) tags = defaultdict(list)
parse_tag = re.compile(r'#\s*(\w+)\s*:(.*)$').match parse_tag = re.compile(r'#\s*(\w+)\s*:(.*)$').match
f = io_open(filepath, encoding='ISO-8859-1', errors='ignore') with io_open(filepath, encoding='ISO-8859-1', errors='ignore') as f:
try:
for line in f: for line in f:
# ignore BOM-like bytes and whitespace # ignore BOM-like bytes and whitespace
line = line.lstrip(UTF8_BOM_BYTES).strip() line = line.lstrip(UTF8_BOM_BYTES).strip()
...@@ -486,8 +485,6 @@ def parse_tags(filepath): ...@@ -486,8 +485,6 @@ def parse_tags(filepath):
tags[tag].extend(filter(None, [value.strip() for value in values])) tags[tag].extend(filter(None, [value.strip() for value in values]))
elif tags: elif tags:
break # assume all tags are in one block break # assume all tags are in one block
finally:
f.close()
return tags return tags
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment