Mercurial > p > roundup > code
diff roundup/cgi/engine_zopetal.py @ 6479:808f7a8ed2b6
Clean leaking file descriptors. Eliminates ResourceWarnings.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 05 Sep 2021 23:38:10 -0400 |
| parents | 38d04127d9bb |
| children | 408fd477761f |
line wrap: on
line diff
--- a/roundup/cgi/engine_zopetal.py Mon Aug 30 16:17:46 2021 -0400 +++ b/roundup/cgi/engine_zopetal.py Sun Sep 05 23:38:10 2021 -0400 @@ -42,7 +42,8 @@ pt = RoundupPageTemplate() # use pt_edit so we can pass the content_type guess too content_type = mimetypes.guess_type(filename)[0] or 'text/html' - pt.pt_edit(open(src).read(), content_type) + with open(src) as srcd: + pt.pt_edit(srcd.read(), content_type) pt.id = filename pt.mtime = stime # Add it to the cache. We cannot do this until the template
