summaryrefslogtreecommitdiff
path: root/Doc/tools/extensions/patchlevel.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2017-02-09 16:09:03 +0100
committerNick Coghlan <ncoghlan@gmail.com>2017-02-09 16:09:03 +0100
commit2a1d833d5da7fa7a01a2eef183b0a208ed019427 (patch)
tree8da3ebb695ae55c69d0a58691403fb13d96a9476 /Doc/tools/extensions/patchlevel.py
parentc6180bb73c8c7c7f9d8ea9816487b710597b6fc1 (diff)
parentbbd3587a29510bd5a318e0a19fc8570c0cd3b622 (diff)
downloadcpython-2a1d833d5da7fa7a01a2eef183b0a208ed019427.tar.gz
Merge issue #26355 fix from 3.6
Diffstat (limited to 'Doc/tools/extensions/patchlevel.py')
-rw-r--r--Doc/tools/extensions/patchlevel.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/Doc/tools/extensions/patchlevel.py b/Doc/tools/extensions/patchlevel.py
index 919ba4a12e..617f28c252 100644
--- a/Doc/tools/extensions/patchlevel.py
+++ b/Doc/tools/extensions/patchlevel.py
@@ -24,15 +24,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'])