Mercurial > p > roundup > code
diff roundup/backends/indexer_dbm.py @ 7690:d17e57220a62 2.3.1a0
fix: close file properly in indexer_dbm.py:save_index()
Fix this error found in debug logs of gentoo packaging of round 2.2.0.
/roundup/backends/indexer_dbm.py:253: ResourceWarning: unclosed file
<_io.BufferedWriter name='test-index/indexes/index.db-'>
open(self.indexdb+'-', 'wb').write(zlib.compress(marshal.dumps(dbfil)))
Also added test that calls save_index(), reloads the index and tests
that the original item. I am not sure how Gentoo hit
this But they were missing a number of backends. So it's possible that
indexer_dbm.py is not getting fully tested depending on what is
installed on the system. Codecov from CI didnt show
indexer_dbm.py:save_index() being covered.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 02 Nov 2023 18:55:47 -0400 |
| parents | e605ddb45701 |
| children |
line wrap: on
line diff
--- a/roundup/backends/indexer_dbm.py Mon Oct 30 21:57:21 2023 -0400 +++ b/roundup/backends/indexer_dbm.py Thu Nov 02 18:55:47 2023 -0400 @@ -250,7 +250,9 @@ # First write the much simpler filename/fileid dictionaries dbfil = {'WORDS': None, 'FILES': self.files, 'FILEIDS': self.fileids} - open(self.indexdb+'-', 'wb').write(zlib.compress(marshal.dumps(dbfil))) + marshal_fh = open(self.indexdb+'-', 'wb') + marshal_fh.write(zlib.compress(marshal.dumps(dbfil))) + marshal_fh.close() # The hard part is splitting the word dictionary up, of course letters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ#_"
