New submission from Jani Mikkonen <jani.mikko...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue41649>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to