semidbm
semidbm copied to clipboard
File not closed when verify_header fails
I need to convert dbhash because it's not supported in python3, so in python2 I:
- try to open as semidb
- if fail, open as dbhash, copy keys to new-name, close, rename.
This lets the conversion happen automagically in my db code, rather than needing explicit conversion. BUT the rename fails because the file has not been closed, so in mmapload.py I made the change:
try: # Phil added try...except
header = f.read(8)
self._verify_header(header)
except:
f.close()
raise
I did not try to submit a change because it may be better wrapped in the other try clause.