Index: setuptools/package_index.py =================================================================== --- setuptools/package_index.py (revision 60968) +++ setuptools/package_index.py (working copy) @@ -749,7 +749,9 @@ files = [] for f in os.listdir(filename): if f=='index.html': - body = open(os.path.join(filename,f),'rb').read() + fp = open(os.path.join(filename,f),'rb') + body = fp.read() + fp.close() break elif os.path.isdir(os.path.join(filename,f)): f+='/' Index: setuptools/command/egg_info.py =================================================================== --- setuptools/command/egg_info.py (revision 60968) +++ setuptools/command/egg_info.py (working copy) @@ -444,6 +444,7 @@ match = re.match(r"Version:.*-r(\d+)\s*$", line) if match: return int(match.group(1)) + f.close() return 0 Index: setuptools/command/upload.py =================================================================== --- setuptools/command/upload.py (revision 60968) +++ setuptools/command/upload.py (working copy) @@ -80,7 +80,9 @@ dry_run=self.dry_run) # Fill in the data - content = open(filename,'rb').read() + f = open(filename,'rb') + content = f.read() + f.close() basename = os.path.basename(filename) comment = '' if command=='bdist_egg' and self.distribution.has_ext_modules(): Index: setuptools/command/easy_install.py =================================================================== --- setuptools/command/easy_install.py (revision 60968) +++ setuptools/command/easy_install.py (working copy) @@ -781,7 +781,9 @@ if locals()[name]: txt = os.path.join(egg_tmp, 'EGG-INFO', name+'.txt') if not os.path.exists(txt): - open(txt,'w').write('\n'.join(locals()[name])+'\n') + f = open(txt,'w') + f.write('\n'.join(locals()[name])+'\n') + f.close() def check_conflicts(self, dist): """Verify that there are no conflicting "old-style" packages""" @@ -1076,7 +1078,9 @@ if os.path.exists(sitepy): log.debug("Checking existing site.py in %s", self.install_dir) - current = open(sitepy,'rb').read() + f = open(sitepy,'rb') + current = f.read() + f.close() if not current.startswith('def __boot():'): raise DistutilsError( "%s is not a setuptools-generated site.py; please" @@ -1327,7 +1331,8 @@ saw_import = False seen = {} if os.path.isfile(self.filename): - for line in open(self.filename,'rt'): + f = open(self.filename,'rt') + for line in f: if line.startswith('import'): saw_import = True continue @@ -1345,6 +1350,7 @@ self.dirty = True # we cleaned up, so we're dirty now :) continue seen[path] = 1 + f.close() if self.paths and not saw_import: self.dirty = True # ensure anything we touch has import wrappers Index: pkg_resources.py =================================================================== --- pkg_resources.py (revision 60968) +++ pkg_resources.py (working copy) @@ -1453,7 +1453,10 @@ def get_metadata(self,name): if name=='PKG-INFO': - return open(self.path,'rU').read() + f = open(self.path,'rU') + metadata = f.read() + f.close() + return metadata raise KeyError("No metadata except PKG-INFO is available") def get_metadata_lines(self,name):