Skip to content

Commit 73bc4eb

Browse files
authored
fix: subprocess doesn't allow Path on windows, 3.7 (#7932)
1 parent 3f2469a commit 73bc4eb

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/poetry/utils/env.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ def get_python_version(
544544
if executable:
545545
python_patch = decode(
546546
subprocess.check_output(
547-
[executable, "-c", GET_PYTHON_VERSION_ONELINER],
547+
[str(executable), "-c", GET_PYTHON_VERSION_ONELINER],
548548
).strip()
549549
)
550550

@@ -579,7 +579,7 @@ def activate(self, python: str) -> Env:
579579
try:
580580
python_version_string = decode(
581581
subprocess.check_output(
582-
[python_path, "-c", GET_PYTHON_VERSION_ONELINER],
582+
[str(python_path), "-c", GET_PYTHON_VERSION_ONELINER],
583583
)
584584
)
585585
except CalledProcessError as e:
@@ -906,7 +906,7 @@ def create_venv(
906906
if executable:
907907
python_patch = decode(
908908
subprocess.check_output(
909-
[executable, "-c", GET_PYTHON_VERSION_ONELINER],
909+
[str(executable), "-c", GET_PYTHON_VERSION_ONELINER],
910910
).strip()
911911
)
912912
python_minor = ".".join(python_patch.split(".")[:2])
@@ -954,7 +954,7 @@ def create_venv(
954954
try:
955955
python_patch = decode(
956956
subprocess.check_output(
957-
[python, "-c", GET_PYTHON_VERSION_ONELINER],
957+
[str(python), "-c", GET_PYTHON_VERSION_ONELINER],
958958
stderr=subprocess.STDOUT,
959959
).strip()
960960
)

tests/utils/test_env.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ def check_output_wrapper(
192192
) -> Callable[[list[str], Any, Any], str]:
193193
def check_output(cmd: list[str], *args: Any, **kwargs: Any) -> str:
194194
# cmd is a list, like ["python", "-c", "do stuff"]
195+
assert all(isinstance(arg, str) for arg in cmd)
195196
python_cmd = cmd[2]
196197
if "sys.version_info[:3]" in python_cmd:
197198
return version.text

0 commit comments

Comments
 (0)