From da30e73ed1338b0dd892f2448c7178df0eaadf7a Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Fri, 4 Sep 2020 00:03:00 -0400 Subject: [PATCH] fix git --HG-- branch : pmacs2 --- buffer/data.py | 5 ++++- method/git.py | 2 +- util.py | 13 +++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/buffer/data.py b/buffer/data.py index 7ac0d8a..0a3ca2f 100644 --- a/buffer/data.py +++ b/buffer/data.py @@ -5,7 +5,10 @@ class DataBuffer(Buffer): def __init__(self, name, data): Buffer.__init__(self) self._name = name - self.lines = data.split("\n") + if type(data) == bytes: + self.lines = data.decode('UTF-8').split('\n') + else: + self.lines = data.split("\n") def name(self): return self._name def close(self): diff --git a/method/git.py b/method/git.py index 4736c9e..a6ef6ef 100644 --- a/method/git.py +++ b/method/git.py @@ -186,7 +186,7 @@ class GitBlame(VcBlame): if not m: raise VcException("couldn't parse %r" % line) groups = m.groups() - fields = [s.decode('UTF-8') for s in groups[:-1]] + fields = list(groups[:-1]) del fields[1] if fields[1] == 'Not Committed Yet': fields[1] = '' diff --git a/util.py b/util.py index 2935d31..e865700 100644 --- a/util.py +++ b/util.py @@ -137,12 +137,13 @@ except: dict.__repr__(self)) def decode(s): - for coding in ('utf-8', 'latin-1'): - try: - return s.decode(coding) - except: - pass - return s.decode('ascii', 'replace') + return s + #for coding in ('utf-8', 'latin-1'): + # try: + # return s.decode(coding) + # except: + # pass + #return s.decode('ascii', 'replace') def communicate(cmd, stdin=None, stderr=True, shell=False): if stderr: