diff options
author | jmcgill298 <jacob@networktocode.com> | 2021-04-21 16:35:27 -0400 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2021-04-22 09:36:14 +0800 |
commit | 3211ae9dbfc6aadd2dd1d7d0f9f3af37ead19383 (patch) | |
tree | 4f98f02828a2c88eb345e279e6c6b4d06d4daccd | |
parent | d0fb22b4f5f94da44075d8c43da24b344ae3f0da (diff) | |
download | gitpython-3211ae9dbfc6aadd2dd1d7d0f9f3af37ead19383.tar.gz |
Revert compiling GitCommand shell messages
-rw-r--r-- | git/compat.py | 4 | ||||
-rw-r--r-- | 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 @@ -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") % ( |