comparison mercurial/pycompat.py @ 43096:813aa8cc55d4

patchbomb: use procutil.shellquote() instead of shlex to escape email address This basically backs out 2cc453284d5c, and inserts procutil.shellquote() instead. I don't care about Windows compatibility here, but shlex.quote() can't handle byte strings on Python 3.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 02 Oct 2019 07:35:22 +0900
parents 127cc1f72e70
children c95b2f40db7c
comparison
equal deleted inserted replaced
43095:fb41ea2ea076 43096:813aa8cc55d4
335 Python 3 compatibility as shelx.split() don't accept bytes on Python 3. 335 Python 3 compatibility as shelx.split() don't accept bytes on Python 3.
336 """ 336 """
337 ret = shlex.split(s.decode('latin-1'), comments, posix) 337 ret = shlex.split(s.decode('latin-1'), comments, posix)
338 return [a.encode('latin-1') for a in ret] 338 return [a.encode('latin-1') for a in ret]
339 339
340 shlexquote = shlex.quote
341 340
342 else: 341 else:
343 import cStringIO 342 import cStringIO
344 import pipes
345 343
346 xrange = xrange 344 xrange = xrange
347 unicode = unicode 345 unicode = unicode
348 bytechr = chr 346 bytechr = chr
349 byterepr = repr 347 byterepr = repr
406 if getattr(sys, 'argv', None) is not None: 404 if getattr(sys, 'argv', None) is not None:
407 sysargv = sys.argv 405 sysargv = sys.argv
408 sysplatform = sys.platform 406 sysplatform = sys.platform
409 sysexecutable = sys.executable 407 sysexecutable = sys.executable
410 shlexsplit = shlex.split 408 shlexsplit = shlex.split
411 shlexquote = pipes.quote
412 bytesio = cStringIO.StringIO 409 bytesio = cStringIO.StringIO
413 stringio = bytesio 410 stringio = bytesio
414 maplist = map 411 maplist = map
415 rangelist = range 412 rangelist = range
416 ziplist = zip 413 ziplist = zip