Mercurial > p > roundup > code
changeset 6491:087cae2fbcea
Handle more ResourceWarning issues.
admin.py - remove unneeded close.
mailer.py - close debug log file.
indexer.py - close read of version file
memorydb.py - close python files being compled. Similiar to instance.
not sure why it's compoing things and not just letting instance do
it.
.travis.ymv disable all except 3.9-dev till we get a handle on errors.
also increase errors to 50 from 20.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 06 Sep 2021 16:03:31 -0400 |
| parents | 47a7fc39eaf0 |
| children | 4351c95faace |
| files | .travis.yml roundup/admin.py roundup/backends/indexer_dbm.py roundup/mailer.py roundup/test/memorydb.py |
| diffstat | 5 files changed, 20 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/.travis.yml Mon Sep 06 15:14:58 2021 -0400 +++ b/.travis.yml Mon Sep 06 16:03:31 2021 -0400 @@ -5,13 +5,13 @@ cache: pip python: - - 2.7 +# - 2.7 - 3.9-dev - - 3.8 - - 3.7 - - 3.6 - - 3.4 - - nightly +# - 3.8 +# - 3.7 +# - 3.6 +# - 3.4 +# - nightly #I would like to build and test the maint-1.6 and trunk/default @@ -153,7 +153,7 @@ -W "ignore:'U' mode::docutils.io" -W "ignore:unclosed:ResourceWarning:roundup.roundup.demo" -W "ignore:unclosed file:ResourceWarning:enum" - -v --maxfail=20 test/ --cov=roundup + -v --maxfail=50 test/ --cov=roundup after_success: - codecov
--- a/roundup/admin.py Mon Sep 06 15:14:58 2021 -0400 +++ b/roundup/admin.py Mon Sep 06 16:03:31 2021 -0400 @@ -1367,7 +1367,6 @@ if max_len > self.db.config.CSV_FIELD_SIZE: print("Warning: config csv_field_size should be at least %s" % max_len, file=sys.stderr) - jf.close() return 0 def do_exporttables(self, args):
--- a/roundup/backends/indexer_dbm.py Mon Sep 06 15:14:58 2021 -0400 +++ b/roundup/backends/indexer_dbm.py Mon Sep 06 16:03:31 2021 -0400 @@ -51,7 +51,9 @@ # for now the file itself is a flag self.force_reindex() elif os.path.exists(version): - version = open(version).read() + fd = open(version) + version = fd.read() + fd.close() # check the value and reindex if it's not the latest if version.strip() != '1': self.force_reindex() @@ -63,7 +65,9 @@ shutil.rmtree(self.indexdb_path) os.makedirs(self.indexdb_path) os.chmod(self.indexdb_path, 0o775) # nosec - allow group write - open(os.path.join(self.indexdb_path, 'version'), 'w').write('1\n') + fd = open(os.path.join(self.indexdb_path, 'version'), 'w') + fd.write('1\n') + fd.close() self.reindex = 1 self.changed = 1 @@ -260,6 +264,7 @@ filename = self.indexdb + initchar pickle_fh = open(filename, 'wb') pickle_fh.write(zlib.compress(pickle_str)) + pickle_fh.close() os.chmod(filename, 0o664) # save done
--- a/roundup/mailer.py Mon Sep 06 15:14:58 2021 -0400 +++ b/roundup/mailer.py Mon Sep 06 16:03:31 2021 -0400 @@ -278,9 +278,11 @@ # that resulting file can be openened in a mailer fmt = '%a %b %m %H:%M:%S %Y' unixfrm = 'From %s %s' % (sender, Date('.').pretty(fmt)) - open(self.debug, 'a').write('%s\nFROM: %s\nTO: %s\n%s\n\n' % + debug_fh = open(self.debug, 'a') + debug_fh.write('%s\nFROM: %s\nTO: %s\n%s\n\n' % (unixfrm, sender, ', '.join(to), message)) + debug_fh.close() else: # now try to send the message try:
--- a/roundup/test/memorydb.py Mon Sep 06 15:14:58 2021 -0400 +++ b/roundup/test/memorydb.py Mon Sep 06 16:03:31 2021 -0400 @@ -63,8 +63,9 @@ for fn in os.listdir(dirname): if not fn.endswith('.py'): continue vars = {} - exec(compile(open(os.path.join(dirname, fn)).read(), - os.path.join(dirname, fn), 'exec'), vars) + with open(os.path.join(dirname, fn)) as fd: + exec(compile(fd.read(), + os.path.join(dirname, fn), 'exec'), vars) vars['init'](db) tx_Source_init(db)
