Skip to content
Myr

Merge pull request #2030 from taranlu-houzz/remove_fast_exit

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

Remove fast exit

authored by David Lord · committed by GitHub · parents 6aff09e, 36e7f19 · Browse files · 3 files+3 added−15 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+3 added−15 removed

  • tests:+0 added−3 removed
  • other:+3 added−12 removed

3 files+3 added−15 removed

modified:src/click/core.py+1 added-12 removed
44 unmodified lines
45F = t.TypeVar("F", bound=t.Callable[..., t.Any])46V = t.TypeVar("V")474849def _fast_exit(code: int) -> "te.NoReturn":50 """Low-level exit that skips Python's cleanup but speeds up exit by51 about 10ms for things like shell completion.5253 :param code: Exit code.54 """55 sys.stdout.flush()56 sys.stderr.flush()57 os._exit(code)585949def _complete_visible_commands(50 ctx: "Context", incomplete: str51) -> t.Iterator[t.Tuple[str, "Command"]]:52 """List all the subcommands of a group that start with the
1065 unmodified lines
11181119 from .shell_completion import shell_complete11201121 rv = shell_complete(self, ctx_args, prog_name, complete_var, instruction)1133 _fast_exit(rv)1122 sys.exit(rv)11231124 def __call__(self, *args: t.Any, **kwargs: t.Any) -> t.Any:1125 """Alias for :meth:`main`."""1126 return self.main(*args, **kwargs)
1821 unmodified lines
modified:tests/test_shell_completion.py-3 removed
1import sys21import pytest23from click.core import Argument4from click.core import Command
257 unmodified lines
262263264@pytest.fixture()265def _patch_for_completion(monkeypatch):268 monkeypatch.setattr("click.core._fast_exit", sys.exit)266 monkeypatch.setattr(267 "click.shell_completion.BashComplete._check_version", lambda self: True268 )269
50 unmodified lines
modified:CHANGES.rst+2 added
12 unmodified lines
13- Fix shell completion for arguments that start with a forward slash14 such as absolute file paths. :issue:`1929`15- ``Path`` type with ``resolve_path=True`` resolves relative symlinks16 to be relative to the containing directory. :issue:`1921`17- Completion does not skip Python's resource cleanup when exiting,18 avoiding some unexpected warning output. :issue:`1738, 2017`192021Version 8.0.122-------------
889 unmodified lines