Commit 68d8bca1 authored by Marius Gedminas's avatar Marius Gedminas

Use with open(): ... for peace of mind

parent 033512a3
...@@ -1183,7 +1183,7 @@ class FileStorage( ...@@ -1183,7 +1183,7 @@ class FileStorage(
handle_dir = ZODB.blob.remove_committed_dir handle_dir = ZODB.blob.remove_committed_dir
# Fist step: move or remove oids or revisions # Fist step: move or remove oids or revisions
fp = open(os.path.join(self.blob_dir, '.removed'), 'rb') with open(os.path.join(self.blob_dir, '.removed'), 'rb') as fp:
for line in fp: for line in fp:
line = binascii.unhexlify(line.strip()) line = binascii.unhexlify(line.strip())
...@@ -1198,7 +1198,6 @@ class FileStorage( ...@@ -1198,7 +1198,6 @@ class FileStorage(
continue continue
if len(line) != 16: if len(line) != 16:
fp.close()
raise ValueError("Bad record in ", self.blob_dir, '.removed') raise ValueError("Bad record in ", self.blob_dir, '.removed')
oid, tid = line[:8], line[8:] oid, tid = line[:8], line[8:]
...@@ -1210,7 +1209,6 @@ class FileStorage( ...@@ -1210,7 +1209,6 @@ class FileStorage(
assert not os.path.exists(path) assert not os.path.exists(path)
maybe_remove_empty_dir_containing(path) maybe_remove_empty_dir_containing(path)
fp.close()
os.remove(os.path.join(self.blob_dir, '.removed')) os.remove(os.path.join(self.blob_dir, '.removed'))
if not self.pack_keep_old: if not self.pack_keep_old:
......
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