# HG changeset patch # User Augie Fackler # Date 2014-10-15 19:13:43 # Node ID 77c121da614327a579b3b4e5b173da947915acf3 # Parent 3232f92360d4da06d304ea6856568c9a3ab2e6b7 checklink: always close the NamedTemporaryFile This fixes test-patchbomb.t when using pypy with --pure. diff --git a/mercurial/posix.py b/mercurial/posix.py --- a/mercurial/posix.py +++ b/mercurial/posix.py @@ -156,9 +156,12 @@ def checklink(path): name = tempfile.mktemp(dir=path, prefix='hg-checklink-') try: fd = tempfile.NamedTemporaryFile(dir=path, prefix='hg-checklink-') - os.symlink(os.path.basename(fd.name), name) - os.unlink(name) - return True + try: + os.symlink(os.path.basename(fd.name), name) + os.unlink(name) + return True + finally: + fd.close() except AttributeError: return False except OSError, inst: