Przeglądaj źródła

Fix some python3 encoding issues

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

Change-Id: I0f03ecf9ed1a78e3b2f15f9469deb9aaab698657
Chirayu Desai 12 lat temu
rodzic
commit
0eb35cbe50
5 zmienionych plików z 6 dodań i 6 usunięć
  1. 1 1
      git_command.py
  2. 2 2
      git_config.py
  3. 1 1
      git_refs.py
  4. 1 1
      project.py
  5. 1 1
      subcmds/sync.py

+ 1 - 1
git_command.py

@@ -86,7 +86,7 @@ class _GitCall(object):
     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,

+ 2 - 2
git_config.py

@@ -304,8 +304,8 @@ class GitConfig(object):
     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:

+ 1 - 1
git_refs.py

@@ -100,7 +100,7 @@ class GitRefs(object):
   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

+ 1 - 1
project.py

@@ -1165,7 +1165,7 @@ class Project(object):
     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

+ 1 - 1
subcmds/sync.py

@@ -761,7 +761,7 @@ class _FetchTimes(object):
   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