mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
Always close files in distutils code and tests (#10252).
This commit is contained in:
parent
afb078dd26
commit
bee5cef7db
24 changed files with 261 additions and 171 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue