From 3211ae9dbfc6aadd2dd1d7d0f9f3af37ead19383 Mon Sep 17 00:00:00 2001 From: jmcgill298 Date: Wed, 21 Apr 2021 16:35:27 -0400 Subject: Revert compiling GitCommand shell messages --- git/compat.py | 4 ++-- git/exc.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/git/compat.py b/git/compat.py index a0aea1ac..c9b83ba4 100644 --- a/git/compat.py +++ b/git/compat.py @@ -18,7 +18,7 @@ from gitdb.utils.encoding import ( # typing -------------------------------------------------------------------- -from typing import Any, AnyStr, Dict, Optional, Type +from typing import IO, Any, AnyStr, Dict, Optional, Type, Union from git.types import TBD # --------------------------------------------------------------------------- @@ -30,7 +30,7 @@ is_darwin = (os.name == 'darwin') defenc = sys.getfilesystemencoding() -def safe_decode(s: Optional[AnyStr]) -> Optional[str]: +def safe_decode(s: Union[IO[str], AnyStr, None]) -> Optional[str]: """Safely decodes a binary string to unicode""" if isinstance(s, str): return s diff --git a/git/exc.py b/git/exc.py index c066e5e2..358e7ae4 100644 --- a/git/exc.py +++ b/git/exc.py @@ -65,10 +65,12 @@ class CommandError(GitError): status = "'%s'" % s if isinstance(status, str) else s self._cmd = safe_decode(command[0]) - self._cmdline = ' '.join(str(safe_decode(i)) for i in command) + self._cmdline = ' '.join(safe_decode(i) for i in command) self._cause = status and " due to: %s" % status or "!" - self.stdout = stdout and "\n stdout: '%s'" % safe_decode(str(stdout)) or '' - self.stderr = stderr and "\n stderr: '%s'" % safe_decode(str(stderr)) or '' + stdout_decode = safe_decode(stdout) + stderr_decode = safe_decode(stderr) + self.stdout = stdout_decode and "\n stdout: '%s'" % stdout_decode or '' + self.stderr = stderr_decode and "\n stderr: '%s'" % stderr_decode or '' def __str__(self) -> str: return (self._msg + "\n cmdline: %s%s%s") % ( -- cgit v1.2.1