
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2018-10-03 18:50 byaecant, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| subprocess_run_bug.py | aecant,2018-10-03 18:50 | Minimal working example | ||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 11727 | merged | remi.lapeyre,2019-02-01 22:49 | |
| PR 11727 | merged | remi.lapeyre,2019-02-01 22:49 | |
| PR 11727 | merged | remi.lapeyre,2019-02-01 22:49 | |
| PR 13916 | merged | miss-islington,2019-06-08 14:56 | |
| PR 13917 | merged | miss-islington,2019-06-08 14:56 | |
| Messages (11) | |||
|---|---|---|---|
| msg327002 -(view) | Author: Alessandro (aecant)* | Date: 2018-10-03 18:50 | |
If input and stdin parameters are passed as keyword arguments to subprocess.run, an exception is thrown even if input and stdin are both None.The exception is ValueError: stdin and input arguments may not both be used.I attach a minimal working example of the bug | |||
| msg327003 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2018-10-03 19:12 | |
What is wrong with this? | |||
| msg327004 -(view) | Author: Alessandro (aecant)* | Date: 2018-10-03 19:22 | |
subprocess.run('ls', input=b'', stdin=None) # this is okkwargs = {'input': b'', 'stdin': None}subprocess.run('ls', **kwargs) # this throws exceptionThe two calls should have the same behaviour, but one throws exception and the other doesn't. I think the exception shouldn't be thrown, because stdin is None. | |||
| msg327008 -(view) | Author: Josh Rosenberg (josh.r)*![]() | Date: 2018-10-03 19:49 | |
I just tried: subprocess.run('ls', input=b'', stdin=None)and I got the same ValueError as for passing using kwargs. Where did you get the idea subprocess.run('ls', input=b'', stdin=None) worked? | |||
| msg327009 -(view) | Author: Josh Rosenberg (josh.r)*![]() | Date: 2018-10-03 19:52 | |
The actual code receives input by name, but stdin is received in **kwargs. The test is just: if input is not None: if 'stdin' in kwargs: raise ValueError(...) kwargs['stdin'] = PIPEPerhaps just change `if 'stdin' in kwargs:` to: if kwargs.get('stdin') is not None:so it obeys the documented API (that says stdin defaults to None, and therefore passing stdin=None explicitly should be equivalent to not passing it at all)? | |||
| msg327011 -(view) | Author: Alessandro (aecant)* | Date: 2018-10-03 20:06 | |
> and I got the same ValueError as for passing using kwargs. Where did you get the idea subprocess.run('ls', input=b'', stdin=None) worked?Sorry, the example was wrong. Both calls have the same behaviour.> so it obeys the documented API (that says stdin defaults to None, and therefore passing stdin=None explicitly should be equivalent to not passing it at all)?The actual problem is this. The fix you propose works for me. | |||
| msg334728 -(view) | Author: Rémi Lapeyre (remi.lapeyre)* | Date: 2019-02-01 22:50 | |
I opened a PR with @josh.r proposed change. | |||
| msg345042 -(view) | Author: Gregory P. Smith (gregory.p.smith)*![]() | Date: 2019-06-08 14:56 | |
New changeset8cc605acdda5aff250ab4c9b524a7560f90ca9f3 by Gregory P. Smith (Rémi Lapeyre) in branch 'master':bpo-34886: Fix subprocess.run handling of exclusive arguments (GH-11727)https://github.com/python/cpython/commit/8cc605acdda5aff250ab4c9b524a7560f90ca9f3 | |||
| msg345046 -(view) | Author: miss-islington (miss-islington) | Date: 2019-06-08 15:15 | |
New changeset6324ac1293b2cf71559869b88f89f510f9a62a8e by Miss Islington (bot) in branch '3.8':bpo-34886: Fix subprocess.run handling of exclusive arguments (GH-11727)https://github.com/python/cpython/commit/6324ac1293b2cf71559869b88f89f510f9a62a8e | |||
| msg345049 -(view) | Author: miss-islington (miss-islington) | Date: 2019-06-08 15:24 | |
New changeset10b4fd98142edef6ab7b034e10ae5c9551043999 by Miss Islington (bot) in branch '3.7':bpo-34886: Fix subprocess.run handling of exclusive arguments (GH-11727)https://github.com/python/cpython/commit/10b4fd98142edef6ab7b034e10ae5c9551043999 | |||
| msg345179 -(view) | Author: Gregory P. Smith (gregory.p.smith)*![]() | Date: 2019-06-11 04:55 | |
thanks! | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:06 | admin | set | github: 79067 |
| 2019-06-11 04:55:33 | gregory.p.smith | set | status: open -> closed assignee:gregory.p.smith versions: + Python 3.8, Python 3.9 keywords:patch,patch,patch resolution: fixed messages: +msg345179 stage: patch review -> commit review |
| 2019-06-08 15:24:13 | miss-islington | set | messages: +msg345049 |
| 2019-06-08 15:15:10 | miss-islington | set | nosy: +miss-islington messages: +msg345046 |
| 2019-06-08 14:56:42 | miss-islington | set | pull_requests: +pull_request13790 |
| 2019-06-08 14:56:35 | miss-islington | set | pull_requests: +pull_request13789 |
| 2019-06-08 14:56:27 | gregory.p.smith | set | nosy: +gregory.p.smith messages: +msg345042 |
| 2019-02-01 22:50:04 | remi.lapeyre | set | nosy: +remi.lapeyre messages: +msg334728 |
| 2019-02-01 22:49:14 | remi.lapeyre | set | keywords: +patch stage: patch review pull_requests: +pull_request11613 |
| 2019-02-01 22:49:07 | remi.lapeyre | set | keywords: +patch stage: (no value) pull_requests: +pull_request11612 |
| 2019-02-01 22:49:00 | remi.lapeyre | set | keywords: +patch stage: (no value) pull_requests: +pull_request11611 |
| 2018-10-03 20:06:56 | aecant | set | messages: +msg327011 |
| 2018-10-03 19:52:55 | josh.r | set | messages: +msg327009 |
| 2018-10-03 19:49:29 | josh.r | set | nosy: +josh.r messages: +msg327008 |
| 2018-10-03 19:22:57 | aecant | set | messages: +msg327004 |
| 2018-10-03 19:12:16 | serhiy.storchaka | set | nosy: +serhiy.storchaka messages: +msg327003 |
| 2018-10-03 18:50:38 | aecant | create | |