diff options
author | Kostis Anagnostopoulos <ankostis@gmail.com> | 2016-09-27 17:23:53 +0200 |
---|---|---|
committer | Kostis Anagnostopoulos <ankostis@gmail.com> | 2016-09-28 03:35:38 +0200 |
commit | df2fb548040c8313f4bb98870788604bc973fa18 (patch) | |
tree | 4c11a309cfc6821b5ecd847592a451820c303463 /git/exc.py | |
parent | 25a2ebfa684f7ef37a9298c5ded2fc5af190cb42 (diff) | |
download | gitpython-df2fb548040c8313f4bb98870788604bc973fa18.tar.gz |
PY2, #519: FIX GitCommandError.tostr() encoding issue
+ PY3 means "PY3 or later" (TODO: fix also for *gitdb* project).
Diffstat (limited to 'git/exc.py')
-rw-r--r-- | git/exc.py | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -6,8 +6,7 @@ """ Module containing all exceptions thrown througout the git package, """ from gitdb.exc import * # NOQA - -from git.compat import defenc +from git.compat import UnicodeMixin, safe_decode class InvalidGitRepositoryError(Exception): @@ -28,7 +27,7 @@ class GitCommandNotFound(Exception): pass -class GitCommandError(Exception): +class GitCommandError(UnicodeMixin, Exception): """ Thrown if execution of the git command fails with non-zero status code. """ def __init__(self, command, status, stderr=None, stdout=None): @@ -37,13 +36,13 @@ class GitCommandError(Exception): self.status = status self.command = command - def __str__(self): - ret = "'%s' returned with exit code %i" % \ - (' '.join(str(i) for i in self.command), self.status) + def __unicode__(self): + ret = u"'%s' returned with exit code %s" % \ + (u' '.join(safe_decode(i) for i in self.command), self.status) if self.stderr: - ret += "\nstderr: '%s'" % self.stderr.decode(defenc) + ret += u"\nstderr: '%s'" % safe_decode(self.stderr) if self.stdout: - ret += "\nstdout: '%s'" % self.stdout.decode(defenc) + ret += u"\nstdout: '%s'" % safe_decode(self.stdout) return ret |