Skip to content

Commit 9097c31

Browse files
mywtony
authored andcommitted
Make more extensive testing and more generic fix
1 parent b8bcada commit 9097c31

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

libtmux/_compat.py

+6
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,9 @@ def reraise(tp, value, tb=None):
9292

9393

9494
number_types = integer_types + (float,)
95+
96+
def str_from_console(s):
97+
try:
98+
return text_type(s)
99+
except UnicodeDecodeError:
100+
return text_type(s, encoding='utf_8')

libtmux/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from distutils.version import LooseVersion
1515

1616
from . import exc
17-
from ._compat import console_to_str, text_type
17+
from ._compat import console_to_str, str_from_console
1818

1919
logger = logging.getLogger(__name__)
2020

@@ -196,7 +196,7 @@ def __init__(self, *args, **kwargs):
196196

197197
cmd = [tmux_bin]
198198
cmd += args # add the command arguments to cmd
199-
cmd = [text_type(c, encoding='utf_8') for c in cmd]
199+
cmd = [str_from_console(c) for c in cmd]
200200

201201
self.cmd = cmd
202202

tests/test_common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def test_tmux_cmd_raises_on_not_found():
164164

165165

166166
def test_tmux_cmd_unicode():
167-
tmux_cmd('has-session', 'юникод')
167+
tmux_cmd('new-window', '-t', 3, '-n', 'юникод', '-F', u'Ελληνικά')
168168

169169

170170
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)