debian/lib/python/debian_linux/utils.py: Use 'with' to manage file handles

This commit is contained in:
Ben Hutchings
2019-10-23 20:50:13 +01:00
parent 307b011acf
commit c8e5a878e8
2 changed files with 7 additions and 6 deletions

1
debian/changelog vendored
View File

@@ -9,6 +9,7 @@ linux (5.3.7-2) UNRELEASED; urgency=medium
* gencontrol: Generalise substitution of debhelper config template
* Add maint scripts to meta-packages to convert doc directories to symlinks
(Closes: #942861)
* debian/lib/python/debian_linux/utils.py: Use 'with' to manage file handles
-- Ben Hutchings <ben@decadent.org.uk> Wed, 23 Oct 2019 18:32:15 +0100

View File

@@ -23,12 +23,12 @@ class Templates(object):
for dir in self.dirs:
filename = "%s/%s%s" % (dir, name, suffix)
if os.path.exists(filename):
f = codecs.open(filename, 'r', 'utf-8')
if prefix == 'control':
return read_control(f)
if prefix == 'tests-control':
return read_tests_control(f)
return f.read()
with codecs.open(filename, 'r', 'utf-8') as f:
if prefix == 'control':
return read_control(f)
if prefix == 'tests-control':
return read_tests_control(f)
return f.read()
def get(self, key, default=None):
if key in self._cache: