[tor-commits] [bridgedb/master] Fix with combined with os.open; doesn't work on Python2.6.

isis at torproject.org isis at torproject.org
Sun Jan 12 06:06:31 UTC 2014


commit 11d976b50b8983174d9fdf8e6a276b1639cd0b95
Author: Isis Lovecruft <isis at torproject.org>
Date:   Sat Oct 26 13:00:14 2013 +0000

    Fix with combined with os.open; doesn't work on Python2.6.
---
 lib/bridgedb/crypto.py |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/bridgedb/crypto.py b/lib/bridgedb/crypto.py
index ea00733..43b2b79 100644
--- a/lib/bridgedb/crypto.py
+++ b/lib/bridgedb/crypto.py
@@ -44,9 +44,10 @@ def getKey(filename):
     except IOError:
         key = OpenSSL.rand.bytes(32)
         flags = os.O_WRONLY | os.O_TRUNC | os.O_CREAT | getattr(os, "O_BIN", 0)
-        with os.open(filename, flags, 0400) as fd:
-            os.write(fd, key)
-            os.fsync(fd)
+        fd = os.open(filename, flags, 0400)
+        os.write(fd, key)
+        os.fsync(fd)
+        fd.close()
     else:
         key = fh.read()
         fh.close()





More information about the tor-commits mailing list