[New-bugs-announce] [issue41649] Can't pass Path like objects to subprocess api's on Windows.
Jani Mikkonen
report at bugs.python.org
Thu Aug 27 10:25:18 EDT 2020
New submission from Jani Mikkonen <jani.mikkonen at gmail.com>:
Following code:
```
from pathlib import Path
import os
import subprocess
dir_name = os.environ.get("WORKSPACE", None) or "."
output_directory = Path(dir_name) / "results"
res = subprocess.run(["mytest", "--output", output_directory])
```
Works on macos and linux but on windows, this causes "TypeError: argument of type 'WindowsPath' is not iterable" at https://github.com/python/cpython/blob/master/Lib/subprocess.py#L568
(line is different, depending on the actual python release but i guess that gives the idea where it is)..
Quick test to check if i can do `" " in Path("/tmp")` on posix platforms shows the same exception but with PosixPath type but apparently this sort of check does not happen on those platforms as the example code works fine there.
It would be nice to be able to pass path objects to subprocess api calls also in windows without explicitly casting the object into string before passing it as argument.
----------
components: Windows
messages: 375993
nosy: paul.moore, rasjani, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Can't pass Path like objects to subprocess api's on Windows.
type: behavior
versions: Python 3.10, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41649>
_______________________________________
More information about the New-bugs-announce
mailing list