summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-10-22 00:09:51 (GMT)
committerGuido van Rossum <guido@python.org>2007-10-22 00:09:51 (GMT)
commit40d20bcf1fccfe8af2393f1aec88ba18e38d0bc1 (patch)
tree0d6616333b9c3cb004b659751fe9baa4bac67ad2 /Modules
parentc2954e5273520031d3debfac8c668b9e611303b3 (diff)
downloadcpython-40d20bcf1fccfe8af2393f1aec88ba18e38d0bc1.zip
cpython-40d20bcf1fccfe8af2393f1aec88ba18e38d0bc1.tar.gz
cpython-40d20bcf1fccfe8af2393f1aec88ba18e38d0bc1.tar.bz2
Issue 1267, continued.
Additional patch by Christian Heimes to deal more cleanly with the FILE* vs file-descriptor issues. I cleaned up his code a bit, and moved the lseek() call into import.c.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 647ea3e..e0de961 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5386,11 +5386,18 @@ static PyObject *
posix_tmpfile(PyObject *self, PyObject *noargs)
{
FILE *fp;
+ int fd;
fp = tmpfile();
if (fp == NULL)
return posix_error();
- return PyFile_FromFile(fp, "<tmpfile>", "w+b", fclose);
+ fd = fileno(fp);
+ if (fd != -1)
+ fd = dup(fd);
+ fclose(fp);
+ if (fd == -1)
+ return posix_error();
+ return PyFile_FromFd(fd, "<tmpfile>", "w+b", -1, NULL, NULL);
}
#endif