[issue31961] subprocess._execute_child doesn't accept a single PathLike argument for args

Roy Williams report at bugs.python.org
Mon Nov 6 12:27:25 EST 2017


New submission from Roy Williams <rwilliams at lyft.com>:

Repro:

```python
from pathlib import Path
import subprocess

subprocess.run([Path('/bin/ls')])  # Works Fine
subprocess.run(Path('/bin/ls'))  # Fails
```

The problem seems to originate from here:
https://github.com/python/cpython/blob/master/Lib/subprocess.py#L1237-L1240

This file auspiciously avoids importing pathlib, which I'm guessing is somewhat intentional?  Would the correct fix be to check for the existence of a `__fspath__` attribute as per https://www.python.org/dev/peps/pep-0519/ ?

----------
components: Library (Lib)
messages: 305663
nosy: Roy Williams
priority: normal
severity: normal
status: open
title: subprocess._execute_child doesn't accept a single PathLike argument for args
versions: Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31961>
_______________________________________


More information about the Python-bugs-list mailing list