Rev 85: It didn't really seem safe to open the file in raw mode in http://bazaar.launchpad.net/~meliae-dev/meliae/trunk

John Arbash Meinel john at arbash-meinel.com
Fri Sep 11 18:52:51 BST 2009


At http://bazaar.launchpad.net/~meliae-dev/meliae/trunk

------------------------------------------------------------
revno: 85
revision-id: john at arbash-meinel.com-20090911175235-5k1cqyq61s18i0ix
parent: john at arbash-meinel.com-20090911174920-wgmza4klttnti2se
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: trunk
timestamp: Fri 2009-09-11 12:52:35 -0500
message:
  It didn't really seem safe to open the file in raw mode
  to pass it into a Gzip stream.
-------------- next part --------------
=== modified file 'meliae/files.py'
--- a/meliae/files.py	2009-09-11 17:49:20 +0000
+++ b/meliae/files.py	2009-09-11 17:52:35 +0000
@@ -31,7 +31,7 @@
     
     :return: An iterator of lines, and a cleanup function.
     """
-    source = open(filename, 'r')
+    source = open(filename, 'rb')
     gzip_source = gzip.GzipFile(mode='rb', fileobj=source)
     try:
         line = gzip_source.readline()
@@ -42,6 +42,8 @@
         source.seek(0)
         return source, None
     else:
+        # We don't need these anymore, so close them out in case the rest of
+        # the code raises an exception.
         gzip_source.close()
         source.close()
         # a gzip file



More information about the bazaar-commits mailing list