depot_tools: Run git_common_test in Python 3

Bug: 1009809
Change-Id: Idfcbd26de3420798f092c7fa55a6126d7c389a8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1834317
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/git_hyper_blame.py b/git_hyper_blame.py
index 3e08513..8b0ee30 100755
--- a/git_hyper_blame.py
+++ b/git_hyper_blame.py
@@ -7,6 +7,7 @@
 """
 
 from __future__ import print_function
+from __future__ import unicode_literals
 
 import argparse
 import collections
@@ -94,11 +95,6 @@
     yield BlameLine(commit, context, lineno_then, lineno_now, False)
 
 
-def num_codepoints(s):
-  """Gets the length of a UTF-8 byte string, in Unicode codepoints."""
-  return len(s.decode('utf-8', errors='replace'))
-
-
 def print_table(table, colsep=' ', rowsep='\n', align=None, out=sys.stdout):
   """Print a 2D rectangular array, aligning columns with spaces.
 
@@ -112,10 +108,9 @@
   colwidths = None
   for row in table:
     if colwidths is None:
-      colwidths = [num_codepoints(x) for x in row]
+      colwidths = [len(x) for x in row]
     else:
-      colwidths = [max(colwidths[i], num_codepoints(x))
-                   for i, x in enumerate(row)]
+      colwidths = [max(colwidths[i], len(x)) for i, x in enumerate(row)]
 
   if align is None:  # pragma: no cover
     align = 'l' * len(colwidths)
@@ -123,7 +118,7 @@
   for row in table:
     cells = []
     for i, cell in enumerate(row):
-      padding = ' ' * (colwidths[i] - num_codepoints(cell))
+      padding = ' ' * (colwidths[i] - len(cell))
       if align[i] == 'r':
         cell = padding + cell
       elif i < len(row) - 1:
@@ -279,7 +274,7 @@
   try:
     parsed = cache_blame_from(filename, git_common.hash_one(revision))
   except subprocess2.CalledProcessError as e:
-    err.write(e.stderr)
+    err.write(e.stderr.decode())
     return e.returncode
 
   new_parsed = []
@@ -361,7 +356,7 @@
   try:
     repo_root = git_common.repo_root()
   except subprocess2.CalledProcessError as e:
-    stderr.write(e.stderr)
+    stderr.write(e.stderr.decode())
     return e.returncode
 
   # Make filename relative to the repository root, and cd to the root dir (so