From 294ee46af4583ac1a2da0e797dc7193e8260a8d5 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Fri, 8 Sep 2023 17:33:23 +0200 Subject: [PATCH] Fix query parameters in `bench_download.py` tool (#7772) URL query parameter construction in the `bench_donwload.py` tool uses `urllib` to properly quote, e.g., complex branch names. # Important Notes Fixes queries with complicated branch names, like `./bench_download.py -v -s stdlib --use-cache true -b develop wip/akirathan/6959-Integer.+-cannot-be-invoked-statically` --- tools/performance/engine-benchmarks/bench_download.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/performance/engine-benchmarks/bench_download.py b/tools/performance/engine-benchmarks/bench_download.py index 3b796de8f2..138dff3b57 100755 --- a/tools/performance/engine-benchmarks/bench_download.py +++ b/tools/performance/engine-benchmarks/bench_download.py @@ -65,6 +65,7 @@ from os import path from typing import List, Dict, Optional, Any, Union, Set from dataclasses import dataclass import xml.etree.ElementTree as ET +from urllib.parse import urlencode if not (sys.version_info.major >= 3 and sys.version_info.minor >= 7): @@ -300,12 +301,11 @@ def _read_json(json_file: str) -> Dict[Any, Any]: async def _invoke_gh_api(endpoint: str, query_params: Dict[str, str] = {}, result_as_text: bool = True) -> Union[Dict[str, Any], bytes]: - query_str_list = [key + "=" + value for key, value in query_params.items()] - query_str = "&".join(query_str_list) + urlencode(query_params) cmd = [ "gh", "api", - f"/repos/enso-org/enso{endpoint}" + ("" if len(query_str) == 0 else "?" + query_str) + f"/repos/enso-org/enso{endpoint}" + "?" + urlencode(query_params) ] logging.info(f"Starting subprocess `{' '.join(cmd)}`") proc = await asyncio.create_subprocess_exec("gh", *cmd[1:],