From 09697cfec76ea4b68d0e16931cce4dc87038ab83 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 6 Apr 2018 12:09:51 +0200 Subject: [PATCH] debian/lib/python/debian_linux/debian.py: Close changelog after parsing --- debian/changelog | 1 + debian/lib/python/debian_linux/debian.py | 34 ++++++++++++------------ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/debian/changelog b/debian/changelog index 7f111bb72557..f13f9305856d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -46,6 +46,7 @@ linux (4.16-1~exp1) UNRELEASED; urgency=medium * debian/config: Rename [build]signed-modules setting to signed-code * debian/lib/python/debian_linux/gencontrol.py: Allow overriding output filenames + * debian/lib/python/debian_linux/debian.py: Close changelog after parsing -- Roger Shimizu Fri, 23 Mar 2018 21:10:34 +0900 diff --git a/debian/lib/python/debian_linux/debian.py b/debian/lib/python/debian_linux/debian.py index 7ad5f93274c7..6f40c6222f63 100644 --- a/debian/lib/python/debian_linux/debian.py +++ b/debian/lib/python/debian_linux/debian.py @@ -38,23 +38,23 @@ class Changelog(list): def __init__(self, dir='', version=None): if version is None: version = Version - f = open(os.path.join(dir, "debian/changelog"), encoding="UTF-8") - while True: - line = f.readline() - if not line: - break - match = self._re.match(line) - if not match: - continue - try: - v = version(match.group('version')) - except Exception: - if not len(self): - raise - v = Version(match.group('version')) - self.append(self.Entry(match.group('distribution'), - match.group('source'), v, - match.group('urgency'))) + with open(os.path.join(dir, "debian/changelog"), encoding="UTF-8") as f: + while True: + line = f.readline() + if not line: + break + match = self._re.match(line) + if not match: + continue + try: + v = version(match.group('version')) + except Exception: + if not len(self): + raise + v = Version(match.group('version')) + self.append(self.Entry(match.group('distribution'), + match.group('source'), v, + match.group('urgency'))) class Version(object):