Revert compiling GitCommand shell messages · gitpython-developers/GitPython@8292032

2 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -18,7 +18,7 @@

1818
1919

# typing --------------------------------------------------------------------

2020
21-

from typing import Any, AnyStr, Dict, Optional, Type

21+

from typing import IO, Any, AnyStr, Dict, Optional, Type, Union

2222

from git.types import TBD

2323
2424

# ---------------------------------------------------------------------------

@@ -30,7 +30,7 @@

3030

defenc = sys.getfilesystemencoding()

3131
3232
33-

def safe_decode(s: Optional[AnyStr]) -> Optional[str]:

33+

def safe_decode(s: Union[IO[str], AnyStr, None]) -> Optional[str]:

3434

"""Safely decodes a binary string to unicode"""

3535

if isinstance(s, str):

3636

return s

Original file line numberDiff line numberDiff line change

@@ -65,10 +65,13 @@ def __init__(self, command: Union[List[str], Tuple[str, ...], str],

6565

status = "'%s'" % s if isinstance(status, str) else s

6666
6767

self._cmd = safe_decode(command[0])

68-

self._cmdline = ' '.join(str(safe_decode(i)) for i in command)

68+

command_decode = [safe_decode(i) for i in command]

69+

self._cmdline = ' '.join(safe_decode(i) for i in command_decode)

6970

self._cause = status and " due to: %s" % status or "!"

70-

self.stdout = stdout and "\n stdout: '%s'" % safe_decode(str(stdout)) or ''

71-

self.stderr = stderr and "\n stderr: '%s'" % safe_decode(str(stderr)) or ''

71+

stdout_decode = safe_decode(stdout)

72+

stderr_decode = safe_decode(stderr)

73+

self.stdout = stdout_decode and "\n stdout: '%s'" % stdout_decode or ''

74+

self.stderr = stderr_decode and "\n stderr: '%s'" % stderr_decode or ''

7275
7376

def __str__(self) -> str:

7477

return (self._msg + "\n cmdline: %s%s%s") % (