summaryrefslogtreecommitdiff
path: root/Objects/fileobject.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
commit2dced8b602df10531cab6cd87da5503c06f14888 (patch)
treebf87d57eb4945b66b672aadfb87c071449391441 /Objects/fileobject.c
parent2673a5723433ff398fed901a8ebebb265031091e (diff)
downloadcpython-git-2dced8b602df10531cab6cd87da5503c06f14888.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 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 9f63814ba1..4e18480b31 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -27,15 +27,15 @@ extern "C" {
PyObject *
PyFile_FromFd(int fd, char *name, char *mode, int buffering, char *encoding,
- char *newline)
+ char *newline, int closefd)
{
PyObject *io, *stream, *nameobj = NULL;
io = PyImport_ImportModule("io");
if (io == NULL)
return NULL;
- stream = PyObject_CallMethod(io, "open", "isiss", fd, mode,
- buffering, encoding, newline);
+ stream = PyObject_CallMethod(io, "open", "isissi", fd, mode,
+ buffering, encoding, newline, closefd);
Py_DECREF(io);
if (stream == NULL)
return NULL;