Author: thomas.heller
Date: Wed Jul 11 14:45:46 2007
New Revision: 56264

Modified:
   python/branches/py3k-struni/Modules/_fileio.c
   python/branches/py3k-struni/PC/config.c
   python/branches/py3k-struni/PCbuild/pythoncore.vcproj
Log:
See SF# 1751801: Windows: Add the _fileio builtin module, and undefine
HAVE_FTRUNCATE because ftruncate does not exist on Windows.


Modified: python/branches/py3k-struni/Modules/_fileio.c
==============================================================================
--- python/branches/py3k-struni/Modules/_fileio.c       (original)
+++ python/branches/py3k-struni/Modules/_fileio.c       Wed Jul 11 14:45:46 2007
@@ -22,7 +22,7 @@
 
 #ifdef MS_WINDOWS
 /* can simulate truncate with Win32 API functions; see file_truncate */
-#define HAVE_FTRUNCATE
+/* #define HAVE_FTRUNCATE */
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #endif
@@ -581,6 +581,7 @@
        return portable_lseek(self->fd, NULL, 1);
 }
 
+#ifdef HAVE_FTRUNCATE
 static PyObject *
 fileio_truncate(PyFileIOObject *self, PyObject *args)
 {
@@ -629,6 +630,7 @@
 
        return posobj;
 }
+#endif
 
 static char *
 mode_string(PyFileIOObject *self)
@@ -711,10 +713,12 @@
 "\n"
 "Note that not all file objects are seekable.");
 
+#ifdef HAVE_FTRUNCATE
 PyDoc_STRVAR(truncate_doc,
 "truncate([size: int]) -> None.         Truncate the file to at most size 
bytes.\n"
 "\n"
 "Size defaults to the current file position, as returned by tell().");
+#endif
 
 PyDoc_STRVAR(tell_doc,
 "tell() -> int.         Current file position");
@@ -747,7 +751,9 @@
        {"write",    (PyCFunction)fileio_write,    METH_VARARGS, write_doc},
        {"seek",     (PyCFunction)fileio_seek,     METH_VARARGS, seek_doc},
        {"tell",     (PyCFunction)fileio_tell,     METH_VARARGS, tell_doc},
+#ifdef HAVE_FTRUNCATE
        {"truncate", (PyCFunction)fileio_truncate, METH_VARARGS, truncate_doc},
+#endif
        {"close",    (PyCFunction)fileio_close,    METH_NOARGS,  close_doc},
        {"seekable", (PyCFunction)fileio_seekable, METH_NOARGS,  seekable_doc},
        {"readable", (PyCFunction)fileio_readable, METH_NOARGS,  readable_doc},

Modified: python/branches/py3k-struni/PC/config.c
==============================================================================
--- python/branches/py3k-struni/PC/config.c     (original)
+++ python/branches/py3k-struni/PC/config.c     Wed Jul 11 14:45:46 2007
@@ -59,6 +59,7 @@
 extern void init_lsprof(void);
 extern void init_ast(void);
 extern void init_types(void);
+extern void init_fileio(void);
 
 /* tools/freeze/makeconfig.py marker for additional "extern" */
 /* -- ADDMODULE MARKER 1 -- */
@@ -145,6 +146,7 @@
         {"sys", NULL},
         
         {"_types", init_types},
+        {"_fileio", init_fileio},
 
         /* Sentinel */
         {0, 0}

Modified: python/branches/py3k-struni/PCbuild/pythoncore.vcproj
==============================================================================
--- python/branches/py3k-struni/PCbuild/pythoncore.vcproj       (original)
+++ python/branches/py3k-struni/PCbuild/pythoncore.vcproj       Wed Jul 11 
14:45:46 2007
@@ -371,6 +371,9 @@
                        RelativePath="..\Modules\_csv.c">
                </File>
                <File
+                       RelativePath="..\Modules\_fileio.c">
+               </File>
+               <File
                        RelativePath="..\Modules\_functoolsmodule.c">
                </File>
                <File
_______________________________________________
Python-3000-checkins mailing list
Python-3000-checkins@python.org
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to