Browse Source

Close ref file after writing to it.

Jelmer Vernooij 16 years ago
parent
commit
aa596748f9
1 changed files with 5 additions and 1 deletions
  1. 5 1
      dulwich/repo.py

+ 5 - 1
dulwich/repo.py

@@ -206,7 +206,11 @@ class Repo(object):
 
     def set_ref(self, name, value):
         file = os.path.join(self.controldir(), name)
-        open(file, 'w').write(value+"\n")
+        f = open(file, 'w')
+        try:
+            f.write(value+"\n")
+        finally:
+            f.close()
 
     def remove_ref(self, name):
         file = os.path.join(self.controldir(), name)