Skip to content

Commit 27fcca1

Browse files
author
wangweichen
committed
fix codecs.open can't have text and binary mode at once
1 parent d3e1078 commit 27fcca1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

git/refs/symbolic.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def abspath(self):
7676
@classmethod
7777
def _get_packed_refs_path(cls, repo):
7878
try:
79-
commondir = codecs.open(osp.join(repo.git_dir, 'commondir'), 'rt', encoding="utf-8").readlines()[0].strip()
79+
commondir = codecs.open(osp.join(repo.git_dir, 'commondir'), 'r', encoding="utf-8").readlines()[0].strip()
8080
except (OSError, IOError):
8181
commondir = '.'
8282
repodir = osp.join(repo.git_dir, commondir)
@@ -87,7 +87,7 @@ def _iter_packed_refs(cls, repo):
8787
"""Returns an iterator yielding pairs of sha1/path pairs (as bytes) for the corresponding refs.
8888
:note: The packed refs file will be kept open as long as we iterate"""
8989
try:
90-
with codecs.open(cls._get_packed_refs_path(repo), 'rt', encoding="utf-8") as fp:
90+
with codecs.open(cls._get_packed_refs_path(repo), 'r', encoding="utf-8") as fp:
9191
for line in fp:
9292
line = line.strip()
9393
if not line:
@@ -133,7 +133,7 @@ def _get_ref_info_helper(cls, repo, repodir, ref_path):
133133
point to, or None"""
134134
tokens = None
135135
try:
136-
with codecs.open(osp.join(repodir, ref_path), 'rt', encoding="utf-8") as fp:
136+
with codecs.open(osp.join(repodir, ref_path), 'r', encoding="utf-8") as fp:
137137
value = fp.read().rstrip()
138138
# Don't only split on spaces, but on whitespace, which allows to parse lines like
139139
# 60b64ef992065e2600bfef6187a97f92398a9144 branch 'master' of git-server:/path/to/repo
@@ -173,7 +173,7 @@ def _get_ref_info(cls, repo, ref_path):
173173
return cls._get_ref_info_helper(repo, repo.git_dir, ref_path)
174174
except ValueError:
175175
try:
176-
commondir = codecs.open(osp.join(repo.git_dir, 'commondir'), 'rt', encoding="utf-8").readlines()[0].strip()
176+
commondir = codecs.open(osp.join(repo.git_dir, 'commondir'), 'r', encoding="utf-8").readlines()[0].strip()
177177
except (OSError, IOError):
178178
commondir = '.'
179179

0 commit comments

Comments
 (0)