mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
bpo-35416: fix potential resource warnings in distutils (GH-10918)
This commit is contained in:
parent
7a0630c530
commit
58721a9030
4 changed files with 41 additions and 36 deletions
|
@ -537,7 +537,8 @@ class bdist_rpm(Command):
|
|||
'',
|
||||
'%' + rpm_opt,])
|
||||
if val:
|
||||
spec_file.extend(open(val, 'r').read().split('\n'))
|
||||
with open(val) as f:
|
||||
spec_file.extend(f.read().split('\n'))
|
||||
else:
|
||||
spec_file.append(default)
|
||||
|
||||
|
|
|
@ -247,12 +247,13 @@ class bdist_wininst(Command):
|
|||
self.announce("creating %s" % installer_name)
|
||||
|
||||
if bitmap:
|
||||
bitmapdata = open(bitmap, "rb").read()
|
||||
with open(bitmap, "rb") as f:
|
||||
bitmapdata = f.read()
|
||||
bitmaplen = len(bitmapdata)
|
||||
else:
|
||||
bitmaplen = 0
|
||||
|
||||
file = open(installer_name, "wb")
|
||||
with open(installer_name, "wb") as file:
|
||||
file.write(self.get_exe_bytes())
|
||||
if bitmap:
|
||||
file.write(bitmapdata)
|
||||
|
@ -287,7 +288,8 @@ class bdist_wininst(Command):
|
|||
bitmaplen, # number of bytes in bitmap
|
||||
)
|
||||
file.write(header)
|
||||
file.write(open(arcname, "rb").read())
|
||||
with open(arcname, "rb") as f:
|
||||
file.write(f.read())
|
||||
|
||||
def get_installer_filename(self, fullname):
|
||||
# Factored out to allow overriding in subclasses
|
||||
|
|
|
@ -125,8 +125,9 @@ class upload(PyPIRCCommand):
|
|||
data['comment'] = ''
|
||||
|
||||
if self.sign:
|
||||
with open(filename + ".asc", "rb") as f:
|
||||
data['gpg_signature'] = (os.path.basename(filename) + ".asc",
|
||||
open(filename+".asc", "rb").read())
|
||||
f.read())
|
||||
|
||||
# set up the authentication
|
||||
user_pass = (self.username + ":" + self.password).encode('ascii')
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Fix potential resource warnings in distutils. Patch by Mickaël Schoentgen.
|
Loading…
Add table
Add a link
Reference in a new issue