[Python-3000-checkins] r55791 - python/branches/py3k-struni/Modules/_fileio.c

walter.doerwald python-3000-checkins at python.org
Wed Jun 6 18:55:40 CEST 2007


Author: walter.doerwald
Date: Wed Jun  6 18:55:38 2007
New Revision: 55791

Modified:
   python/branches/py3k-struni/Modules/_fileio.c
Log:
Use O_APPEND flag instead of seeking, when append
mode is specified.


Modified: python/branches/py3k-struni/Modules/_fileio.c
==============================================================================
--- python/branches/py3k-struni/Modules/_fileio.c	(original)
+++ python/branches/py3k-struni/Modules/_fileio.c	Wed Jun  6 18:55:38 2007
@@ -230,6 +230,11 @@
 	flags |= O_BINARY;
 #endif
 
+#ifdef O_APPEND
+	if (append)
+		flags |= O_APPEND;
+#endif
+
 	if (fd >= 0) {
 		self->fd = fd;
 	}
@@ -242,18 +247,6 @@
 			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;


More information about the Python-3000-checkins mailing list