This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: suggesting option to raise exception if process exits nonzero in `with subprocess.Popen(...):`
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, gregory.p.smith, nlevitt
Priority: normal Keywords:

Created on 2019-06-06 22:16 by nlevitt, last changed 2022-04-11 14:59 by admin.

Messages (5)
msg344880 - (view) Author: Noah (nlevitt) Date: 2019-06-06 22:16
Suggesting option to raise exception if process exits nonzero in `with subprocess.Popen(...):`

with subprocess.Popen('/bin/false'):
    pass

I made the mistake of assuming this construct would raise an exception (CalledProcessError). It would be nice if there were a way to do that.
msg344882 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-06-06 22:25
I think Popen() is just about as complex as anyone wants it to be. Is there something about .run() or .check_call() that keeps you from using them?
msg344883 - (view) Author: Noah (nlevitt) Date: 2019-06-06 22:32
Yes, I'm piping a large amount of data to/from a fairly long-running subprocess.
msg344886 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-06-06 23:17
I figured as much (but didn't want to lead the witness!).

I'm not completely opposed to this. I think the best thing to do is to bring up the proposal on python-ideas, and point here.
msg345257 - (view) Author: Noah (nlevitt) Date: 2019-06-11 18:03
I subscribed and emailed python-ideas@python.org but it still hasn't passed moderation I guess, hmm
History
Date User Action Args
2022-04-11 14:59:16adminsetgithub: 81365
2019-06-11 18:03:12nlevittsetmessages: + msg345257
2019-06-07 01:24:14xtreaksetnosy: + gregory.p.smith
2019-06-06 23:17:14eric.smithsetmessages: + msg344886
2019-06-06 22:32:17nlevittsetmessages: + msg344883
2019-06-06 22:25:51eric.smithsetnosy: + eric.smith

messages: + msg344882
versions: + Python 3.9
2019-06-06 22:16:29nlevittcreate