mirror of
https://github.com/python/cpython.git
synced 2026-01-06 07:22:09 +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
|
|
@ -340,4 +340,8 @@ def get_exe_bytes(self):
|
|||
sfix = ''
|
||||
|
||||
filename = os.path.join(directory, "wininst-%.1f%s.exe" % (bv, sfix))
|
||||
return open(filename, "rb").read()
|
||||
f = open(filename, "rb")
|
||||
try:
|
||||
return f.read()
|
||||
finally:
|
||||
f.close()
|
||||
|
|
|
|||
|
|
@ -76,7 +76,11 @@ def upload_file(self, command, pyversion, filename):
|
|||
|
||||
# Fill in the data - send all the meta-data in case we need to
|
||||
# register a new release
|
||||
content = open(filename,'rb').read()
|
||||
f = open(filename,'rb')
|
||||
try:
|
||||
content = f.read()
|
||||
finally:
|
||||
f.close()
|
||||
meta = self.distribution.metadata
|
||||
data = {
|
||||
# action
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue