Christian Heimes added the comment: Guido van Rossum wrote: > I think find_module() should return a file descriptor (fd), not a > FILE*, but most of the rest of the code should call fdopen() on that > fd. Only call_find_module() should use the fd to turn it into a Python > file object. Then the amount of change should be pretty minimal.
K, I understand. > I recommend changing the name of the API used to turn a fd into file > object while we're at it; that's one of the few guidelines we have for > C API changes. Is PyFile_FromFd and PyFile_FromFdEx fine with you or do you prefer a different name like PyFile_FromFD and PyFile_FromFDEx or PyFile_FromFileDescriptor? I've another question. The os.tmpfile method is using tmpfile() which returns a file pointer. Do I have to dup its file number and explictely close the file pointer as shown below or is a simple fileno() enough? I haven't found sample code how to use a file descriptor after the file pointer is closed. static PyObject * posix_tmpfile(PyObject *self, PyObject *noargs) { FILE *fp; int fd; fp = tmpfile(); if (fp == NULL) return posix_error(); fd = dup(fileno(fp)); if (fd == -1) return posix_error(); fclose(fp); return PyFile_FromFD(fd, "<tmpfile>", "w+b"); } __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1267> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com