https://bz.mercurial-scm.org/show_bug.cgi?id=6065
Bug ID: 6065 Summary: hglib.clone raises exception due to string encoding Product: Mercurial Version: 2.6.1 Hardware: PC OS: Windows Status: UNCONFIRMED Severity: bug Priority: wish Component: hglib Assignee: bugzi...@mercurial-scm.org Reporter: she...@zaxasoft.com CC: mercurial-devel@mercurial-scm.org OS: Windows 10 64 Python: 3.7.0 HgLib: 2.6.1 Overview: Cannot execute a simple clone due to the binary encoding of the strings in the util.py functions. Binary encoded strings cause an exception. Steps To Reproduce: hglib.clone("http://from.anywhere/repo", "/to/anywhere/") Actual Results: TypeError: a bytes-like object is required, not 'str' At: needquote = (" " in arg) or ("\t" in arg) or not arg in subprocess.py Excepted Results: A cloned repo at the required path. Build Date & Hardware: Windows 10, HgLib 2.6.1, Python 3.7.0, encoding utf-8 Work Around: I was able to work around the issue in util.py in popen by checking each arg to see if it is a string, if not I decode it back to a string and pass it onto subprocess.popen: def __fix_str(string): if isinstance(string, six.text_type): return string else: return string.decode() def popen(args, env=None): environ = None if env: environ = dict(os.environ) environ.update(env) args_adj = list(map(lambda x: __fix_str(x), args)) return subprocess.Popen(args_adj, stdin=subprocess.PIPE, stdout=subprocess.PIPE,stderr=subprocess.PIPE, close_fds=close_fds, startupinfo=startupinfo, env=environ) This obviously adds the dependency on the "six" library. I have no clue how it would behave on Linux or other platforms, but it works for windows. -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel