summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-10-30 17:27:30 +0000
committerGuido van Rossum <guido@python.org>2007-10-30 17:27:30 +0000
commit3d14428ee84888f6723d895314109a6835fabbfc (patch)
tree8434f19f1d4cbbe4aacb9643364c4b5298a7b0dc /Python/pythonrun.c
parentfe01e73d5c49d3d57129ad9f9198795027766f2d (diff)
downloadcpython-3d14428ee84888f6723d895314109a6835fabbfc.tar.gz
Patch 1329 (partial) by Christian Heimes.
Add a closefd flag to open() which can be set to False to prevent closing the file descriptor when close() is called or when the object is destroyed. Useful to ensure that sys.std{in,out,err} keep their file descriptors open when Python is uninitialized. (This was always a feature in 2.x, it just wasn't implemented in 3.0 yet.)
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 330667a219..76da8fb7f7 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -720,7 +720,7 @@ initstdio(void)
/* Set sys.stdin */
if (!(std = PyFile_FromFd(fileno(stdin), "<stdin>", "r", -1,
- NULL, "\n"))) {
+ NULL, "\n", 0))) {
goto error;
}
PySys_SetObject("__stdin__", std);
@@ -729,16 +729,16 @@ initstdio(void)
/* Set sys.stdout */
if (!(std = PyFile_FromFd(fileno(stdout), "<stdout>", "w", -1,
- NULL, "\n"))) {
+ NULL, "\n", 0))) {
goto error;
}
PySys_SetObject("__stdout__", std);
PySys_SetObject("stdout", std);
Py_DECREF(std);
- /* Set sys.stderr */
+ /* Set sys.stderr, replaces the preliminary stderr */
if (!(std = PyFile_FromFd(fileno(stderr), "<stderr>", "w", -1,
- NULL, "\n"))) {
+ NULL, "\n", 0))) {
goto error;
}
PySys_SetObject("__stderr__", std);