Don't error when creating GitFiles with the default mode.
authorDave Borowitz <dborowitz@google.com>
Mon, 26 Jul 2010 17:43:17 +0000 (19:43 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 26 Jul 2010 17:43:17 +0000 (19:43 +0200)
NEWS
dulwich/file.py
dulwich/tests/test_file.py

diff --git a/NEWS b/NEWS
index 5068f2de64b9ff2c3b80f63e92ff259dca1fc82e..52744be7c1806b7ee8f399ab46a4f27f1a2f7fc8 100644 (file)
--- a/NEWS
+++ b/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)
index dd0fbb03a6fcdea3a33da99f86c3db4a938aff64..7228fc29e2210fa734d75d078e827529dcb882b1 100644 (file)
@@ -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
index 8deb987cf88c6e76acca8cc98c929a92e6e3ab14..f154a571252192d657d8b3e44309ecb259deaa1e 100644 (file)
@@ -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