From 8a386225fd9ff3d2ee94bf96154921bcc67b6a24 Mon Sep 17 00:00:00 2001 From: Adam Waldenberg Date: Mon, 17 Jun 2013 07:47:47 +0200 Subject: [PATCH] Added "ignore" parameter to unicode_escape decodings (Fixes issue 4). --- gitinspector/blame.py | 3 +-- gitinspector/changes.py | 3 +-- gitinspector/metrics.py | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/gitinspector/blame.py b/gitinspector/blame.py index b35430e..84984da 100644 --- a/gitinspector/blame.py +++ b/gitinspector/blame.py @@ -21,7 +21,6 @@ from __future__ import print_function from __future__ import unicode_literals from outputable import Outputable from changes import FileDiff -import codecs import comment import filtering import format @@ -92,7 +91,7 @@ class Blame: lines = ls_tree_r.readlines() for i, row in enumerate(lines): - row = codecs.getdecoder("unicode_escape")(row.strip())[0] + row = row.strip().decode("unicode_escape", "ignore") row = row.encode("latin-1", "replace") row = row.decode("utf-8", "replace").strip("\"").strip("'").strip() diff --git a/gitinspector/changes.py b/gitinspector/changes.py index 6f1d1cf..397ba20 100644 --- a/gitinspector/changes.py +++ b/gitinspector/changes.py @@ -20,7 +20,6 @@ from __future__ import print_function from __future__ import unicode_literals from outputable import Outputable -import codecs import extensions import filtering import interval @@ -98,7 +97,7 @@ class Changes: lines = git_log_r.readlines() for i in lines: - j = codecs.getdecoder("unicode_escape")(i.strip())[0] + j = i.strip().decode("unicode_escape", "ignore") j = j.encode("latin-1", "replace") j = j.decode("utf-8", "replace") diff --git a/gitinspector/metrics.py b/gitinspector/metrics.py index ea86fe2..0940dfc 100644 --- a/gitinspector/metrics.py +++ b/gitinspector/metrics.py @@ -18,9 +18,9 @@ # along with gitinspector. If not, see . from __future__ import print_function +from __future__ import unicode_literals from outputable import Outputable from changes import FileDiff -import codecs import comment import filtering import interval @@ -37,7 +37,7 @@ class MetricsLogic: stdout=subprocess.PIPE).stdout for i in ls_tree_r.readlines(): - i = codecs.getdecoder("unicode_escape")(i.strip())[0] + i = i.strip().decode("unicode_escape", "ignore") i = i.encode("latin-1", "replace") i = i.decode("utf-8", "replace").strip("\"").strip("'").strip()