Update of /cvsroot/pywin32/pywin32/win32/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18841/win32/src
Modified Files:
Tag: py3k
PyWinTypes.h win32file.i
Log Message:
merge datetime changes from trunk (and other misc trunk changes)
Index: PyWinTypes.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v
retrieving revision 1.51.2.9
retrieving revision 1.51.2.10
diff -C2 -d -r1.51.2.9 -r1.51.2.10
*** PyWinTypes.h 8 Jan 2009 03:45:50 -0000 1.51.2.9
--- PyWinTypes.h 27 Jan 2009 07:55:31 -0000 1.51.2.10
***************
*** 494,498 ****
// The NO_PYWINTYPES_TIME define was initially used for CE builds. We now
// use that symbol to mean "do we include our old, crap, custom time object?"
! // This is currently always true on the trunk - but not for long :)
PYWINTYPES_EXPORT PyObject *PyWinObject_FromSYSTEMTIME(const SYSTEMTIME &t);
PYWINTYPES_EXPORT PyObject *PyWinObject_FromFILETIME(const FILETIME &t);
--- 494,520 ----
// The NO_PYWINTYPES_TIME define was initially used for CE builds. We now
// use that symbol to mean "do we include our old, crap, custom time object?"
! // If not defined, we exclusively support datetime objects via the C API.
! // (Note py2.3 doesn't have a C API, so will not currently build with
! // NO_PYWINTYPES_TIME defined.)
! // TODO: If both builtin and datetime objects are enabled, we will enable
! // some transitional period using something like
! // pywintypes.__future_datatime__, but for now this is defined purely at build
! // time.
! #if (PY_VERSION_HEX >= 0x03000000)
! # define NO_PYWINTYPES_TIME
! #endif
!
! // Python 2.3 doesn't have C Api for datetime, so can't have our new funky
! // support.
! #if (PY_VERSION_HEX >= 0x02040000)
! # define PYWIN_HAVE_DATETIME_CAPI
! #endif
!
! // XXX - fixme - ack - we don't yet like *both* defines existing - and for now
! // its only enabled in py3k
! #if (PY_VERSION_HEX < 0x03000000)
! # undef PYWIN_HAVE_DATETIME_CAPI
! #endif
!
PYWINTYPES_EXPORT PyObject *PyWinObject_FromSYSTEMTIME(const SYSTEMTIME &t);
PYWINTYPES_EXPORT PyObject *PyWinObject_FromFILETIME(const FILETIME &t);
Index: win32file.i
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v
retrieving revision 1.93.2.6
retrieving revision 1.93.2.7
diff -C2 -d -r1.93.2.6 -r1.93.2.7
*** win32file.i 3 Jan 2009 23:46:35 -0000 1.93.2.6
--- win32file.i 27 Jan 2009 07:55:31 -0000 1.93.2.7
***************
*** 51,54 ****
--- 51,59 ----
%{
+
+ #ifdef PYWIN_HAVE_DATETIME_CAPI
+ #include "datetime.h" // python's datetime header.
+ #endif
+
// older python version's don't get the PyCObject structure definition
// exposed, and we need it to cleanly zap our handles (see
***************
*** 342,346 ****
// @pyparm <o PyUnicode>|fileName||The filename to delete
-
%{
// @pyswig str/buffer|DeviceIoControl|Sends a control code to a device or file system driver
--- 347,350 ----
***************
*** 669,679 ****
BOOLAPI GetFileTime(
HANDLE handle, // @pyparm <o PyHANDLE>|handle||Handle to the file.
! FILETIME *OUTPUT,
! FILETIME *OUTPUT,
! FILETIME *OUTPUT
);
%{
// @pyswig None|SetFileTime|Sets the date and time that a file was created, last accessed, or last modified.
static PyObject *PySetFileTime (PyObject *self, PyObject *args)
--- 673,693 ----
BOOLAPI GetFileTime(
HANDLE handle, // @pyparm <o PyHANDLE>|handle||Handle to the file.
! FILETIME *OUTPUT, // @pyparm <o PyTime>|creationTime||
! FILETIME *OUTPUT, // @pyparm <o PyTime>|accessTime||
! FILETIME *OUTPUT // @pyparm <o PyTime>|writeTime||
);
%{
+ // Helper for SetFileTime - see comments below.
+ static BOOL PyWinTime_DateTimeCheck(PyObject *ob)
+ {
+ return FALSE
+ #ifdef PYWIN_HAVE_DATETIME_CAPI
+ || (PyDateTimeAPI && PyDateTime_Check(ob))
+ #endif
+ ;
+ }
+
// @pyswig None|SetFileTime|Sets the date and time that a file was created, last accessed, or last modified.
static PyObject *PySetFileTime (PyObject *self, PyObject *args)
***************
*** 701,705 ****
if (!PyWinObject_AsFILETIME(obTimeCreated, &LocalFileTime))
return NULL;
! LocalFileTimeToFileTime(&LocalFileTime, &TimeCreated);
lpTimeCreated= &TimeCreated;
}
--- 715,725 ----
if (!PyWinObject_AsFILETIME(obTimeCreated, &LocalFileTime))
return NULL;
! // This sucks! This code is the only code in pywin32 that
! // blindly converted the result of AsFILETIME to a localtime.
! // That doesn't make sense in a tz-aware datetime world...
! if (PyWinTime_DateTimeCheck(obTimeCreated))
! TimeCreated = LocalFileTime;
! else
! LocalFileTimeToFileTime(&LocalFileTime, &TimeCreated);
lpTimeCreated= &TimeCreated;
}
***************
*** 710,714 ****
if (!PyWinObject_AsFILETIME(obTimeAccessed, &LocalFileTime))
return NULL;
! LocalFileTimeToFileTime(&LocalFileTime, &TimeAccessed);
lpTimeAccessed= &TimeAccessed;
}
--- 730,737 ----
if (!PyWinObject_AsFILETIME(obTimeAccessed, &LocalFileTime))
return NULL;
! if (PyWinTime_DateTimeCheck(obTimeAccessed))
! TimeAccessed = LocalFileTime;
! else
! LocalFileTimeToFileTime(&LocalFileTime, &TimeAccessed);
lpTimeAccessed= &TimeAccessed;
}
***************
*** 719,723 ****
if (!PyWinObject_AsFILETIME(obTimeWritten, &LocalFileTime))
return NULL;
! LocalFileTimeToFileTime(&LocalFileTime, &TimeWritten);
lpTimeWritten= &TimeWritten;
}
--- 742,749 ----
if (!PyWinObject_AsFILETIME(obTimeWritten, &LocalFileTime))
return NULL;
! if (PyWinTime_DateTimeCheck(obTimeWritten))
! TimeWritten = LocalFileTime;
! else
! LocalFileTimeToFileTime(&LocalFileTime, &TimeWritten);
lpTimeWritten= &TimeWritten;
}
***************
*** 1659,1663 ****
DWORD flags, bytes_to_write, bytes_per_send;
OVERLAPPED *pOverlapped;
! int error, rc;
static char *keywords[]={"Socket","File","NumberOfBytesToWrite", "NumberOfBytesPerSend",
--- 1685,1689 ----
DWORD flags, bytes_to_write, bytes_per_send;
OVERLAPPED *pOverlapped;
! int error, rc;
static char *keywords[]={"Socket","File","NumberOfBytesToWrite", "NumberOfBytesPerSend",
***************
*** 1699,1708 ****
if (!PyWinObject_AsReadBuffer(obTail, &tf_buffers.Tail, &tf_buffers.TailLength, TRUE))
return NULL;
!
if (tf_buffers.Head || tf_buffers.Tail)
ptf_buffers = &tf_buffers;
else
ptf_buffers = NULL;
!
rc=0;
Py_BEGIN_ALLOW_THREADS;
--- 1725,1734 ----
if (!PyWinObject_AsReadBuffer(obTail, &tf_buffers.Tail, &tf_buffers.TailLength, TRUE))
return NULL;
!
if (tf_buffers.Head || tf_buffers.Tail)
ptf_buffers = &tf_buffers;
else
ptf_buffers = NULL;
!
rc=0;
Py_BEGIN_ALLOW_THREADS;
***************
*** 1710,1714 ****
rc = WSAGetLastError();
Py_END_ALLOW_THREADS;
!
if (rc == 0 || rc == ERROR_IO_PENDING || rc == WSA_IO_PENDING)
return PyInt_FromLong(rc);
--- 1736,1740 ----
rc = WSAGetLastError();
Py_END_ALLOW_THREADS;
!
if (rc == 0 || rc == ERROR_IO_PENDING || rc == WSA_IO_PENDING)
return PyInt_FromLong(rc);
***************
*** 1735,1739 ****
DWORD buffer_len=0;
int rc, error;
! DWORD sent=0;
static char *keywords[]={"s","name","Overlapped","SendBuffer", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO|O:ConnectEx", keywords,
--- 1761,1765 ----
DWORD buffer_len=0;
int rc, error;
! DWORD sent=0;
static char *keywords[]={"s","name","Overlapped","SendBuffer", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO|O:ConnectEx", keywords,
***************
*** 1762,1766 ****
}
// convert the address
! //
char pbuf[30];
char *hptr, *pptr;
--- 1788,1792 ----
}
// convert the address
! //
char pbuf[30];
char *hptr, *pptr;
***************
*** 1810,1819 ****
}
// done screwing with the address
!
if (!PyWinObject_AsOVERLAPPED(obOverlapped, &pOverlapped))
{
return NULL;
}
!
rc=0;
Py_BEGIN_ALLOW_THREADS;
--- 1836,1845 ----
}
// done screwing with the address
!
if (!PyWinObject_AsOVERLAPPED(obOverlapped, &pOverlapped))
{
return NULL;
}
!
rc=0;
Py_BEGIN_ALLOW_THREADS;
***************
*** 5241,5244 ****
--- 5267,5274 ----
PYWIN_MODULE_INIT_RETURN_ERROR;
+ #ifdef PYWIN_HAVE_DATETIME_CAPI
+ PyDateTime_IMPORT;
+ #endif
+
for (PyMethodDef *pmd = win32fileMethods;pmd->ml_name;pmd++)
if ((strcmp(pmd->ml_name, "CreateFileW")==0)
|