Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/posix.py @ 31498:492c64afc54c
py3: make the regular expression bytes to prevent TypeError
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Fri, 17 Mar 2017 05:10:58 +0530 |
parents | 13d94304c8da |
children | d96d010be4fa |
comparison
equal
deleted
inserted
replaced
31497:8122cc5cb543 | 31498:492c64afc54c |
---|---|
406 def shellquote(s): | 406 def shellquote(s): |
407 if pycompat.sysplatform == 'OpenVMS': | 407 if pycompat.sysplatform == 'OpenVMS': |
408 return '"%s"' % s | 408 return '"%s"' % s |
409 global _needsshellquote | 409 global _needsshellquote |
410 if _needsshellquote is None: | 410 if _needsshellquote is None: |
411 _needsshellquote = re.compile(r'[^a-zA-Z0-9._/+-]').search | 411 _needsshellquote = re.compile(br'[^a-zA-Z0-9._/+-]').search |
412 if s and not _needsshellquote(s): | 412 if s and not _needsshellquote(s): |
413 # "s" shouldn't have to be quoted | 413 # "s" shouldn't have to be quoted |
414 return s | 414 return s |
415 else: | 415 else: |
416 return "'%s'" % s.replace("'", "'\\''") | 416 return "'%s'" % s.replace("'", "'\\''") |