Issue5870
Created on 2009-04-28 19:24 by MrJean1, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| 5870_v1.patch | rosslagerwall, 2011-01-02 05:19 | Patch + test for issue | review | |
| Messages (9) | |||
|---|---|---|---|
| msg86761 - (view) | Author: Jean Brouwers (MrJean1) | Date: 2009-04-28 19:24 | |
The subprocess module exposes the PIPE and STDOUT constants to be used for the stdin, stdout or stderr keyword arguments. Often, stderr needs to be redirected to /dev/null (on posix). It would nice if another constant was available for that purpose, e.g. subprocess.DEVNULL. Perhaps, that might be as simple as DEVNULL = os.open(os.devnull, os.OS_RDWR) and re-use the same, single file descriptor. |
|||
| msg86771 - (view) | Author: Jean Brouwers (MrJean1) | Date: 2009-04-28 22:06 | |
Typo. That should be ..., os.O_RDWR) |
|||
| msg90444 - (view) | Author: Lucas Prado Melo (lucaspmelo) | Date: 2009-07-12 12:21 | |
-1 on this one. It is not a portable decision (only *nix OSes do have /dev/null). Also, why would we want it as a default constant? The subprocess module would need to open /dev/null every time. Despite that, I can't see how would someone use the redirection of errors to /dev/null through a python script and, at the same time, make it seem not a bad practice at all. |
|||
| msg90446 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2009-07-12 12:53 | |
Lucas, Windows has a /dev/null-like device. I think Jean's suggestion is reasonable, but it should be a special constant instead of creating a file descriptor unconditionnally (that is, the file should only be open if needed). Also, a patch should be provided (with tests :-)). |
|||
| msg125030 - (view) | Author: Ross Lagerwall (rosslagerwall) ![]() |
Date: 2011-01-02 05:19 | |
Here is a fairly simple patch that adds the subprocess.DEVNULL constant. |
|||
| msg125057 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2011-01-02 14:42 | |
Hmm, we don't like these open-for-eternity file descriptors; we had such a thing for os.urandom() but removed it (see #1177468). I'm okay with DEVNULL (or even just NULL) as a shorthand, but it should open (and close) the devnull device each time just as if a normal fd was given. |
|||
| msg125058 - (view) | Author: Ross Lagerwall (rosslagerwall) ![]() |
Date: 2011-01-02 14:50 | |
I think if you look closely at the patch, the fd does not stay open the whole time. It is opened if necessary in _get_handles() with e.g.:
elif stdin == DEVNULL:
p2cread = self._get_devnull()
and then closed in _execute_child() with:
if hasattr(self, '_devnull'):
os.close(self._devnull)
which is executed from __init__(). So I don't think it stays open for eternity :-)
|
|||
| msg125063 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2011-01-02 15:53 | |
Right, sorry then :) |
|||
| msg131146 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2011-03-16 17:36 | |
New changeset eaf93e156dff by Ross Lagerwall in branch 'default': Issue #5870: Add subprocess.DEVNULL constant. http://hg.python.org/cpython/rev/eaf93e156dff |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:48 | admin | set | github: 50120 |
| 2011-03-16 17:38:53 | rosslagerwall | set | status: open -> closed assignee: gregory.p.smith -> rosslagerwall resolution: accepted nosy: georg.brandl, gregory.p.smith, pitrou, giampaolo.rodola, OG7, MrJean1, lucaspmelo, santoso.wijaya, rosslagerwall, socketpair, python-dev stage: needs patch -> resolved |
| 2011-03-16 17:36:56 | python-dev | set | nosy:
+ python-dev messages: + msg131146 |
| 2011-03-05 10:17:43 | santoso.wijaya | set | nosy:
+ santoso.wijaya |
| 2011-03-05 09:29:55 | ned.deily | set | nosy:
+ socketpair |
| 2011-03-05 09:28:55 | ned.deily | link | issue11404 superseder |
| 2011-01-02 15:53:11 | georg.brandl | set | assignee: gregory.p.smith messages:
+ msg125063 |
| 2011-01-02 14:50:30 | rosslagerwall | set | nosy:
georg.brandl, pitrou, giampaolo.rodola, OG7, MrJean1, lucaspmelo, rosslagerwall messages: + msg125058 |
| 2011-01-02 14:42:42 | georg.brandl | set | nosy:
+ georg.brandl messages: + msg125057 |
| 2011-01-02 05:19:19 | rosslagerwall | set | files:
+ 5870_v1.patch versions: + Python 3.3, - Python 2.7 nosy: + rosslagerwall messages: + msg125030 keywords: + patch |
| 2010-10-11 17:51:34 | giampaolo.rodola | set | nosy:
+ giampaolo.rodola |
| 2010-10-07 17:05:50 | amaury.forgeotdarc | set | stage: needs patch |
| 2009-07-12 12:53:12 | pitrou | set | nosy:
+ pitrou messages: + msg90446 |
| 2009-07-12 12:21:56 | lucaspmelo | set | nosy:
+ lucaspmelo messages: + msg90444 |
| 2009-07-09 09:25:26 | OG7 | set | nosy:
+ OG7 |
| 2009-04-28 22:06:31 | MrJean1 | set | messages: + msg86771 |
| 2009-04-28 19:24:02 | MrJean1 | create | |

