From 997128ced47936adabb2f267d2606f8eac253ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Mon, 2 Jan 2023 11:58:01 -0800 Subject: Better message when command parsing on empty input (#2807) --- src/tox/config/loader/str_convert.py | 2 ++ src/tox/tox_env/python/pip/pip_install.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tox/config/loader/str_convert.py b/src/tox/config/loader/str_convert.py index e31c034f..f07545f5 100644 --- a/src/tox/config/loader/str_convert.py +++ b/src/tox/config/loader/str_convert.py @@ -63,6 +63,8 @@ class StrConvert(Convert[str]): pos = splitter.instream.tell() except ValueError: args.append(value[pos:]) + if len(args) == 0: + raise ValueError(f"attempting to parse {value!r} into a command failed") if args[0] != "-" and args[0].startswith("-"): args[0] = args[0][1:] args = ["-"] + args diff --git a/src/tox/tox_env/python/pip/pip_install.py b/src/tox/tox_env/python/pip/pip_install.py index a148ce32..2136e862 100644 --- a/src/tox/tox_env/python/pip/pip_install.py +++ b/src/tox/tox_env/python/pip/pip_install.py @@ -160,7 +160,10 @@ class Pip(Installer[Python]): outcome.assert_success() def build_install_cmd(self, args: Sequence[str]) -> list[str]: - cmd: Command = self._env.conf["install_command"] + try: + cmd: Command = self._env.conf["install_command"] + except ValueError as exc: + raise Fail(f"unable to determine pip install command: {str(exc)}") from exc install_command = cmd.args try: opts_at = install_command.index("{packages}") -- cgit v1.2.1