From 15c78003846edcd7b8447936ef76df1140286c5a Mon Sep 17 00:00:00 2001 From: Martin Panter Date: Sun, 29 Jan 2017 10:17:17 +0000 Subject: Issues #29349: Add NEWS for 3.7; use ?with? statement --- Doc/tools/extensions/patchlevel.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'Doc/tools/extensions/patchlevel.py') diff --git a/Doc/tools/extensions/patchlevel.py b/Doc/tools/extensions/patchlevel.py index 9558b9ce43..9ba32bd8b9 100644 --- a/Doc/tools/extensions/patchlevel.py +++ b/Doc/tools/extensions/patchlevel.py @@ -22,15 +22,12 @@ def get_header_version_info(srcdir): rx = re.compile(r'\s*#define\s+([a-zA-Z][a-zA-Z_0-9]*)\s+([a-zA-Z_0-9]+)') d = {} - f = open(patchlevel_h) - try: + with open(patchlevel_h) as f: for line in f: m = rx.match(line) if m is not None: name, value = m.group(1, 2) d[name] = value - finally: - f.close() release = version = '%s.%s' % (d['PY_MAJOR_VERSION'], d['PY_MINOR_VERSION']) micro = int(d['PY_MICRO_VERSION']) -- cgit v1.2.1