summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/util.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2010-11-05 23:51:56 (GMT)
committerÉric Araujo <merwok@netwok.org>2010-11-05 23:51:56 (GMT)
commitbee5cef7dbff40734c347da5b93797e8db9103e8 (patch)
tree06dcc726207cfad3016f2b0f7c365fb9fe5b3cc6 /Lib/distutils/util.py
parentafb078dd2673d919ac3733104757c441f256f30f (diff)
downloadcpython-bee5cef7dbff40734c347da5b93797e8db9103e8.zip
cpython-bee5cef7dbff40734c347da5b93797e8db9103e8.tar.gz
cpython-bee5cef7dbff40734c347da5b93797e8db9103e8.tar.bz2
Always close files in distutils code and tests (#10252).
Diffstat (limited to 'Lib/distutils/util.py')
-rw-r--r--Lib/distutils/util.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 8175434..3081245 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -115,13 +115,15 @@ def get_platform ():
# behaviour.
pass
else:
- m = re.search(
- r'<key>ProductUserVisibleVersion</key>\s*' +
- r'<string>(.*?)</string>', f.read())
- f.close()
- if m is not None:
- macrelease = '.'.join(m.group(1).split('.')[:2])
- # else: fall back to the default behaviour
+ try:
+ m = re.search(
+ r'<key>ProductUserVisibleVersion</key>\s*' +
+ r'<string>(.*?)</string>', f.read())
+ if m is not None:
+ macrelease = '.'.join(m.group(1).split('.')[:2])
+ # else: fall back to the default behaviour
+ finally:
+ f.close()
if not macver:
macver = macrelease