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.

Author vapier
Recipients vapier
Date 2020-03-05.02:10:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1583374218.17.0.443069658502.issue39857@roundup.psfhosted.org>
In-reply-to
Content
a common idiom i run into is wanting to add/set one or two env vars when running a command via subprocess.  the only thing the API allows currently is inherting the current environment, or specifying the complete environment.  this means a lot of copying & pasting of the pattern:

 env = os.environ.copy()
 env['FOO'] = ...
 env['BAR'] = ...
 subprocess.run(..., env=env, ...)

it would nice if we could simply express this incremental behavior:

 subprocess.run(..., extra_env={'FOO': ..., 'BAR': ...}, ...)

then the subprocess API would take care of copying & merging.

 if extra_env:
   assert env is None
   env = os.environ.copy()
   env.update(extra_env)

this is akin to subprocess.run's capture_output shortcut.

it's unclear to me whether this would be in both subprocess.Popen & subprocess.run, or only subprocess.run.  it seems like subprocess.Popen elides convenience APIs.
History
Date User Action Args
2020-03-05 02:10:18vapiersetrecipients: + vapier
2020-03-05 02:10:18vapiersetmessageid: <1583374218.17.0.443069658502.issue39857@roundup.psfhosted.org>
2020-03-05 02:10:18vapierlinkissue39857 messages
2020-03-05 02:10:17vapiercreate