From 8ae0c2f3d3c632bb35841cc71cf255a29d0f9ebd Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Tue, 18 Aug 2026 07:25:42 -0400 Subject: [PATCH] fix(codegen): PS5.1-safe quoting for native-exe args in generate-proto probes --- clients/python/generate-proto.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/clients/python/generate-proto.ps1 b/clients/python/generate-proto.ps1 index a98eb29..863a21c 100644 --- a/clients/python/generate-proto.ps1 +++ b/clients/python/generate-proto.ps1 @@ -36,7 +36,11 @@ function Resolve-Python { function Assert-GrpcioToolsVersion { param([string]$Python) - $version = (& $Python -c 'import grpc_tools; from importlib.metadata import version; print(version("grpcio-tools"))').Trim() + # Windows PowerShell 5.1 strips embedded double quotes when passing an argument to a native + # exe (pwsh 7 does not), so a Python literal quoted with " " here would arrive at Python as + # print(version(grpcio-tools)) -> NameError. Use single quotes for the Python string literal + # inside this double-quoted PowerShell string so the quoting survives on both hosts. + $version = (& $Python -c "import grpc_tools; from importlib.metadata import version; print(version('grpcio-tools'))").Trim() if ($version -ne $PinnedGrpcioToolsVersion) { throw "grpcio-tools $version is installed, but regeneration is pinned to $PinnedGrpcioToolsVersion. " + "Install the pin (python -m pip install 'grpcio-tools==$PinnedGrpcioToolsVersion') before regenerating, " +