Skip to content
Myr

Merge branch '7.x'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parents 97de2c9, 1784558 · Browse files · 4 files+26 added−16 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+26 added−16 removed

  • tests:+0 added−1 removed
  • other:+26 added−15 removed

4 files+26 added−16 removed

modified:docs/options.rst+1 added-1 removed
384 unmodified lines
385Choices should be unique after considering the effects of386``case_sensitive`` and any specified token normalization function.387388.. versionchanged:: 7.1389 The resulting value from an option will always be on the of the389 The resulting value from an option will always be one of the390 originally passed choices regardless of ``case_sensitive``.391392.. _option-prompting:393
459 unmodified lines
modified:src/click/_termui_impl.py+13 added-14 removed
4 unmodified lines
5"""6import contextlib7import math8import os9import shlex9import sys10import time1112from ._compat import _default_text_stdout
337 unmodified lines
350351 fd, filename = tempfile.mkstemp()352 os.close(fd)353 try:355 if hasattr(os, "system") and os.system(f"more {shlex.quote(filename)}") == 0:354 if hasattr(os, "system") and os.system(f'more "{filename}"') == 0:355 return _pipepager(generator, "more", color)356 return _nullpager(stdout, generator, color)357 finally:358 os.unlink(filename)
60 unmodified lines
419 encoding = get_best_encoding(sys.stdout)420 with open_stream(filename, "wb")[0] as f:421 f.write(text.encode(encoding))422 try:424 os.system(f"{shlex.quote(cmd)} {shlex.quote(filename)}")423 os.system(f'{cmd} "{filename}"')424 finally:425 os.unlink(filename)426427
35 unmodified lines
463 environ.update(self.env)464 else:465 environ = None466 try:468 c = subprocess.Popen(469 f"{shlex.quote(editor)} {shlex.quote(filename)}",470 env=environ,471 shell=True,472 )467 c = subprocess.Popen(f'{editor} "{filename}"', env=environ, shell=True)468 exit_code = c.wait()469 if exit_code != 0:470 raise ClickException(f"{editor}: Editing failed!")471 except OSError as e:
64 unmodified lines
536 finally:537 null.close()538 elif WIN:539 if locate:545 url = _unquote_file(url)546 args = f"explorer /select,{shlex.quote(url)}"540 url = _unquote_file(url.replace('"', ""))541 args = f'explorer /select,"{url}"'542 else:548 args = f"start {'/WAIT' if wait else ''} \"\" {shlex.quote(url)}"543 url = url.replace('"', "")544 wait = "/WAIT" if wait else ""545 args = f'start {wait} "" "{url}"'546 return os.system(args)547 elif CYGWIN:548 if locate:552 url = _unquote_file(url)553 args = f"cygstart {shlex.quote(os.path.dirname(url))}"549 url = os.path.dirname(_unquote_file(url).replace('"', ""))550 args = f'cygstart "{url}"'551 else:555 args = f"cygstart {'-w' if wait else ''} {shlex.quote(url)}"552 url = url.replace('"', "")553 wait = "-w" if wait else ""554 args = f'cygstart {wait} "{url}"'555 return os.system(args)556557 try:558 if locate:
109 unmodified lines
modified:tests/test_imports.py-1 removed
44 unmodified lines
45 "errno",46 "fcntl",47 "datetime",48 "pipes",49 "shlex",49}5051if WIN:52 ALLOWED_IMPORTS.update(["ctypes", "ctypes.wintypes", "msvcrt", "time", "zlib"])
14 unmodified lines
modified:CHANGES.rst+12 added
12 unmodified lines
13- Add an optional parameter to ``ProgressBar.update`` to set the14 ``current_item``. :issue:`1226`, :pr:`1332`151617Version 7.1.218-------------1920Released 2020-04-272122- Revert applying shell quoting to commands for ``echo_with_pager``23 and ``edit``. This was intended to allows spaces in commands, but24 caused issues if the string was actually a command and arguments, or25 on Windows. Instead, the string must be quoted manually as it should26 appear on the command line. :issue:`1514`272829Version 7.1.130-------------3132Released 2020-03-09
619 unmodified lines