Mercurial > public > mercurial-scm > hg-stable
diff setup.py @ 13400:14f3795a5ed7
explicitly close files
Add missing calls to close() to many places where files are
opened. Relying on reference counting to catch them soon-ish is not
portable and fails in environments with a proper GC, such as PyPy.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Fri, 24 Dec 2010 15:23:01 +0100 |
parents | 4c50552fc9bc |
children | e42d18538e1d |
line wrap: on
line diff
--- a/setup.py Fri Feb 11 22:24:10 2011 +0800 +++ b/setup.py Fri Dec 24 15:23:01 2010 +0100 @@ -294,14 +294,18 @@ libdir = uplevel * ('..' + os.sep) + self.install_lib[len(common):] for outfile in self.outfiles: - data = open(outfile, 'rb').read() + fp = open(outfile, 'rb') + data = fp.read() + fp.close() # skip binary files if '\0' in data: continue data = data.replace('@LIBDIR@', libdir.encode('string_escape')) - open(outfile, 'wb').write(data) + fp = open(outfile, 'wb') + fp.write(data) + fp.close() cmdclass = {'build_mo': hgbuildmo, 'build_ext': hgbuildext,