@@ -361,16 +361,17 @@ async def run(cls, *args: t.Any) -> AsyncTmuxCmd:
361
361
msg ,
362
362
)
363
363
364
- # Convert all arguments to strings, accounting for Python 3.7+ strings
365
- cmd : list [str ] = [tmux_bin ] + [str_from_console (a ) for a in args ]
364
+ cmd : list [str ] = [tmux_bin ] + [str (c ) for c in args ]
366
365
367
366
try :
368
367
process : asyncio .subprocess .Process = await asyncio .create_subprocess_exec (
369
368
* cmd ,
370
369
stdout = asyncio .subprocess .PIPE ,
371
370
stderr = asyncio .subprocess .PIPE ,
371
+ text = True ,
372
+ errors = "backslashreplace" ,
372
373
)
373
- raw_stdout , raw_stderr = await process .communicate ()
374
+ stdout , stderr = await process .communicate ()
374
375
returncode : int = (
375
376
process .returncode if process .returncode is not None else - 1
376
377
)
@@ -382,12 +383,14 @@ async def run(cls, *args: t.Any) -> AsyncTmuxCmd:
382
383
msg ,
383
384
) from e
384
385
385
- stdout_str : str = console_to_str (raw_stdout )
386
- stderr_str : str = console_to_str (raw_stderr )
386
+ # Split on newlines and filter empty lines
387
+ stdout_split : list [str ] = stdout .split ("\n " )
388
+ # remove trailing newlines from stdout
389
+ while stdout_split and stdout_split [- 1 ] == "" :
390
+ stdout_split .pop ()
387
391
388
- # Split on newlines, filtering out any trailing empty lines
389
- stdout_split : list [str ] = [line for line in stdout_str .split ("\n " ) if line ]
390
- stderr_split : list [str ] = [line for line in stderr_str .split ("\n " ) if line ]
392
+ stderr_split = stderr .split ("\n " )
393
+ stderr_split = list (filter (None , stderr_split )) # filter empty values
391
394
392
395
# Workaround for tmux "has-session" command behavior
393
396
if "has-session" in cmd and stderr_split and not stdout_split :
0 commit comments