diff options
author | Walter Dörwald <walter@livinglogic.de> | 2007-06-06 16:55:38 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2007-06-06 16:55:38 (GMT) |
commit | 0e41148c4bdb3b1af157a9bf55df4bc27474f1e8 (patch) | |
tree | b73f744a73e6648838c5202d7bba8161a46c2062 /Modules | |
parent | 5b1284d0b757f28d97fb21d487b4fe19a858c88f (diff) | |
download | cpython-0e41148c4bdb3b1af157a9bf55df4bc27474f1e8.zip cpython-0e41148c4bdb3b1af157a9bf55df4bc27474f1e8.tar.gz cpython-0e41148c4bdb3b1af157a9bf55df4bc27474f1e8.tar.bz2 |
Use O_APPEND flag instead of seeking, when append
mode is specified.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_fileio.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/Modules/_fileio.c b/Modules/_fileio.c index 364748a..660402f 100644 --- a/Modules/_fileio.c +++ b/Modules/_fileio.c @@ -230,6 +230,11 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) flags |= O_BINARY; #endif +#ifdef O_APPEND + if (append) + flags |= O_APPEND; +#endif + if (fd >= 0) { self->fd = fd; } @@ -242,18 +247,6 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); goto error; } - if (append) { - int result; - Py_BEGIN_ALLOW_THREADS - errno = 0; - result = lseek(self->fd, 0, SEEK_END); - Py_END_ALLOW_THREADS - if (result < 0) { - close(self->fd); - PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); - goto error; - } - } } goto done; |