mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 03:50:24 +09:00
debian/lib/python/debian_linux/utils.py: Use 'with' to manage file handles
This commit is contained in:
1
debian/changelog
vendored
1
debian/changelog
vendored
@@ -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
|
||||
|
||||
|
||||
12
debian/lib/python/debian_linux/utils.py
vendored
12
debian/lib/python/debian_linux/utils.py
vendored
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user