Issue 35246: asyncio.create_subprocess_exec doesn't accept pathlib.Path like subprocess does (original) (raw)

Created on 2018-11-14 13:50 by lilydjwg, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13628 merged lilydjwg,2019-05-28 15:27
Messages (5)
msg329907 - (view) Author: lilydjwg (lilydjwg) * Date: 2018-11-14 13:50
When I pass pathlib.Path to asyncio.create_subprocess_exec I get: TypeError: program arguments must be a bytes or text string, not PosixPath It's not so good when subprocess accepts this kind of arguments without issues. So can you add support for this?
msg343701 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-05-27 23:15
All we need is `program = os.fspath(program)` in base_events.py subprocess_exec() method. Is anybody volunteered to make a patch (with test and docs update, sure)?
msg343729 - (view) Author: lilydjwg (lilydjwg) * Date: 2019-05-28 04:38
> All we need is `program = os.fspath(program)` in base_events.py subprocess_exec() method. I don't think so. The arguments could be `pathlib.Path` too. We can update the `isinstance(arg, (str, bytes))` check so the args pass on to `subprocess.Popen`. It will work in the POSIX part but there is an issue (, ) in Windows part: subprocess.list2cmdline doesn't accept pathlib.Path.
msg343771 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-05-28 12:46
Aha, I see. You are right. Let's drop checks for cmd/program/args types but left to subprocess do these checks. This approach avoiding complex checking/converting logic in asyncio itself and reduces code duplication.
msg343864 - (view) Author: miss-islington (miss-islington) Date: 2019-05-29 06:51
New changeset 744c08a9c75a1a53b7a6521fcee3e7c513919ff9 by Miss Islington (bot) (依云) in branch 'master': bpo-35246: fix support for path-like args in asyncio subprocess (GH-13628) https://github.com/python/cpython/commit/744c08a9c75a1a53b7a6521fcee3e7c513919ff9
History
Date User Action Args
2022-04-11 14:59:08 admin set github: 79427
2019-05-29 06:51:26 asvetlov set status: open -> closedresolution: fixedstage: patch review -> resolved
2019-05-29 06:51:05 miss-islington set nosy: + miss-islingtonmessages: +
2019-05-28 15:27:13 lilydjwg set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest13527>
2019-05-28 12:46:04 asvetlov set messages: +
2019-05-28 04:38:16 lilydjwg set messages: +
2019-05-27 23:15:59 asvetlov set versions: + Python 3.8, - Python 3.7
2019-05-27 23:15:13 asvetlov set messages: +
2018-11-14 13:50:49 lilydjwg create