Merge pull request #1543 from pallets/revert-shlex-quote
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Revert "Use shlex.quote for quoting shell arguments"
authored by David Lord · committed by GitHub · parents a6b10db, 0d1b8ea · Browse files · 3 files·+9 added−18 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+9 added−18 removed
- tests:+0 added−1 removed
- other:+9 added−17 removed
Provenance
- Commit
25a3cb2- Tree
4b6e31d- Author
David Lord <davidism@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
a6b10db- Parent 2
0d1b8ea
3 files changed+9 added−18 removed
modified:src/click/_compat.py-4 removed
172 unmodified lines173 int_types = (int, long)174 iteritems = lambda x: x.iteritems()175 range_type = xrange176 177- from pipes import quote as shlex_quote178-177 def is_bytes(x):178 return isinstance(x, (buffer, bytearray))179 180 _identifier_re = re.compile(r"^[a-zA-Z_][a-zA-Z0-9_]*$")100 unmodified lines281 range_type = range282 isidentifier = lambda x: x.isidentifier()283 iteritems = lambda x: iter(x.items())284 287- from shlex import quote as shlex_quote288-285 def is_bytes(x):286 return isinstance(x, (bytes, memoryview, bytearray))287 288 def _is_binary_reader(stream, default=False):498 unmodified linesmodified:src/click/_termui_impl.py+9 added-13 removed
15 unmodified lines16 from ._compat import int_types17 from ._compat import isatty18 from ._compat import open_stream19 from ._compat import range_type20-from ._compat import shlex_quote20 from ._compat import strip_ansi21 from ._compat import term_len22 from ._compat import WIN23 from .exceptions import ClickException320 unmodified lines344 345 fd, filename = tempfile.mkstemp()346 os.close(fd)347 try:349- if (350- hasattr(os, "system")351- and os.system("more {}".format(shlex_quote(filename))) == 0352- ):348+ if hasattr(os, "system") and os.system('more "{}"'.format(filename)) == 0:349 return _pipepager(generator, "more", color)350 return _nullpager(stdout, generator, color)351 finally:352 os.unlink(filename)60 unmodified lines413 encoding = get_best_encoding(sys.stdout)414 with open_stream(filename, "wb")[0] as f:415 f.write(text.encode(encoding))416 try:421- os.system("{} {}".format(shlex_quote(cmd), shlex_quote(filename)))417+ os.system('{} "{}"'.format(cmd, filename))418 finally:419 os.unlink(filename)420 421 36 unmodified lines458 else:459 environ = None460 try:461 c = subprocess.Popen(466- "{} {}".format(shlex_quote(editor), shlex_quote(filename)),467- env=environ,468- shell=True,462+ '{} "{}"'.format(editor, filename), env=environ, shell=True,463 )464 exit_code = c.wait()465 if exit_code != 0:466 raise ClickException("{}: Editing failed!".format(editor))62 unmodified lines529 null.close()530 elif WIN:531 if locate:532 url = _unquote_file(url)539- args = "explorer /select,{}".format(shlex_quote(url))533+ args = 'explorer /select,"{}"'.format(_unquote_file(url.replace('"', "")))534 else:541- args = 'start {} "" {}'.format("/WAIT" if wait else "", shlex_quote(url))535+ args = 'start {} "" "{}"'.format(536+ "/WAIT" if wait else "", url.replace('"', "")537+ )538 return os.system(args)539 elif CYGWIN:540 if locate:541 url = _unquote_file(url)546- args = "cygstart {}".format(shlex_quote(os.path.dirname(url)))542+ args = 'cygstart "{}"'.format(os.path.dirname(url).replace('"', ""))543 else:548- args = "cygstart {} {}".format("-w" if wait else "", shlex_quote(url))544+ args = 'cygstart {} "{}"'.format("-w" if wait else "", url.replace('"', ""))545 return os.system(args)546 547 try:548 if locate:109 unmodified linesmodified:tests/test_imports.py-1 removed
47 unmodified lines48 "errno",49 "fcntl",50 "datetime",51 "pipes",52- "shlex",52 }53 54 if WIN:55 ALLOWED_IMPORTS.update(["ctypes", "ctypes.wintypes", "msvcrt", "time", "zlib"])16 unmodified lines