changeset 22946:77c121da6143

checklink: always close the NamedTemporaryFile This fixes test-patchbomb.t when using pypy with --pure.
author Augie Fackler <raf@durin42.com>
date Wed, 15 Oct 2014 15:13:43 -0400
parents 3232f92360d4
children c63a09b6b337
files mercurial/posix.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/posix.py	Mon Oct 13 11:46:04 2014 +0200
+++ b/mercurial/posix.py	Wed Oct 15 15:13:43 2014 -0400
@@ -156,9 +156,12 @@
     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: