Fix some python3 encoding issues
* Add .decode('utf-8') where needed
* Add 'b' to `open` where needed, and remove where unnecessary
Change-Id: I0f03ecf9ed1a78e3b2f15f9469deb9aaab698657
diff --git a/git_command.py b/git_command.py
index d347dd6..51f5e3c 100644
--- a/git_command.py
+++ b/git_command.py
@@ -86,7 +86,7 @@
global _git_version
if _git_version is None:
- ver_str = git.version()
+ ver_str = git.version().decode('utf-8')
if ver_str.startswith('git version '):
_git_version = tuple(
map(int,
diff --git a/git_config.py b/git_config.py
index a294a0b..f6093a2 100644
--- a/git_config.py
+++ b/git_config.py
@@ -304,8 +304,8 @@
d = self._do('--null', '--list')
if d is None:
return c
- for line in d.rstrip('\0').split('\0'): # pylint: disable=W1401
- # Backslash is not anomalous
+ for line in d.decode('utf-8').rstrip('\0').split('\0'): # pylint: disable=W1401
+ # Backslash is not anomalous
if '\n' in line:
key, val = line.split('\n', 1)
else:
diff --git a/git_refs.py b/git_refs.py
index 4dd6876..3c26606 100644
--- a/git_refs.py
+++ b/git_refs.py
@@ -100,7 +100,7 @@
def _ReadPackedRefs(self):
path = os.path.join(self._gitdir, 'packed-refs')
try:
- fd = open(path, 'rb')
+ fd = open(path, 'r')
mtime = os.path.getmtime(path)
except IOError:
return
diff --git a/project.py b/project.py
index dec21ab..6631641 100644
--- a/project.py
+++ b/project.py
@@ -1165,7 +1165,7 @@
last_mine = None
cnt_mine = 0
for commit in local_changes:
- commit_id, committer_email = commit.split(' ', 1)
+ commit_id, committer_email = commit.decode('utf-8').split(' ', 1)
if committer_email == self.UserEmail:
last_mine = commit_id
cnt_mine += 1
diff --git a/subcmds/sync.py b/subcmds/sync.py
index e9d52b7..d8aec59 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -761,7 +761,7 @@
def _Load(self):
if self._times is None:
try:
- f = open(self._path)
+ f = open(self._path, 'rb')
except IOError:
self._times = {}
return self._times