sshrepo: move mkstemp() out of the try block, we don't use the exception
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Sat, 07 Nov 2009 13:25:25 +0100
changeset 9742 0c84afa1d622
parent 9741 245689e7f869
child 9743 bae76e97f91a
sshrepo: move mkstemp() out of the try block, we don't use the exception simpler fix for 3b6f18851d87
mercurial/sshserver.py
--- a/mercurial/sshserver.py	Sat Nov 07 03:22:03 2009 +0100
+++ b/mercurial/sshserver.py	Sat Nov 07 13:25:25 2009 +0100
@@ -181,11 +181,9 @@
         self.respond('')
 
         # write bundle data to temporary file because it can be big
-        tempname = fp = None
+        fd, tempname = tempfile.mkstemp(prefix='hg-unbundle-')
+        fp = os.fdopen(fd, 'wb+')
         try:
-            fd, tempname = tempfile.mkstemp(prefix='hg-unbundle-')
-            fp = os.fdopen(fd, 'wb+')
-
             count = int(self.fin.readline())
             while count:
                 fp.write(self.fin.read(count))
@@ -212,10 +210,8 @@
                     self.lock.release()
                     self.lock = None
         finally:
-            if fp is not None:
-                fp.close()
-            if tempname is not None:
-                os.unlink(tempname)
+            fp.close()
+            os.unlink(tempname)
 
     def do_stream_out(self):
         try: