1515import typing as t
1616
1717from . import exc
18- from ._compat import LooseVersion , console_to_str , str_from_console
18+ from ._compat import LooseVersion
1919
2020if t .TYPE_CHECKING :
2121 from collections .abc import Callable
@@ -226,7 +226,7 @@ def __init__(self, *args: t.Any) -> None:
226226
227227 cmd = [tmux_bin ]
228228 cmd += args # add the command arguments to cmd
229- cmd = [str_from_console (c ) for c in cmd ]
229+ cmd = [str (c ) for c in cmd ]
230230
231231 self .cmd = cmd
232232
@@ -235,6 +235,8 @@ def __init__(self, *args: t.Any) -> None:
235235 cmd ,
236236 stdout = subprocess .PIPE ,
237237 stderr = subprocess .PIPE ,
238+ text = True ,
239+ errors = "backslashreplace" ,
238240 )
239241 stdout , stderr = self .process .communicate ()
240242 returncode = self .process .returncode
@@ -244,14 +246,12 @@ def __init__(self, *args: t.Any) -> None:
244246
245247 self .returncode = returncode
246248
247- stdout_str = console_to_str (stdout )
248- stdout_split = stdout_str .split ("\n " )
249+ stdout_split = stdout .split ("\n " )
249250 # remove trailing newlines from stdout
250251 while stdout_split and stdout_split [- 1 ] == "" :
251252 stdout_split .pop ()
252253
253- stderr_str = console_to_str (stderr )
254- stderr_split = stderr_str .split ("\n " )
254+ stderr_split = stderr .split ("\n " )
255255 self .stderr = list (filter (None , stderr_split )) # filter empty values
256256
257257 if "has-session" in cmd and len (self .stderr ) and not stdout_split :
0 commit comments