Make usage of open safer by setting binary mode and closing fds
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/git_refs.py b/git_refs.py
index 2476091..ac8ed0c 100644
--- a/git_refs.py
+++ b/git_refs.py
@@ -101,7 +101,7 @@
def _ReadPackedRefs(self):
path = os.path.join(self._gitdir, 'packed-refs')
try:
- fd = open(path, 'r')
+ fd = open(path, 'rb')
mtime = os.path.getmtime(path)
except IOError:
return
@@ -138,7 +138,7 @@
def _ReadLoose1(self, path, name):
try:
- fd = open(path, 'r')
+ fd = open(path, 'rb')
mtime = os.path.getmtime(path)
except OSError:
return