瀏覽代碼

Don't error when creating GitFiles with the default mode.

Dave Borowitz 14 年之前
父節點
當前提交
29cc33dadd
共有 3 個文件被更改,包括 8 次插入1 次删除
  1. 2 0
      NEWS
  2. 1 1
      dulwich/file.py
  3. 5 0
      dulwich/tests/test_file.py

+ 2 - 0
NEWS

@@ -4,6 +4,8 @@
 
   * HTTP server correctly handles empty CONTENT_LENGTH. (Dave Borowitz)
 
+  * Don't error when creating GitFiles with the default mode. (Dave Borowitz)
+
  FEATURES
 
   * Use slots for core objects to save up on memory. (Jelmer Vernooij)

+ 1 - 1
dulwich/file.py

@@ -60,7 +60,7 @@ def fancy_rename(oldname, newname):
     os.remove(tmpfile)
 
 
-def GitFile(filename, mode='r', bufsize=-1):
+def GitFile(filename, mode='rb', bufsize=-1):
     """Create a file object that obeys the git file locking protocol.
 
     :return: a builtin file object or a _GitFile object

+ 5 - 0
dulwich/tests/test_file.py

@@ -119,6 +119,11 @@ class GitFileTests(TestCase):
         self.assertEquals('contents', f.read())
         f.close()
 
+    def test_default_mode(self):
+        f = GitFile(self.path('foo'))
+        self.assertEquals('foo contents', f.read())
+        f.close()
+
     def test_write(self):
         foo = self.path('foo')
         foo_lock = '%s.lock' % foo