mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
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.
This commit is contained in:
parent
c2954e5273
commit
40d20bcf1f
12 changed files with 94 additions and 64 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue