Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libtmux/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,9 @@ def reraise(tp, value, tb=None):


number_types = integer_types + (float,)

def str_from_console(s):
try:
return text_type(s)
except UnicodeDecodeError:
return text_type(s, encoding='utf_8')
4 changes: 2 additions & 2 deletions libtmux/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from distutils.version import LooseVersion

from . import exc
from ._compat import console_to_str
from ._compat import console_to_str, str_from_console

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -196,7 +196,7 @@ def __init__(self, *args, **kwargs):

cmd = [tmux_bin]
cmd += args # add the command arguments to cmd
cmd = [str(c) for c in cmd]
cmd = [str_from_console(c) for c in cmd]

self.cmd = cmd

Expand Down
4 changes: 4 additions & 0 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ def test_tmux_cmd_raises_on_not_found():
tmux_cmd('-V')


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


@pytest.mark.parametrize(
"session_name,raises,exc_msg_regex",
[
Expand Down