Fix some python3 encoding issues

* Add .decode('utf-8') where needed
* Add 'b' to `open` where needed, and remove where unnecessary

Change-Id: I0f03ecf9ed1a78e3b2f15f9469deb9aaab698657
This commit is contained in:
Chirayu Desai 2013-11-19 18:46:29 +05:30 committed by Chirayu Desai
parent ce201a5311
commit 0eb35cbe50
5 changed files with 6 additions and 6 deletions

View File

@ -86,7 +86,7 @@ class _GitCall(object):
global _git_version global _git_version
if _git_version is None: if _git_version is None:
ver_str = git.version() ver_str = git.version().decode('utf-8')
if ver_str.startswith('git version '): if ver_str.startswith('git version '):
_git_version = tuple( _git_version = tuple(
map(int, map(int,

View File

@ -304,7 +304,7 @@ class GitConfig(object):
d = self._do('--null', '--list') d = self._do('--null', '--list')
if d is None: if d is None:
return c return c
for line in d.rstrip('\0').split('\0'): # pylint: disable=W1401 for line in d.decode('utf-8').rstrip('\0').split('\0'): # pylint: disable=W1401
# Backslash is not anomalous # Backslash is not anomalous
if '\n' in line: if '\n' in line:
key, val = line.split('\n', 1) key, val = line.split('\n', 1)

View File

@ -100,7 +100,7 @@ class GitRefs(object):
def _ReadPackedRefs(self): def _ReadPackedRefs(self):
path = os.path.join(self._gitdir, 'packed-refs') path = os.path.join(self._gitdir, 'packed-refs')
try: try:
fd = open(path, 'rb') fd = open(path, 'r')
mtime = os.path.getmtime(path) mtime = os.path.getmtime(path)
except IOError: except IOError:
return return

View File

@ -1165,7 +1165,7 @@ class Project(object):
last_mine = None last_mine = None
cnt_mine = 0 cnt_mine = 0
for commit in local_changes: 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: if committer_email == self.UserEmail:
last_mine = commit_id last_mine = commit_id
cnt_mine += 1 cnt_mine += 1

View File

@ -761,7 +761,7 @@ class _FetchTimes(object):
def _Load(self): def _Load(self):
if self._times is None: if self._times is None:
try: try:
f = open(self._path) f = open(self._path, 'rb')
except IOError: except IOError:
self._times = {} self._times = {}
return self._times return self._times