diff --git a/src/rez/cli/_complete_util.py b/src/rez/cli/_complete_util.py index c33637232..9f2ba7d6b 100644 --- a/src/rez/cli/_complete_util.py +++ b/src/rez/cli/_complete_util.py @@ -2,7 +2,7 @@ import os.path from fnmatch import fnmatch from rez.vendor.argcomplete import CompletionFinder, default_validator, \ - sys_encoding, split_line, debug + sys_encoding, split_line, debug, USING_PYTHON2 class RezCompletionFinder(CompletionFinder): @@ -12,9 +12,12 @@ def __init__(self, parser, comp_line, comp_point): self.exclude = None self.validator = default_validator self.wordbreaks = " \t\"'@><=;|&(:" # TODO: might need to be configurable/OS specific - - comp_point = len(comp_line[:comp_point].decode(sys_encoding)) - comp_line = comp_line.decode(sys_encoding) + + if USING_PYTHON2: + comp_line = comp_line.decode(sys_encoding) + comp_point = len(comp_line[:comp_point].decode(sys_encoding)) + else: + comp_point = len(comp_line.encode(sys_encoding)[:comp_point].decode(sys_encoding)) cword_prequote, cword_prefix, cword_suffix, comp_words, \ first_colon_pos = split_line(comp_line, comp_point) diff --git a/src/rez/cli/complete.py b/src/rez/cli/complete.py index ed62354ee..90b369da3 100644 --- a/src/rez/cli/complete.py +++ b/src/rez/cli/complete.py @@ -96,6 +96,7 @@ def _pop_arg(l, p): comp_line=comp_line, comp_point=comp_point) words = completer.completions + words = [w.decode() if hasattr(w, 'decode') else w for w in words] print(' '.join(words))