Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
python: Use Python 3.8 shlex.join function.
Anders Kaseorg098a5145999b
diff --git a/puppet/zulip/files/postgresql/pg_backup_and_purge b/puppet/zulip/files/postgresql/pg_backup_and_purgeindex 9af5b7b4328..c3b4f8857cd 100755--- a/puppet/zulip/files/postgresql/pg_backup_and_purge+++ b/puppet/zulip/files/postgresql/pg_backup_and_purge@@ -18,7 +18,7 @@ logger = logging.getLogger(__name__)def run(args: List[str], dry_run: bool = False) -> str:if dry_run:- print("Would have run: " + " ".join(map(shlex.quote, args)))+ print(f"Would have run: {shlex.join(args)}")return ""return subprocess.check_output(args, stdin=subprocess.DEVNULL, text=True)diff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.pyindex e9ac1046bb7..b825cfd93c5 100755--- a/scripts/lib/zulip_tools.py+++ b/scripts/lib/zulip_tools.py@@ -227,19 +227,14 @@ def release_deployment_lock() -> None:def run(args: Sequence[str], **kwargs: Any) -> None:# Output what we're doing in the `set -x` style- print("+ {}".format(" ".join(map(shlex.quote, args))), flush=True)+ print(f"+ {shlex.join(args)}", flush=True)try:subprocess.check_call(args, **kwargs)except subprocess.CalledProcessError:print()print(- WHITEONRED- + "Error running a subcommand of {}: {}".format(- sys.argv[0],- " ".join(map(shlex.quote, args)),- )- + ENDC+ WHITEONRED + f"Error running a subcommand of {sys.argv[0]}: {shlex.join(args)}" + ENDC)print(WHITEONRED + "Actual error output for the subcommand is just above this." + ENDC)print()@@ -258,7 +253,7 @@ def log_management_command(cmd: Sequence[str], log_path: str) -> None:logger.addHandler(file_handler)logger.setLevel(logging.INFO)- logger.info("Ran %s", " ".join(map(shlex.quote, cmd)))+ logger.info("Ran %s", shlex.join(cmd))def get_environment() -> str:@@ -567,7 +562,7 @@ def get_config_file() -> configparser.RawConfigParser:def get_deploy_options(config_file: configparser.RawConfigParser) -> List[str]:- return shlex.split(get_config(config_file, "deployment", "deploy_options", "").strip())+ return shlex.split(get_config(config_file, "deployment", "deploy_options", ""))def run_psql_as_postgres(@@ -575,20 +570,7 @@ def run_psql_as_postgres(sql_query: str,) -> None:dbname = get_config(config_file, "postgresql", "database_name", "zulip")- subcmd = " ".join(- map(- shlex.quote,- [- "psql",- "-v",- "ON_ERROR_STOP=1",- "-d",- dbname,- "-c",- sql_query,- ],- )- )+ subcmd = shlex.join(["psql", "-v", "ON_ERROR_STOP=1", "-d", dbname, "-c", sql_query])subprocess.check_call(["su", "postgres", "-c", subcmd])diff --git a/tools/diagnose b/tools/diagnoseindex e992db50a21..1b05167c381 100755--- a/tools/diagnose+++ b/tools/diagnose@@ -25,7 +25,7 @@ def run(check_func: Callable[[], bool]) -> None:def run_command(args: List[str]) -> None:- print(" ".join(map(shlex.quote, args)))+ print(shlex.join(args))subprocess.check_call(args)diff --git a/tools/review b/tools/reviewindex 820c0e37d6d..d00c5049b09 100755--- a/tools/review+++ b/tools/review@@ -12,7 +12,7 @@ def exit(message: str) -> None:def run(command: List[str]) -> None:- print("\n>>> " + " ".join(map(shlex.quote, command)))+ print(f"\n>>> {shlex.join(command)}")subprocess.check_call(command)diff --git a/tools/test-js-with-puppeteer b/tools/test-js-with-puppeteerindex 46b2f7cb55e..1aae323df1f 100755--- a/tools/test-js-with-puppeteer+++ b/tools/test-js-with-puppeteer@@ -73,7 +73,7 @@ def run_single_test(test_file: str, test_number: int, total_tests: int) -> int:]test_name = os.path.basename(test_file)- cmd_str = " ".join(map(shlex.quote, cmd))+ cmd_str = shlex.join(cmd)print(f"\n\n===================== ({test_number}/{total_tests}) {test_name} =====================\nRunning {cmd_str}\n\n",flush=True,diff --git a/zerver/openapi/markdown_extension.py b/zerver/openapi/markdown_extension.pyindex f270719785d..d120e9f217c 100644--- a/zerver/openapi/markdown_extension.py+++ b/zerver/openapi/markdown_extension.py@@ -300,7 +300,7 @@ def generate_curl_example(example_endpoint = endpoint.format_map(format_dict)curl_first_line_parts = ["curl", *curl_method_arguments(example_endpoint, method, api_url)]- lines.append(" ".join(map(shlex.quote, curl_first_line_parts)))+ lines.append(shlex.join(curl_first_line_parts))insecure_operations = ["/dev_fetch_api_key:post", "/fetch_api_key:post"]if operation_security is None:diff --git a/zerver/views/zephyr.py b/zerver/views/zephyr.pyindex d8917d3270e..a434a7ee936 100644--- a/zerver/views/zephyr.py+++ b/zerver/views/zephyr.py@@ -67,9 +67,7 @@ def webathena_kerberos_login(api_key,base64.b64encode(ccache).decode(),]- subprocess.check_call(- ["ssh", settings.PERSONAL_ZMIRROR_SERVER, "--", " ".join(map(shlex.quote, command))]- )+ subprocess.check_call(["ssh", settings.PERSONAL_ZMIRROR_SERVER, "--", shlex.join(command)])except subprocess.CalledProcessError:logging.exception("Error updating the user's ccache", stack_info=True)raise JsonableError(_("We were unable to set up mirroring for you"))