pywin32-checkins Mailing List for Python for Windows Extensions (Page 25)
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(6) |
Jul
(50) |
Aug
(11) |
Sep
(24) |
Oct
(184) |
Nov
(118) |
Dec
(22) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(31) |
Feb
(25) |
Mar
(34) |
Apr
(105) |
May
(49) |
Jun
(38) |
Jul
(39) |
Aug
(7) |
Sep
(98) |
Oct
(79) |
Nov
(20) |
Dec
(17) |
2005 |
Jan
(66) |
Feb
(32) |
Mar
(43) |
Apr
(30) |
May
(58) |
Jun
(30) |
Jul
(16) |
Aug
(4) |
Sep
(21) |
Oct
(42) |
Nov
(11) |
Dec
(14) |
2006 |
Jan
(42) |
Feb
(30) |
Mar
(22) |
Apr
(1) |
May
(9) |
Jun
(15) |
Jul
(20) |
Aug
(9) |
Sep
(8) |
Oct
(1) |
Nov
(9) |
Dec
(43) |
2007 |
Jan
(52) |
Feb
(45) |
Mar
(20) |
Apr
(12) |
May
(59) |
Jun
(39) |
Jul
(35) |
Aug
(31) |
Sep
(17) |
Oct
(20) |
Nov
(4) |
Dec
(4) |
2008 |
Jan
(28) |
Feb
(111) |
Mar
(4) |
Apr
(27) |
May
(40) |
Jun
(27) |
Jul
(32) |
Aug
(94) |
Sep
(87) |
Oct
(153) |
Nov
(336) |
Dec
(331) |
2009 |
Jan
(298) |
Feb
(127) |
Mar
(20) |
Apr
(8) |
May
|
Jun
(10) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
2010 |
Jan
(7) |
Feb
(1) |
Mar
|
Apr
|
May
(15) |
Jun
(4) |
Jul
(3) |
Aug
(28) |
Sep
(1) |
Oct
(19) |
Nov
(16) |
Dec
(6) |
2011 |
Jan
(2) |
Feb
(18) |
Mar
(17) |
Apr
(12) |
May
(5) |
Jun
(11) |
Jul
(7) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(4) |
Dec
|
2012 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
(8) |
May
(4) |
Jun
(3) |
Jul
(13) |
Aug
(27) |
Sep
(8) |
Oct
(9) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
|
Feb
(1) |
Mar
(5) |
Apr
(10) |
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(9) |
2014 |
Jan
(2) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(4) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(6) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Jason R. C. <ja...@us...> - 2009-01-25 03:30:14
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32437/Lib Modified Files: win32timezone.py Log Message: Some minor tweaks to improve Python 2.6 compatibility. Index: win32timezone.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32timezone.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** win32timezone.py 24 Jan 2009 14:58:19 -0000 1.23 --- win32timezone.py 25 Jan 2009 03:30:04 -0000 1.24 *************** *** 171,181 **** log = logging.getLogger(__file__) ! # define a couple of Structure comparison methods (these have to appear before the ! # definitions of subclasses or they won't be used in the type construction. ! ctypes.Structure.__eq__ = lambda self, other: str(buffer(self)) == str(buffer(other)) ! ctypes.Structure.__ne__ = lambda self, other: str(buffer(self)) != str(buffer(other)) # A couple of C-type structures for working with the Windows Platform SDK ! class SYSTEMTIME(ctypes.Structure): _fields_ = [ ('year', ctypes.c_ushort), --- 171,203 ---- log = logging.getLogger(__file__) ! # define a constructor to enable Extended structure pickling ! def __construct_structure__(type_, buffer): ! "Construct a ctypes.Structure subclass from a buffer" ! assert issubclass(type_, ctypes.Structure) ! obj = type_.__new__(type_) ! # TODO, what if buffer is larger that the sizeof obj? ! ctypes.memmove(ctypes.addressof(obj), buffer, len(buffer)) ! return obj ! ! class Extended(object): ! "Used to add extended capability to structures" ! def __eq__(self, other): ! return str(buffer(self)) == str(buffer(other)) ! def __ne__(self, other): ! return str(buffer(self)) != str(buffer(other)) + # this method wouldn't be necessary in ctypes 1.1 except + # for the bug described http://bugs.python.org/issue5049 + def __reduce__(self): + """ + A method to make ctypes.Structures pickleable + from http://osdir.com/ml/python.ctypes/2006-03/msg00009.html + """ + args = (self.__class__, str(buffer(self))) + return (globals()['__construct_structure__'], args) + + # A couple of C-type structures for working with the Windows Platform SDK ! class SYSTEMTIME(Extended, ctypes.Structure): _fields_ = [ ('year', ctypes.c_ushort), *************** *** 189,193 **** ] ! class TIME_ZONE_INFORMATION(ctypes.Structure): _fields_ = [ ('bias', ctypes.c_long), --- 211,215 ---- ] ! class TIME_ZONE_INFORMATION(Extended, ctypes.Structure): _fields_ = [ ('bias', ctypes.c_long), *************** *** 240,262 **** super(DYNAMIC_TIME_ZONE_INFORMATION, self).__init__(*self_args, **kwargs) - - # define a couple of functions to enable ctypes.Structure pickling - def __construct_structure(type_, buffer): - "Construct a ctypes.Structure subclass from a buffer" - assert issubclass(type_, ctypes.Structure) - obj = type_.__new__(type_) - # TODO, what if buffer is larger that the sizeof obj? - ctypes.memmove(ctypes.addressof(obj), buffer, len(buffer)) - return obj - - def __reduce(self): - """ - A method to make ctypes.Structures pickleable - from http://osdir.com/ml/python.ctypes/2006-03/msg00009.html - """ - args = (self.__class__, str(buffer(self))) - return (__construct_structure, args) - ctypes.Structure.__reduce__ = __reduce - class TimeZoneDefinition(DYNAMIC_TIME_ZONE_INFORMATION): --- 262,265 ---- *************** *** 312,316 **** def __init_from_other(self, other): if not isinstance(other, TIME_ZONE_INFORMATION): ! raise TypeError, "Not a TIME_ZONE_INFORMATION" for name in other.field_names(): # explicitly get the value from the underlying structure --- 315,319 ---- def __init_from_other(self, other): if not isinstance(other, TIME_ZONE_INFORMATION): ! raise TypeError("Not a TIME_ZONE_INFORMATION") for name in other.field_names(): # explicitly get the value from the underlying structure |
From: Mark H. <mha...@us...> - 2009-01-25 03:21:59
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31969/win32/test Modified Files: test_win32file.py Log Message: don't attempt to close a handle we already closed! Index: test_win32file.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** test_win32file.py 16 Jan 2009 03:29:31 -0000 1.26 --- test_win32file.py 25 Jan 2009 03:21:55 -0000 1.27 *************** *** 297,301 **** raise finally: ! handle.Close() t.join(3) self.failIf(t.isAlive(), "thread didn't finish") --- 297,302 ---- raise finally: ! if not test_overlapped_death: ! handle.Close() t.join(3) self.failIf(t.isAlive(), "thread didn't finish") |
From: Mark H. <mha...@us...> - 2009-01-25 03:21:36
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31920/win32/test Modified Files: test_pywintypes.py Log Message: drop useless test for timezone name in prep for datetime object support Index: test_pywintypes.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_pywintypes.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_pywintypes.py 8 Jan 2009 02:56:18 -0000 1.6 --- test_pywintypes.py 25 Jan 2009 03:21:32 -0000 1.7 *************** *** 10,14 **** pytime_current = pywintypes.Time(struct_current) # try and test all the standard parts of the format ! format_strings = "%a %A %b %B %c %d %H %I %j %m %M %p %S %U %w %W %x %X %y %Y %Z" for fmt in format_strings.split(): v1 = pytime_current.Format(fmt) --- 10,16 ---- pytime_current = pywintypes.Time(struct_current) # try and test all the standard parts of the format ! # Note we used to include '%Z' testing, but that was pretty useless as ! # it always returned the local timezone. ! format_strings = "%a %A %b %B %c %d %H %I %j %m %M %p %S %U %w %W %x %X %y %Y" for fmt in format_strings.split(): v1 = pytime_current.Format(fmt) |
From: Mark H. <mha...@us...> - 2009-01-25 03:21:12
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31889/win32/test Modified Files: test_odbc.py Log Message: make test for large ints work on py2k and py3k Index: test_odbc.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_odbc.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** test_odbc.py 7 Jan 2009 06:03:29 -0000 1.13 --- test_odbc.py 25 Jan 2009 03:21:07 -0000 1.14 *************** *** 130,134 **** self._test_val('intfield', 1) self._test_val('intfield', 0) ! self._test_val('intfield', sys.maxint) def testFloat(self): --- 130,138 ---- self._test_val('intfield', 1) self._test_val('intfield', 0) ! try: ! big = sys.maxsize ! except AttributeError: ! big = sys.maxint ! self._test_val('intfield', big) def testFloat(self): |
From: Mark H. <mha...@us...> - 2009-01-25 03:20:48
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31852/win32/test Modified Files: handles.py test_win32event.py Log Message: Use int2long to make tests py3k-friendly Index: handles.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/handles.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** handles.py 11 Dec 2008 07:00:12 -0000 1.5 --- handles.py 25 Jan 2009 03:20:43 -0000 1.6 *************** *** 3,6 **** --- 3,7 ---- import pywintypes import win32api + from pywin32_testutil import int2long # A class that will never die vie refcounting, but will die via GC. *************** *** 108,112 **** self.assertRaises(TypeError, pywintypes.HANDLE, ()) # should be able to get a long! ! pywintypes.HANDLE(0L) if __name__ == '__main__': --- 109,113 ---- self.assertRaises(TypeError, pywintypes.HANDLE, ()) # should be able to get a long! ! pywintypes.HANDLE(int2long(0)) if __name__ == '__main__': Index: test_win32event.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32event.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_win32event.py 2 Oct 2008 01:31:28 -0000 1.2 --- test_win32event.py 25 Jan 2009 03:20:43 -0000 1.3 *************** *** 4,12 **** import os import sys class TestWaitableTimer(unittest.TestCase): def testWaitableFire(self): h = win32event.CreateWaitableTimer(None, 0, None) ! dt = -160L # 160 ns. win32event.SetWaitableTimer(h, dt, 0, None, None, 0) rc = win32event.WaitForSingleObject(h, 1000) --- 4,20 ---- import os import sys + from pywin32_testutil import int2long class TestWaitableTimer(unittest.TestCase): + def testWaitableFireLong(self): + h = win32event.CreateWaitableTimer(None, 0, None) + dt = int2long(-160) # 160 ns. + win32event.SetWaitableTimer(h, dt, 0, None, None, 0) + rc = win32event.WaitForSingleObject(h, 1000) + self.failUnlessEqual(rc, win32event.WAIT_OBJECT_0) + def testWaitableFire(self): h = win32event.CreateWaitableTimer(None, 0, None) ! dt = -160 # 160 ns. win32event.SetWaitableTimer(h, dt, 0, None, None, 0) rc = win32event.WaitForSingleObject(h, 1000) *************** *** 16,20 **** h = win32event.CreateWaitableTimer(None, 0, None) # for the sake of this, pass a long that doesn't fit in an int. ! dt = -2000000000L win32event.SetWaitableTimer(h, dt, 0, None, None, 0) rc = win32event.WaitForSingleObject(h, 10) # 10 ms. --- 24,28 ---- h = win32event.CreateWaitableTimer(None, 0, None) # for the sake of this, pass a long that doesn't fit in an int. ! dt = -2000000000 win32event.SetWaitableTimer(h, dt, 0, None, None, 0) rc = win32event.WaitForSingleObject(h, 10) # 10 ms. |
From: Mark H. <mha...@us...> - 2009-01-25 03:19:28
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31679/win32/src Modified Files: win32trace.cpp Log Message: * Fix handling of local vs global object detection yet again :( * Make py3k-friendly by using encoding as latin-1. Index: win32trace.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32trace.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** win32trace.cpp 3 Jan 2009 06:43:58 -0000 1.21 --- win32trace.cpp 25 Jan 2009 03:19:22 -0000 1.22 *************** *** 115,129 **** } static PyObject *PyTraceObject_write(PyObject *self, PyObject *args) { int len; ! char *data; ! if (!PyArg_ParseTuple(args, "s#:write", &data, &len)) return NULL; BOOL ok = static_cast<PyTraceObject*>(self)->WriteData(data, len); if (!ok) return NULL; ! Py_INCREF(Py_None); ! return Py_None; } --- 115,133 ---- } + // In an attempt to allow py2k and py3k readers and writers to work together, + // we assume a 'latin1' encoding for the bytes on the wire. When pulling the + // bytes off the wire, in py2k we return a string while in py3k we return + // a latin-1 decoded unicode object. static PyObject *PyTraceObject_write(PyObject *self, PyObject *args) { int len; ! char *data = NULL; ! if (!PyArg_ParseTuple(args, "et#:write", "latin-1", &data, &len)) return NULL; BOOL ok = static_cast<PyTraceObject*>(self)->WriteData(data, len); + PyMem_Free(data); if (!ok) return NULL; ! Py_RETURN_NONE; } *************** *** 137,141 **** --- 141,149 ---- if (!ok) return NULL; + #if (PY_VERSION_HEX < 0x03000000) PyObject *result = PyString_FromStringAndSize(data, len); + #else + PyObject *result = PyUnicode_DecodeLatin1(data, len, "replace"); + #endif free(data); return result; *************** *** 152,156 **** --- 160,168 ---- if (!ok) return NULL; + #if (PY_VERSION_HEX < 0x03000000) PyObject *result = PyString_FromStringAndSize(data, len); + #else + PyObject *result = PyUnicode_DecodeLatin1(data, len, "replace"); + #endif free(data); return result; *************** *** 648,651 **** --- 660,664 ---- // no local one exists - see if we can create it globally - if // we can, we go global, else we stick with local. + use_global_namespace = TRUE; HANDLE h2 = CreateFileMapping((HANDLE)-1, &sa, PAGE_READWRITE, 0, BUFFER_SIZE, |
From: Mark H. <mha...@us...> - 2009-01-25 03:19:25
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31679/win32/test Modified Files: test_win32trace.py Log Message: * Fix handling of local vs global object detection yet again :( * Make py3k-friendly by using encoding as latin-1. Index: test_win32trace.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32trace.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_win32trace.py 4 Dec 2008 07:00:21 -0000 1.7 --- test_win32trace.py 25 Jan 2009 03:19:22 -0000 1.8 *************** *** 15,19 **** time.sleep(0.05) if win32trace.read() != "Hi": ! # Reset everything so following tests still fail with this error!S win32trace.TermRead() win32trace.TermWrite() --- 15,19 ---- time.sleep(0.05) if win32trace.read() != "Hi": ! # Reset everything so following tests still fail with this error! win32trace.TermRead() win32trace.TermWrite() *************** *** 102,109 **** --- 102,122 ---- self.assertEquals('Syver Enstad', syverEnstad) + def testRoundTripUnicode(self): + win32trace.write(u'\xa9opyright Syver Enstad') + syverEnstad = win32trace.read() + # str objects are always returned in py2k (latin-1 encoding was used + # on unicode objects) + self.assertEquals('\xa9opyright Syver Enstad', syverEnstad) + def testBlockingRead(self): win32trace.write('Syver Enstad') self.assertEquals('Syver Enstad', win32trace.blockingread()) + def testBlockingReadUnicode(self): + win32trace.write(u'\xa9opyright Syver Enstad') + # str objects are always returned in py2k (latin-1 encoding was used + # on unicode objects) + self.assertEquals('\xa9opyright Syver Enstad', win32trace.blockingread()) + def testFlush(self): win32trace.flush() |
From: Mark H. <mha...@us...> - 2009-01-25 03:18:06
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31572/win32/src Modified Files: win32apimodule.cpp Log Message: * Allow GetTimeZoneInformation to return the SYSTEMTIME elements as tuples. * Add SetTimeZoneInformation. * Modernize how we check for exception objects in the 'console control handler' to allow things to work with py3k Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -d -r1.94 -r1.95 *** win32apimodule.cpp 11 Dec 2008 05:09:00 -0000 1.94 --- win32apimodule.cpp 25 Jan 2009 03:17:58 -0000 1.95 *************** *** 104,107 **** --- 104,134 ---- return PyWin_SetAPIError(fnName, err); } + + PyObject *PyTuple_FromSYSTEMTIME(SYSTEMTIME &st) + { + return Py_BuildValue("iiiiiiii", + st.wYear, + st.wMonth, + st.wDayOfWeek, + st.wDay, + st.wHour, + st.wMinute, + st.wSecond, + st.wMilliseconds); + } + + BOOL PyTuple_AsSYSTEMTIME(PyObject *ob, SYSTEMTIME &st) + { + return PyArg_ParseTuple(ob, "iiiiiiii", + &st.wYear, + &st.wMonth, + &st.wDayOfWeek, + &st.wDay, + &st.wHour, + &st.wMinute, + &st.wSecond, + &st.wMilliseconds); + } + // @pymethod |win32api|Beep|Generates simple tones on the speaker. static PyObject * *************** *** 2344,2348 **** PyGetTimeZoneInformation(PyObject * self, PyObject * args) { ! if (!PyArg_ParseTuple (args, ":GetTimeZoneInformation")) return NULL; TIME_ZONE_INFORMATION tzinfo; --- 2371,2377 ---- PyGetTimeZoneInformation(PyObject * self, PyObject * args) { ! int bTimesAsTuples = 0; ! // @pyparm bool|times_as_tuples|False|If true, the SYSTEMTIME elements are returned as tuples instead of a time object. ! if (!PyArg_ParseTuple (args, "|i:GetTimeZoneInformation", &bTimesAsTuples)) return NULL; TIME_ZONE_INFORMATION tzinfo; *************** *** 2369,2376 **** tzinfo.Bias, PyWinObject_FromWCHAR(tzinfo.StandardName), ! PyWinObject_FromSYSTEMTIME(tzinfo.StandardDate), tzinfo.StandardBias, PyWinObject_FromWCHAR(tzinfo.DaylightName), ! PyWinObject_FromSYSTEMTIME(tzinfo.DaylightDate), tzinfo.DaylightBias ); --- 2398,2409 ---- tzinfo.Bias, PyWinObject_FromWCHAR(tzinfo.StandardName), ! bTimesAsTuples ? ! PyTuple_FromSYSTEMTIME(tzinfo.StandardDate) : ! PyWinObject_FromSYSTEMTIME(tzinfo.StandardDate), tzinfo.StandardBias, PyWinObject_FromWCHAR(tzinfo.DaylightName), ! bTimesAsTuples ? ! PyTuple_FromSYSTEMTIME(tzinfo.DaylightDate) : ! PyWinObject_FromSYSTEMTIME(tzinfo.DaylightDate), tzinfo.DaylightBias ); *************** *** 2384,2392 **** // @tupleitem 0|int|bias|Specifies the current bias, in minutes, for local time translation on this computer. The bias is the difference, in minutes, between Coordinated Universal Time (UTC) and local time. All translations between UTC and local time are based on the following formula:<nl><nl>UTC = local time + bias <nl><nl> // @tupleitem 1|unicode|standardName|Specifies a string associated with standard time on this operating system. For example, this member could contain "EST" to indicate Eastern Standard Time. This string is not used by the operating system, so anything stored there using the SetTimeZoneInformation function is returned unchanged by the GetTimeZoneInformation function. This string can be empty. ! // @tupleitem 2|<o PyTime>|standardTime|Specifies a SYSTEMTIME object that contains a date and local time when the transition from daylight saving time to standard time occurs on this operating system. If this date is not specified, the wMonth member in the SYSTEMTIME structure must be zero. If this date is specified, the DaylightDate value in the TIME_ZONE_INFORMATION structure must also be specified. // <nl>To select the correct day in the month, set the wYear member to zero, the wDayOfWeek member to an appropriate weekday, and the wDay member to a value in the range 1 through 5. Using this notation, the first Sunday in April can be specified, as can the last Thursday in October (5 is equal to "the last"). // @tupleitem 3|int|standardBias|Specifies a bias value to be used during local time translations that occur during standard time. This member is ignored if a value for the StandardDate member is not supplied. <nl>This value is added to the value of the Bias member to form the bias used during standard time. In most time zones, the value of this member is zero. // @tupleitem 4|unicode|daylightName| ! // @tupleitem 5|<o PyTime>|daylightTime| // @tupleitem 6|int|daylightBias|Specifies a bias value to be used during local time translations that occur during daylight saving time. This member is ignored if a value for the DaylightDate member is not supplied. // <nl>This value is added to the value of the Bias member to form the bias used during daylight saving time. In most time zones, the value of this member is 60. --- 2417,2425 ---- // @tupleitem 0|int|bias|Specifies the current bias, in minutes, for local time translation on this computer. The bias is the difference, in minutes, between Coordinated Universal Time (UTC) and local time. All translations between UTC and local time are based on the following formula:<nl><nl>UTC = local time + bias <nl><nl> // @tupleitem 1|unicode|standardName|Specifies a string associated with standard time on this operating system. For example, this member could contain "EST" to indicate Eastern Standard Time. This string is not used by the operating system, so anything stored there using the SetTimeZoneInformation function is returned unchanged by the GetTimeZoneInformation function. This string can be empty. ! // @tupleitem 2|<o PyTime>/tuple|standardTime|Specifies a SYSTEMTIME object that contains a date and local time when the transition from daylight saving time to standard time occurs on this operating system. If this date is not specified, the wMonth member in the SYSTEMTIME structure must be zero. If this date is specified, the DaylightDate value in the TIME_ZONE_INFORMATION structure must also be specified. // <nl>To select the correct day in the month, set the wYear member to zero, the wDayOfWeek member to an appropriate weekday, and the wDay member to a value in the range 1 through 5. Using this notation, the first Sunday in April can be specified, as can the last Thursday in October (5 is equal to "the last"). // @tupleitem 3|int|standardBias|Specifies a bias value to be used during local time translations that occur during standard time. This member is ignored if a value for the StandardDate member is not supplied. <nl>This value is added to the value of the Bias member to form the bias used during standard time. In most time zones, the value of this member is zero. // @tupleitem 4|unicode|daylightName| ! // @tupleitem 5|<o PyTime>/tuple|daylightTime| // @tupleitem 6|int|daylightBias|Specifies a bias value to be used during local time translations that occur during daylight saving time. This member is ignored if a value for the DaylightDate member is not supplied. // <nl>This value is added to the value of the Bias member to form the bias used during daylight saving time. In most time zones, the value of this member is 60. *************** *** 2394,2397 **** --- 2427,2482 ---- } + // @pymethod tuple|win32api|SetTimeZoneInformation|Sets the system time-zone information. + static PyObject * + PySetTimeZoneInformation(PyObject * self, PyObject * args) + { + // @pyparm tuple|tzi||A tuple with the timezone info + // @desc The tuple is of form. + TIME_ZONE_INFORMATION tzi; + PyObject *obStdName, *obStdDate; + PyObject *obDaylightName, *obDaylightDate; + if (!PyArg_ParseTuple (args, "(iOOiOOi):SetTimeZoneInformation", + &tzi.Bias, // @tupleitem 0|int|Bias| + &obStdName, // @tupleitem 1|string|StandardName + &obStdDate, // @tupleitem 2|SYSTEMTIME tuple|StandardDate + &tzi.StandardBias, // @tupleitem 3|int|StandardBias + &obDaylightName, // @tupleitem 4|string|DaylightName + &obDaylightDate, // @tupleitem 5|SYSTEMTIME tuple|DaylightDate + &tzi.DaylightBias))// @tupleitem 6|int|DaylightBias + return NULL; + WCHAR *temp; + if (!PyWinObject_AsWCHAR(obStdName, &temp)) + return NULL; + if (wcslen(temp)>31) { + PyWinObject_FreeWCHAR(temp); + return PyErr_Format(PyExc_ValueError, "Time zone names must be < 32 chars long"); + } + wcscpy(tzi.StandardName, temp); + PyWinObject_FreeWCHAR(temp); + // second string... + if (!PyWinObject_AsWCHAR(obDaylightName, &temp)) + return NULL; + if (wcslen(temp)>31) { + PyWinObject_FreeWCHAR(temp); + return PyErr_Format(PyExc_ValueError, "Time zone names must be < 32 chars long"); + } + wcscpy(tzi.DaylightName, temp); + PyWinObject_FreeWCHAR(temp); + + // tuples with a SYSTEMTIME + if (!PyTuple_AsSYSTEMTIME(obStdDate, tzi.StandardDate)) + return NULL; + if (!PyTuple_AsSYSTEMTIME(obDaylightDate, tzi.DaylightDate)) + return NULL; + + BOOL rc; + PyW32_BEGIN_ALLOW_THREADS + rc = ::SetTimeZoneInformation(&tzi); + PyW32_END_ALLOW_THREADS + if(!rc) + return ReturnAPIError("SetTimeZoneInformation"); + Py_RETURN_NONE; + } + // @pymethod string|win32api|GetDateFormat|Formats a date as a date string for a specified locale. The function formats either a specified date or the local system date. static PyObject *PyGetDateFormat(PyObject *self, PyObject *args) *************** *** 5460,5464 **** ret = PyInt_AsLong(obRet); // Exception instance to be raised. ! } else if (PyInstance_Check(obRet)) { *ppExcType = obRet; Py_INCREF(obRet); --- 5545,5549 ---- ret = PyInt_AsLong(obRet); // Exception instance to be raised. ! } else if (PyObject_IsSubclass(obRet, PyExc_Exception)) { *ppExcType = obRet; Py_INCREF(obRet); *************** *** 5516,5520 **** if (stateCur == NULL) stateCur = stateSave; PyThreadState_Swap(stateCur); ! if (PyInstance_Check(exc_type)) { if (exc_value != NULL) PyErr_SetString(PyExc_TypeError, "instance exception returned from exception handler may not have a separate value"); --- 5601,5605 ---- if (stateCur == NULL) stateCur = stateSave; PyThreadState_Swap(stateCur); ! if (PyObject_IsSubclass(exc_type, PyExc_Exception)) { if (exc_value != NULL) PyErr_SetString(PyExc_TypeError, "instance exception returned from exception handler may not have a separate value"); *************** *** 5522,5526 **** // Normalize to class, instance exc_value = exc_type; ! exc_type = (PyObject*) ((PyInstanceObject*)exc_type)->in_class; Py_INCREF(exc_type); PyErr_SetObject(exc_type, exc_value); --- 5607,5611 ---- // Normalize to class, instance exc_value = exc_type; ! exc_type = (PyObject *)exc_value->ob_type; Py_INCREF(exc_type); PyErr_SetObject(exc_type, exc_value); *************** *** 6182,6185 **** --- 6267,6271 ---- {"SetSystemPowerState", PySetSystemPowerState, 1}, // @pymeth SetSystemPowerState|Powers machine down to a suspended state {"SetThreadLocale", PySetThreadLocale, 1}, // @pymeth SetThreadLocale|Sets the current thread's locale. + {"SetTimeZoneInformation",PySetTimeZoneInformation,1}, // @pymeth SetTimeZoneInformation|Sets the system time-zone information. {"SetWindowLong", PySetWindowLong,1}, // @pymeth SetWindowLong|Places a long value at the specified offset into the extra window memory of the given window. {"ShellExecute", PyShellExecute, 1}, // @pymeth ShellExecute|Executes an application. |
From: Mark H. <mha...@us...> - 2009-01-25 03:16:41
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31534/win32/src Modified Files: PySID.cpp PySecurityObjects.h Log Message: Give PySID objects rich comparison support for py3k Index: PySID.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PySID.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PySID.cpp 11 Dec 2008 00:25:40 -0000 1.15 --- PySID.cpp 25 Jan 2009 03:16:35 -0000 1.16 *************** *** 261,265 **** 0, /* tp_traverse */ 0, /* tp_clear */ ! 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ --- 261,265 ---- 0, /* tp_traverse */ 0, /* tp_clear */ ! PySID::richcompareFunc, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ *************** *** 314,317 **** --- 314,336 ---- } + PyObject *PySID::richcompare(PyObject *other, int op) + { + BOOL e; + if (PySID_Check(other)) + e=compare((PyHANDLE *)other)==0; + else + e=FALSE; + PyObject *ret; + if (op==Py_EQ) + ret = e ? Py_True : Py_False; + else if (op==Py_NE) + ret = !e ? Py_True : Py_False; + else { + PyErr_SetString(PyExc_TypeError, "SIDs only compare equal or not equal"); + ret = NULL; + } + Py_XINCREF(ret); + return ret; + } // @pymethod int|PySID|__cmp__|Used when objects are compared. *************** *** 322,325 **** --- 341,349 ---- } + PyObject *PySID::richcompareFunc(PyObject *ob1, PyObject *ob2, int op) + { + return ((PySID *)ob1)->richcompare(ob2, op); + } + /*static*/ void PySID::deallocFunc(PyObject *ob) { Index: PySecurityObjects.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PySecurityObjects.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PySecurityObjects.h 11 Dec 2008 00:25:40 -0000 1.14 --- PySecurityObjects.h 25 Jan 2009 03:16:35 -0000 1.15 *************** *** 102,108 **** --- 102,110 ---- /* Python support */ int compare(PyObject *ob); + PyObject *richcompare(PyObject *other, int op); static void deallocFunc(PyObject *ob); static int compareFunc(PyObject *ob1, PyObject *ob2); + static PyObject *richcompareFunc(PyObject *ob1, PyObject *ob2, int op); static PyObject *strFunc(PyObject *ob); |
From: Mark H. <mha...@us...> - 2009-01-25 03:12:22
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31323/win32/Lib Modified Files: pywin32_testutil.py Log Message: Add int2long test helper and construct failure objects in py3k-friendly way Index: pywin32_testutil.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/pywin32_testutil.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pywin32_testutil.py 7 Jan 2009 05:59:56 -0000 1.1 --- pywin32_testutil.py 25 Jan 2009 03:12:18 -0000 1.2 *************** *** 9,12 **** --- 9,16 ---- ## + def int2long(val): + """return a long on py2k""" + return val + 0x100000000 - 0x100000000 + # The test suite has lots of string constants containing binary data, but # the strings are used in various "bytes" contexts. *************** *** 82,86 **** msg = "%d interface objects and %d gateway objects leaked" \ % (lost_i, lost_g) ! result.addFailure(self.real_test, (AssertionError, msg, None)) def runTest(self): --- 86,91 ---- msg = "%d interface objects and %d gateway objects leaked" \ % (lost_i, lost_g) ! exc = AssertionError(msg) ! result.addFailure(self.real_test, (exc.__class__, exc, None)) def runTest(self): *************** *** 109,113 **** if lost > 0: msg = "LeakTest: %s lost %d references" % (self.real_test, lost) ! result.addFailure(self.real_test, (AssertionError, msg, None)) --- 114,119 ---- if lost > 0: msg = "LeakTest: %s lost %d references" % (self.real_test, lost) ! exc = AssertionError(msg) ! result.addFailure(self.real_test, (exc.__class__, exc, None)) |
From: Mark H. <mha...@us...> - 2009-01-25 03:11:45
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31265/com/win32com/src Modified Files: oleargs.cpp Log Message: don't convert bytes objects on py3k to VT_BSTR Index: oleargs.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/oleargs.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** oleargs.cpp 12 Jan 2009 05:41:40 -0000 1.44 --- oleargs.cpp 25 Jan 2009 03:11:40 -0000 1.45 *************** *** 48,52 **** BOOL bGoodEmpty = FALSE; // Set if VT_EMPTY should really be used. V_VT(var) = VT_EMPTY; ! if ( PyString_Check(obj) || PyUnicode_Check(obj) ) { if ( !PyWinObject_AsBstr(obj, &V_BSTR(var)) ) { --- 48,57 ---- BOOL bGoodEmpty = FALSE; // Set if VT_EMPTY should really be used. V_VT(var) = VT_EMPTY; ! if ( ! // In py3k we don't convert PyString_Check objects (ie, bytes) to BSTR... ! #if (PY_VERSION_HEX < 0x03000000) ! PyString_Check(obj) || ! #endif ! PyUnicode_Check(obj) ) { if ( !PyWinObject_AsBstr(obj, &V_BSTR(var)) ) { |
From: Mark H. <mha...@us...> - 2009-01-25 03:08:47
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/tools In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31095/Pythonwin/pywin/tools Modified Files: browser.py Log Message: modernize type handling in pythonwin's browser and make py3k-friendly Index: browser.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/tools/browser.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** browser.py 14 Jan 2009 12:11:04 -0000 1.15 --- browser.py 25 Jan 2009 03:08:42 -0000 1.16 *************** *** 6,9 **** --- 6,11 ---- # or # >>> browser.Browse(your_module) + import sys + import types import __main__ import win32ui *************** *** 11,15 **** import hierlist - from types import * special_names = [ '__doc__', '__name__', '__self__' ] --- 13,16 ---- *************** *** 265,286 **** TypeMap = { type : HLIClass, ! FunctionType: HLIFunction, tuple: HLITuple, dict: HLIDict, list: HLIList, ! ModuleType: HLIModule, ! CodeType : HLICode, ! BuiltinFunctionType : HLIBuiltinFunction, ! FrameType : HLIFrame, ! TracebackType : HLITraceback, str : HLIString, int: HLIPythonObject, ! ## LongType: HLIPythonObject, - hrm - fixme for py2k float: HLIPythonObject, } - try: - TypeMap[UnicodeType] = HLIString - except NameError: - pass # Python 1.5 - no Unicode - no problem! def MakeHLI( ob, name=None ): --- 266,285 ---- TypeMap = { type : HLIClass, ! types.FunctionType: HLIFunction, tuple: HLITuple, dict: HLIDict, list: HLIList, ! types.ModuleType: HLIModule, ! types.CodeType : HLICode, ! types.BuiltinFunctionType : HLIBuiltinFunction, ! types.FrameType : HLIFrame, ! types.TracebackType : HLITraceback, str : HLIString, + unicode : HLIString, int: HLIPythonObject, ! long: HLIPythonObject, ! bool: HLIPythonObject, float: HLIPythonObject, } def MakeHLI( ob, name=None ): *************** *** 288,291 **** --- 287,293 ---- cls = TypeMap[type(ob)] except KeyError: + # hrmph - this check gets more and more bogus as Python + # improves. Its possible we should just *always* use + # HLIInstance? if hasattr(ob, '__class__'): # 'new style' class cls = HLIInstance |
From: Mark H. <mha...@us...> - 2009-01-25 03:08:14
|
Update of /cvsroot/pywin32/pywin32 In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31011 Modified Files: setup.py Log Message: fix implib handling in debug builds Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** setup.py 14 Jan 2009 04:27:41 -0000 1.92 --- setup.py 25 Jan 2009 03:08:09 -0000 1.93 *************** *** 86,90 **** # using the 'imports' fixer and therefore start much faster... if is_py3k: ! import winreg as winreg else: import _winreg --- 86,90 ---- # using the 'imports' fixer and therefore start much faster... if is_py3k: ! import winreg as _winreg else: import _winreg *************** *** 400,404 **** if self.implib_name: implib = os.path.join(build_ext.build_temp, self.implib_name) ! self.extra_link_args.append("/IMPLIB:%s" % implib) # Try and find the MFC source code, so we can reach inside for # some of the ActiveX support we need. We need to do this late, so --- 400,408 ---- if self.implib_name: implib = os.path.join(build_ext.build_temp, self.implib_name) ! if build_ext.debug: ! suffix = "_d" ! else: ! suffix = "" ! self.extra_link_args.append("/IMPLIB:%s%s.lib" % (implib, suffix)) # Try and find the MFC source code, so we can reach inside for # some of the ActiveX support we need. We need to do this late, so *************** *** 1520,1524 **** dsp_file=r"com\Active Scripting.dsp", extra_compile_args = ['-DPY_BUILD_AXSCRIPT'], ! implib_name="axscript.lib", pch_header = "stdafx.h" ), --- 1524,1528 ---- dsp_file=r"com\Active Scripting.dsp", extra_compile_args = ['-DPY_BUILD_AXSCRIPT'], ! implib_name="axscript", pch_header = "stdafx.h" ), *************** *** 1665,1669 **** %(propsys)s/propsys.cpp """ % dirs).split(), ! implib_name="pypropsys.lib", ), --- 1669,1673 ---- %(propsys)s/propsys.cpp """ % dirs).split(), ! implib_name="pypropsys", ), |
From: Jason R. C. <ja...@us...> - 2009-01-24 14:58:23
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14830 Modified Files: win32timezone.py Log Message: Continued the refactoring - moved much of the code from the structure definitions to TimeZoneDefinition. Added support for the DYNAMIC_TIME_ZONE_INFORMATION structure. TimeZoneDefinition is now a subclass of the DYNAMIC_TIME_ZONE_DEFINITION structure. This will allow for better support of Vista and later platforms in the future. TimeZoneDefinition.current now retrieves the dynamic time zone information if the function is available. Index: win32timezone.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32timezone.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** win32timezone.py 19 Jan 2009 00:31:49 -0000 1.22 --- win32timezone.py 24 Jan 2009 14:58:19 -0000 1.23 *************** *** 200,209 **** ] ! class DYNAMIC_TIME_ZONE_INFORMATION(ctypes.Structure): ! _fields_ = TIME_ZONE_INFORMATION._fields_ + [ ('key_name', ctypes.c_wchar*128), ('dynamic_daylight_time_disabled', ctypes.wintypes.BOOL), ] ! # define a couple of functions to enable ctypes.Structure pickling def __construct_structure(type_, buffer): --- 200,244 ---- ] ! class DYNAMIC_TIME_ZONE_INFORMATION(TIME_ZONE_INFORMATION): ! """ ! Because the structure of the DYNAMIC_TIME_ZONE_INFORMATION extends ! the structure of the TIME_ZONE_INFORMATION, this structure ! can be used as a drop-in replacement for calls where the ! structure is passed by reference. ! ! For example, ! dynamic_tzi = DYNAMIC_TIME_ZONE_INFORMATION() ! ctypes.windll.kernel32.GetTimeZoneInformation(ctypes.byref(dynamic_tzi)) ! ! (although the key_name and dynamic_daylight_time_disabled flags will be ! set to the default (null)). ! ! >>> isinstance(DYNAMIC_TIME_ZONE_INFORMATION(), TIME_ZONE_INFORMATION) ! True ! ! ! """ ! _fields_ = [ ! # ctypes automatically includes the fields from the parent ('key_name', ctypes.c_wchar*128), ('dynamic_daylight_time_disabled', ctypes.wintypes.BOOL), ] ! ! def __init__(self, *args, **kwargs): ! """Allow initialization from args from both this class and ! its superclass. Default ctypes implementation seems to ! assume that this class is only initialized with its own ! _fields_ (for non-keyword-args).""" ! super_self = super(DYNAMIC_TIME_ZONE_INFORMATION, self) ! super_fields = super_self._fields_ ! super_args = args[:len(super_fields)] ! self_args = args[len(super_fields):] ! # convert the super args to keyword args so they're also handled ! for field, arg in zip(super_fields, super_args): ! field_name, spec = field ! kwargs[field_name] = arg ! super(DYNAMIC_TIME_ZONE_INFORMATION, self).__init__(*self_args, **kwargs) ! ! # define a couple of functions to enable ctypes.Structure pickling def __construct_structure(type_, buffer): *************** *** 225,232 **** ! class TimeZoneDefinition(TIME_ZONE_INFORMATION): """ ! A time zone definition class based on the win32 TIME_ZONE_INFORMATION ! structure. Describes a bias against UTC (bias), and two dates at which a separate --- 260,267 ---- ! class TimeZoneDefinition(DYNAMIC_TIME_ZONE_INFORMATION): """ ! A time zone definition class based on the win32 ! DYNAMIC_TIME_ZONE_INFORMATION structure. Describes a bias against UTC (bias), and two dates at which a separate *************** *** 240,249 **** """ Try to construct a TimeZoneDefinition from ! a) TIME_ZONE_INFORMATION args b) another TimeZoneDefinition c) a byte structure (using _from_bytes) """ try: ! TIME_ZONE_INFORMATION.__init__(self, *args, **kwargs) return except TypeError: --- 275,284 ---- """ Try to construct a TimeZoneDefinition from ! a) [DYNAMIC_]TIME_ZONE_INFORMATION args b) another TimeZoneDefinition c) a byte structure (using _from_bytes) """ try: ! super(TimeZoneDefinition, self).__init__(*args, **kwargs) return except TypeError: *************** *** 264,268 **** raise TypeError("Invalid arguments for %s" % self.__class__) ! def __init_from_bytes(self, bytes, standard_name='', daylight_name=''): format = '3l8h8h' components = struct.unpack(format, bytes) --- 299,303 ---- raise TypeError("Invalid arguments for %s" % self.__class__) ! def __init_from_bytes(self, bytes, standard_name='', daylight_name='', key_name='', daylight_disabled=False): format = '3l8h8h' components = struct.unpack(format, bytes) *************** *** 270,289 **** standard_start = SYSTEMTIME(*components[3:11]) daylight_start = SYSTEMTIME(*components[11:19]) ! TIME_ZONE_INFORMATION.__init__(self, bias, standard_name, standard_start, standard_bias, ! daylight_name, daylight_start, daylight_bias,) def __init_from_other(self, other): if not isinstance(other, TIME_ZONE_INFORMATION): raise TypeError, "Not a TIME_ZONE_INFORMATION" ! for name in self.field_names(): # explicitly get the value from the underlying structure ! value = TIME_ZONE_INFORMATION.__getattribute__(other, name) setattr(self, name, value) ! # consider ! # def __getattribute__(self, attr): ! value = TIME_ZONE_INFORMATION.__getattribute__(self, attr) make_minute_timedelta = lambda m: datetime.timedelta(minutes = m) if 'bias' in attr: --- 305,326 ---- standard_start = SYSTEMTIME(*components[3:11]) daylight_start = SYSTEMTIME(*components[11:19]) ! super(TimeZoneDefinition, self).__init__(bias, standard_name, standard_start, standard_bias, ! daylight_name, daylight_start, daylight_bias, ! key_name, daylight_disabled,) def __init_from_other(self, other): if not isinstance(other, TIME_ZONE_INFORMATION): raise TypeError, "Not a TIME_ZONE_INFORMATION" ! for name in other.field_names(): # explicitly get the value from the underlying structure ! value = super(TimeZoneDefinition, other).__getattribute__(other, name) setattr(self, name, value) ! # consider instead of the loop above just copying the memory directly ! #size = max(ctypes.sizeof(DYNAMIC_TIME_ZONE_INFO), ctypes.sizeof(other)) ! #ctypes.memmove(ctypes.addressof(self), other, size) def __getattribute__(self, attr): ! value = super(TimeZoneDefinition, self).__getattribute__(attr) make_minute_timedelta = lambda m: datetime.timedelta(minutes = m) if 'bias' in attr: *************** *** 295,303 **** "Windows Platform SDK GetTimeZoneInformation" tzi = class_() ! code = ctypes.windll.kernel32.GetTimeZoneInformation(ctypes.byref(tzi)) return code, tzi def set(self): ! return ctypes.windll.kernel32.SetTimeZoneInformation(ctypes.byref(self)) def copy(self): --- 332,346 ---- "Windows Platform SDK GetTimeZoneInformation" tzi = class_() ! kernel32 = ctypes.windll.kernel32 ! getter = kernel32.GetTimeZoneInformation ! getter = getattr(kernel32, 'GetDynamicTimeZoneInformation', getter) ! code = getter(ctypes.byref(tzi)) return code, tzi def set(self): ! kernel32 = ctypes.windll.kernel32 ! setter = kernel32.SetTimeZoneInformation ! setter = getattr(kernel32, 'SetDynamicTimeZoneInformation', setter) ! return setter(ctypes.byref(self)) def copy(self): |
From: Mark H. <mha...@us...> - 2009-01-23 04:33:28
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17326 Modified Files: PyIType.cpp Log Message: release the GIL while calling GetContainingTypeLib Index: PyIType.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyIType.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PyIType.cpp 13 Nov 2008 11:11:58 -0000 1.10 --- PyIType.cpp 23 Jan 2009 04:33:25 -0000 1.11 *************** *** 44,48 **** --- 44,50 ---- ITypeLib *ptlib; unsigned index; + PY_INTERFACE_PRECALL; SCODE sc = pMyTypeInfo->GetContainingTypeLib(&ptlib, &index); + PY_INTERFACE_POSTCALL; if (FAILED(sc)) return PyCom_BuildPyException(sc, pMyTypeInfo, IID_ITypeInfo); |
From: Jason R. C. <ja...@us...> - 2009-01-19 00:32:01
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13459 Modified Files: win32timezone.py Log Message: Added ability to pickle a TimeZoneInformation created from a TimeZoneDefinition. Added the DYNAMIC_TIME_ZONE_INFORMATION structure (considering this as the basis for TimeZoneDefinition). Index: win32timezone.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32timezone.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** win32timezone.py 18 Jan 2009 21:50:27 -0000 1.21 --- win32timezone.py 19 Jan 2009 00:31:49 -0000 1.22 *************** *** 78,81 **** --- 78,87 ---- True + It's possible to construct a TimeZoneInfo from a TimeZoneDescription + including the currently-defined zone. + >>> tz = win32timezone.TimeZoneInfo(TimeZoneDefinition.current()) + >>> tz == pickle.loads(pickle.dumps(tz)) + True + >>> aest = win32timezone.TimeZoneInfo('AUS Eastern Standard Time') >>> est = win32timezone.TimeZoneInfo('E. Australia Standard Time') *************** *** 154,157 **** --- 160,164 ---- import win32api import ctypes + import ctypes.wintypes import re import sys *************** *** 193,196 **** --- 200,209 ---- ] + class DYNAMIC_TIME_ZONE_INFORMATION(ctypes.Structure): + _fields_ = TIME_ZONE_INFORMATION._fields_ + [ + ('key_name', ctypes.c_wchar*128), + ('dynamic_daylight_time_disabled', ctypes.wintypes.BOOL), + ] + # define a couple of functions to enable ctypes.Structure pickling def __construct_structure(type_, buffer): *************** *** 351,355 **** tzRegKey = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones' ! def __init__(self, param, fix_standard_time=False): if isinstance(param, TimeZoneDefinition): self._LoadFromTZI(param) --- 364,368 ---- tzRegKey = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones' ! def __init__(self, param=None, fix_standard_time=False): if isinstance(param, TimeZoneDefinition): self._LoadFromTZI(param) *************** *** 374,380 **** return result - def __getinitargs__(self): - return (self.timeZoneName,) - def _LoadInfoFromKey(self): """Loads the information from an opened time zone registry key --- 387,390 ---- |
From: Jason R. C. <ja...@us...> - 2009-01-18 23:17:02
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv5473 Modified Files: win32timezone.py Log Message: Fixed pickling error, caused by the pickle-unfriendly ctypes.Structures Index: win32timezone.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32timezone.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** win32timezone.py 16 Jan 2009 03:22:24 -0000 1.20 --- win32timezone.py 18 Jan 2009 21:50:27 -0000 1.21 *************** *** 164,167 **** --- 164,172 ---- log = logging.getLogger(__file__) + # define a couple of Structure comparison methods (these have to appear before the + # definitions of subclasses or they won't be used in the type construction. + ctypes.Structure.__eq__ = lambda self, other: str(buffer(self)) == str(buffer(other)) + ctypes.Structure.__ne__ = lambda self, other: str(buffer(self)) != str(buffer(other)) + # A couple of C-type structures for working with the Windows Platform SDK class SYSTEMTIME(ctypes.Structure): *************** *** 188,191 **** --- 193,214 ---- ] + # define a couple of functions to enable ctypes.Structure pickling + def __construct_structure(type_, buffer): + "Construct a ctypes.Structure subclass from a buffer" + assert issubclass(type_, ctypes.Structure) + obj = type_.__new__(type_) + # TODO, what if buffer is larger that the sizeof obj? + ctypes.memmove(ctypes.addressof(obj), buffer, len(buffer)) + return obj + + def __reduce(self): + """ + A method to make ctypes.Structures pickleable + from http://osdir.com/ml/python.ctypes/2006-03/msg00009.html + """ + args = (self.__class__, str(buffer(self))) + return (__construct_structure, args) + ctypes.Structure.__reduce__ = __reduce + class TimeZoneDefinition(TIME_ZONE_INFORMATION): *************** *** 245,248 **** --- 268,273 ---- value = TIME_ZONE_INFORMATION.__getattribute__(other, name) setattr(self, name, value) + # consider + # def __getattribute__(self, attr): |
From: Jason R. C. <ja...@us...> - 2009-01-16 03:29:44
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31531/test Modified Files: test_win32file.py Log Message: Updated test for win32file for changes to win32timezone. Index: test_win32file.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** test_win32file.py 14 Jan 2009 01:20:58 -0000 1.25 --- test_win32file.py 16 Jan 2009 03:29:31 -0000 1.26 *************** *** 123,128 **** def testFileTimes(self): if issubclass(pywintypes.TimeType, datetime.datetime): ! from win32timezone import GetLocalTimeZone ! now = datetime.datetime.now(tz=GetLocalTimeZone()) nowish = now + datetime.timedelta(seconds=1) later = now + datetime.timedelta(seconds=120) --- 123,128 ---- def testFileTimes(self): if issubclass(pywintypes.TimeType, datetime.datetime): ! from win32timezone import TimeZoneInfo ! now = datetime.datetime.now(tz=TimeZoneInfo.local()) nowish = now + datetime.timedelta(seconds=1) later = now + datetime.timedelta(seconds=120) |
From: Jason R. C. <ja...@us...> - 2009-01-16 03:22:31
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31102 Modified Files: win32timezone.py Log Message: Reorganized and refactored again. WinTZI becomes TimeZoneDefinition which is now a subclass of TIME_ZONE_INFORMATION structure. Robust constructor allows for easy construction from various sources. Moved several functions into the appropriate classes. GetLocalTimeZone() -> TimeZoneInfo.local() GetUTCTimeZone() -> TimeZoneInfo.utc() Restored doctests that describe and confirm the qwirks with dynamic time zones and definition patches that changed time zones in 2007. These tests should pass on all systems. Index: win32timezone.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32timezone.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** win32timezone.py 14 Jan 2009 17:51:17 -0000 1.19 --- win32timezone.py 16 Jan 2009 03:22:24 -0000 1.20 *************** *** 98,113 **** http://support.microsoft.com/gp/cp_dst) ! As a result, the following test will fail in machines with the patch ! except for Vista and its succssors, which have dynamic time ! zone support. ! #>>> nov2 = datetime.datetime(2003, 11, 2, tzinfo = tzi) ! #>>> nov2.utctimetuple() ! (2003, 11, 2, 7, 0, 0, 6, 306, 0) - Note that is the correct response beginning in 2007 - This test will fail in Windows versions prior to Vista - #>>> nov2 = datetime.datetime(2007, 11, 2, tzinfo = tzi) - #>>> nov2.utctimetuple() - (2007, 11, 2, 6, 0, 0, 4, 306, 0) There is a function you can call to get some capabilities of the time --- 98,120 ---- http://support.microsoft.com/gp/cp_dst) ! As a result, patched systems will give an incorrect result for ! dates prior to the designated year except for Vista and its ! successors, which have dynamic time zone support. ! >>> nov2_pre_change = datetime.datetime(2003, 11, 2, tzinfo = MST) ! >>> old_response = (2003, 11, 2, 7, 0, 0, 6, 306, 0) ! >>> incorrect_patch_response = (2003, 11, 2, 6, 0, 0, 6, 306, 0) ! >>> pre_response = nov2_pre_change.utctimetuple() ! >>> pre_response in (old_response, incorrect_patch_response) ! True ! ! Furthermore, unpatched systems pre-Vista will give an incorrect ! result for dates after 2007. ! >>> nov2_post_change = datetime.datetime(2007, 11, 2, tzinfo = MST) ! >>> incorrect_unpatched_response = (2007, 11, 2, 7, 0, 0, 4, 306, 0) ! >>> new_response = (2007, 11, 2, 6, 0, 0, 4, 306, 0) ! >>> post_response = nov2_post_change.utctimetuple() ! >>> post_response in (new_response, incorrect_unpatched_response) ! True There is a function you can call to get some capabilities of the time *************** *** 120,123 **** --- 127,143 ---- >>> caps.has_key('DynamicTZSupport') True + + >>> both_dates_correct = (pre_response == old_response and post_response == new_response) + >>> old_dates_wrong = (pre_response == incorrect_patch_response) + >>> new_dates_wrong = (post_response == incorrect_unpatched_response) + + >>> caps['DynamicTZSupport'] == both_dates_correct + True + + >>> (not caps['DynamicTZSupport'] and caps['MissingTZPatch']) == new_dates_wrong + True + + >>> (not caps['DynamicTZSupport'] and not caps['MissingTZPatch']) == old_dates_wrong + True """ from __future__ import generators *************** *** 144,181 **** log = logging.getLogger(__file__) ! class WinTZI(object): ! format = '3l8h8h' ! def __init__(self, param): ! isinstance(param, basestring) and self.__load_bytes(param) ! isinstance(param, TIME_ZONE_INFORMATION) and self.__load_time_zone_information(param) ! def __load_bytes(self, bytes): ! components = struct.unpack(self.format, bytes) bias, standard_bias, daylight_bias = components[:3] standard_start = SYSTEMTIME(*components[3:11]) daylight_start = SYSTEMTIME(*components[11:19]) ! standard_name = daylight_name = "" ! tzi = TIME_ZONE_INFORMATION(bias, standard_name, standard_start, standard_bias, daylight_name, daylight_start, daylight_bias,) - self.__load_time_zone_information(tzi) ! def __load_time_zone_information(self, tzi): ! """Copy all the attributes from a TIME_ZONE_INFORMATION structure, ! converting bias values to timedelta objects along the way.""" ! # TODO: consider merging this class with TIME_ZONE_INFORMATION ! make_minute_time_delta = lambda m: datetime.timedelta(minutes = m) ! bias_fields = [field for field in tzi.fields() if 'bias' in field] ! for name in tzi.fields(): ! value = getattr(tzi, name) ! if 'bias' in name: ! value = make_minute_time_delta(value) setattr(self, name, value) ! def LocateStartDay(self, year): return self._locate_day(year, self.daylight_start) ! def LocateEndDay(self, year): return self._locate_day(year, self.standard_start) --- 164,273 ---- log = logging.getLogger(__file__) ! # A couple of C-type structures for working with the Windows Platform SDK ! class SYSTEMTIME(ctypes.Structure): ! _fields_ = [ ! ('year', ctypes.c_ushort), ! ('month', ctypes.c_ushort), ! ('day_of_week', ctypes.c_ushort), ! ('day', ctypes.c_ushort), ! ('hour', ctypes.c_ushort), ! ('minute', ctypes.c_ushort), ! ('second', ctypes.c_ushort), ! ('millisecond', ctypes.c_ushort), ! ] ! class TIME_ZONE_INFORMATION(ctypes.Structure): ! _fields_ = [ ! ('bias', ctypes.c_long), ! ('standard_name', ctypes.c_wchar*32), ! ('standard_start', SYSTEMTIME), ! ('standard_bias', ctypes.c_long), ! ('daylight_name', ctypes.c_wchar*32), ! ('daylight_start', SYSTEMTIME), ! ('daylight_bias', ctypes.c_long), ! ] ! ! ! class TimeZoneDefinition(TIME_ZONE_INFORMATION): ! """ ! A time zone definition class based on the win32 TIME_ZONE_INFORMATION ! structure. ! Describes a bias against UTC (bias), and two dates at which a separate ! additional bias applies (standard_bias and daylight_bias). ! """ ! ! def field_names(self): ! return map(operator.itemgetter(0), self._fields_) ! ! def __init__(self, *args, **kwargs): ! """ ! Try to construct a TimeZoneDefinition from ! a) TIME_ZONE_INFORMATION args ! b) another TimeZoneDefinition ! c) a byte structure (using _from_bytes) ! """ ! try: ! TIME_ZONE_INFORMATION.__init__(self, *args, **kwargs) ! return ! except TypeError: ! pass ! ! try: ! self.__init_from_other(*args, **kwargs) ! return ! except TypeError: ! pass ! ! try: ! self.__init_from_bytes(*args, **kwargs) ! return ! except TypeError: ! pass ! ! raise TypeError("Invalid arguments for %s" % self.__class__) ! ! def __init_from_bytes(self, bytes, standard_name='', daylight_name=''): ! format = '3l8h8h' ! components = struct.unpack(format, bytes) bias, standard_bias, daylight_bias = components[:3] standard_start = SYSTEMTIME(*components[3:11]) daylight_start = SYSTEMTIME(*components[11:19]) ! TIME_ZONE_INFORMATION.__init__(self, bias, standard_name, standard_start, standard_bias, daylight_name, daylight_start, daylight_bias,) ! def __init_from_other(self, other): ! if not isinstance(other, TIME_ZONE_INFORMATION): ! raise TypeError, "Not a TIME_ZONE_INFORMATION" ! for name in self.field_names(): ! # explicitly get the value from the underlying structure ! value = TIME_ZONE_INFORMATION.__getattribute__(other, name) setattr(self, name, value) ! def __getattribute__(self, attr): ! value = TIME_ZONE_INFORMATION.__getattribute__(self, attr) ! make_minute_timedelta = lambda m: datetime.timedelta(minutes = m) ! if 'bias' in attr: ! value = make_minute_timedelta(value) ! return value ! ! @classmethod ! def current(class_): ! "Windows Platform SDK GetTimeZoneInformation" ! tzi = class_() ! code = ctypes.windll.kernel32.GetTimeZoneInformation(ctypes.byref(tzi)) ! return code, tzi ! ! def set(self): ! return ctypes.windll.kernel32.SetTimeZoneInformation(ctypes.byref(self)) ! ! def copy(self): ! return self.__class__(self) ! ! def locate_daylight_start(self, year): return self._locate_day(year, self.daylight_start) ! def locate_standard_start(self, year): return self._locate_day(year, self.standard_start) *************** *** 183,187 **** def _locate_day(year, cutoff): """ ! Takes a pywintoypes.Time object, such as retrieved from a TIME_ZONE_INFORMATION structure or call to GetTimeZoneInformation and interprets it based on the given year to identify the actual day. --- 275,279 ---- def _locate_day(year, cutoff): """ ! Takes a SYSTEMTIME object, such as retrieved from a TIME_ZONE_INFORMATION structure or call to GetTimeZoneInformation and interprets it based on the given year to identify the actual day. *************** *** 196,205 **** # according to my calendar, the 4th Saturday in March in 2009 was the 28th >>> expected_date = datetime.datetime(2009, 3, 28) ! >>> WinTZI._locate_day(2009, st) == expected_date True - - Refer to the Windows Platform SDK for more information on the SYSTEMTIME - and TIME_ZONE_INFORMATION structures. - """ # MS stores Sunday as 0, Python datetime stores Monday as zero --- 288,293 ---- # according to my calendar, the 4th Saturday in March in 2009 was the 28th >>> expected_date = datetime.datetime(2009, 3, 28) ! >>> TimeZoneDefinition._locate_day(2009, st) == expected_date True """ # MS stores Sunday as 0, Python datetime stores Monday as zero *************** *** 224,237 **** return result - def __cmp__(self, other): - return cmp(self.__dict__, other.__dict__) - class TimeZoneInfo(datetime.tzinfo): """ ! Main class for handling win32 time zones. Usage: TimeZoneInfo(<Time Zone Standard Name>, [<Fix Standard Time>]) ! If <Fix Standard Time> evaluates to True, daylight savings time is calculated in the same ! way as standard time. """ --- 312,324 ---- return result class TimeZoneInfo(datetime.tzinfo): """ ! Main class for handling Windows time zones. Usage: TimeZoneInfo(<Time Zone Standard Name>, [<Fix Standard Time>]) ! ! If <Fix Standard Time> evaluates to True, daylight savings time is ! calculated in the same ! way as standard time. """ *************** *** 240,244 **** def __init__(self, param, fix_standard_time=False): ! if isinstance(param, WinTZI): self._LoadFromTZI(param) if isinstance(param, basestring): --- 327,331 ---- def __init__(self, param, fix_standard_time=False): ! if isinstance(param, TimeZoneDefinition): self._LoadFromTZI(param) if isinstance(param, basestring): *************** *** 272,276 **** self.standardName = key['Std'] self.daylightName = key['Dlt'] ! self.staticInfo = WinTZI(key['TZI']) self._LoadDynamicInfoFromKey(key) --- 359,363 ---- self.standardName = key['Std'] self.daylightName = key['Dlt'] ! self.staticInfo = TimeZoneDefinition(key['TZI']) self._LoadDynamicInfoFromKey(key) *************** *** 290,294 **** del info['LastEntry'] years = map(int, info.keys()) ! values = map(WinTZI, info.values()) # create a range mapping that searches by descending year and matches # if the target year is greater or equal. --- 377,381 ---- del info['LastEntry'] years = map(int, info.keys()) ! values = map(TimeZoneDefinition, info.values()) # create a range mapping that searches by descending year and matches # if the target year is greater or equal. *************** *** 367,379 **** def GetDSTStartTime(self, year): "Given a year, determines the time when daylight savings time starts" ! return self.getWinInfo(year).LocateStartDay(year) def GetDSTEndTime(self, year): "Given a year, determines the time when daylight savings ends." ! return self.getWinInfo(year).LocateEndDay(year) def __cmp__(self, other): return cmp(self.__dict__, other.__dict__) # helper methods for accessing the timezone info from the registry @staticmethod --- 454,507 ---- def GetDSTStartTime(self, year): "Given a year, determines the time when daylight savings time starts" ! return self.getWinInfo(year).locate_daylight_start(year) def GetDSTEndTime(self, year): "Given a year, determines the time when daylight savings ends." ! return self.getWinInfo(year).locate_standard_start(year) def __cmp__(self, other): return cmp(self.__dict__, other.__dict__) + @classmethod + def local(class_): + """Returns the local time zone as defined by the operating system in the + registry. + >>> localTZ = TimeZoneInfo.local() + >>> now_local = datetime.datetime.now(localTZ) + >>> now_UTC = datetime.datetime.utcnow() + >>> (now_UTC - now_local) < datetime.timedelta(seconds = 5) + Traceback (most recent call last): + ... + TypeError: can't subtract offset-naive and offset-aware datetimes + + >>> now_UTC = now_UTC.replace(tzinfo = TimeZoneInfo('GMT Standard Time', True)) + + Now one can compare the results of the two offset aware values + >>> (now_UTC - now_local) < datetime.timedelta(seconds = 5) + True + """ + code, info = TimeZoneDefinition.current() + # code is 0 if daylight savings is disabled or not defined + # code is 1 or 2 if daylight savings is enabled, 2 if currently active + fix_standard_time = not code + # note that although the given information is sufficient to construct a WinTZI object, it's + # not sufficient to represent the time zone in which the current user is operating due + # to dynamic time zones. + return class_(info, fix_standard_time) + + @classmethod + def utc(class_): + """Returns a time-zone representing UTC. + + Same as TimeZoneInfo('GMT Standard Time', True) but caches the result + for performance. + + >>> isinstance(TimeZoneInfo.utc(), TimeZoneInfo) + True + """ + if not '_tzutc' in class_.__dict__: + setattr(class_, '_tzutc', class_('GMT Standard Time', True)) + return class_._tzutc + # helper methods for accessing the timezone info from the registry @staticmethod *************** *** 491,495 **** """ now = datetime.datetime.utcnow() ! now = now.replace(tzinfo=TimeZoneUTC()) return now --- 619,623 ---- """ now = datetime.datetime.utcnow() ! now = now.replace(tzinfo=TimeZoneInfo.utc()) return now *************** *** 500,504 **** >>> now_local = now() """ ! return datetime.datetime.now(GetLocalTimeZone()) # A timezone info for utc - pywintypes uses a single instance of this class --- 628,632 ---- >>> now_local = now() """ ! return datetime.datetime.now(TimeZoneInfo.local()) # A timezone info for utc - pywintypes uses a single instance of this class *************** *** 506,510 **** class TimeZoneUTC(TimeZoneInfo): """A UTC Time Zone instance that initializes statically (without ! accessing the registry or apis. """ def __new__(cls): --- 634,638 ---- class TimeZoneUTC(TimeZoneInfo): """A UTC Time Zone instance that initializes statically (without ! accessing the registry or apis). """ def __new__(cls): *************** *** 513,575 **** return cls._instance except AttributeError: ! tzi = cls._get_tzi() ! cls._instance = TimeZoneInfo.__new__(cls, tzi) return cls._instance def __init__(self): pass ! @classmethod ! def _get_tzi(cls): ! # create a TZI that represents UTC ! tzi = TIME_ZONE_INFORMATION() ! tzi.standardname = 'Universal Coordinated Time' ! return tzi def __repr__(self): return "%s()" % self.__class__.__name__ - def GetUTCTimeZone(): - """Returns a time-zone representing UTC. - - Same as TimeZoneInfo('GMT Standard Time', True) but caches the result - for performance. - - >>> isinstance(GetUTCTimeZone(), TimeZoneInfo) - True - """ - if not '_tzutc' in globals(): - globals().update(_tzutc = TimeZoneInfo('GMT Standard Time', True)) - return _tzutc - - def GetLocalTimeZone(): - """Returns the local time zone as defined by the operating system in the - registry. - Note that this will only work if the TimeZone in the registry has not been - customized. It should have been selected from the Windows interface. - >>> localTZ = GetLocalTimeZone() - >>> nowLoc = datetime.datetime.now(localTZ) - >>> nowUTC = datetime.datetime.utcnow() - >>> (nowUTC - nowLoc) < datetime.timedelta(seconds = 5) - Traceback (most recent call last): - ... - TypeError: can't subtract offset-naive and offset-aware datetimes - - >>> nowUTC = nowUTC.replace(tzinfo = TimeZoneInfo('GMT Standard Time', True)) - - Now one can compare the results of the two offset aware values - >>> (nowUTC - nowLoc) < datetime.timedelta(seconds = 5) - True - """ - code, result = GetTimeZoneInformation() - info = WinTZI(result) - # code is 0 if daylight savings is disabled or not defined - # code is 1 or 2 if daylight savings is enabled, 2 if currently active - fix_standard_time = not code - # note that although the given information is sufficient to construct a WinTZI object, it's - # not sufficient to represent the time zone in which the current user is operating due - # to dynamic time zones. - return TimeZoneInfo(info, fix_standard_time) - def GetTZCapabilities(): """Run a few known tests to determine the capabilities of the time zone database --- 641,659 ---- return cls._instance except AttributeError: ! cls._instance = cls.__create_instance() return cls._instance def __init__(self): pass ! @classmethod ! def __create_instance(cls): ! tzi = TimeZoneDefinition(standardname='Universal Coordinated Time') ! cls._instance = TimeZoneInfo.__new__(cls, tzi) ! def __repr__(self): return "%s()" % self.__class__.__name__ def GetTZCapabilities(): """Run a few known tests to determine the capabilities of the time zone database *************** *** 698,731 **** def __new__(cls): return RangeItem.__new__(cls, -1) - - # some win32api stuff to get raw SYSTEMTIME structures - class SYSTEMTIME(ctypes.Structure): - _fields_ = [ - ('year', ctypes.c_ushort), - ('month', ctypes.c_ushort), - ('day_of_week', ctypes.c_ushort), - ('day', ctypes.c_ushort), - ('hour', ctypes.c_ushort), - ('minute', ctypes.c_ushort), - ('second', ctypes.c_ushort), - ('millisecond', ctypes.c_ushort), - ] - - class TIME_ZONE_INFORMATION(ctypes.Structure): - _fields_ = [ - ('bias', ctypes.c_long), - ('standard_name', ctypes.c_wchar*32), - ('standard_start', SYSTEMTIME), - ('standard_bias', ctypes.c_long), - ('daylight_name', ctypes.c_wchar*32), - ('daylight_start', SYSTEMTIME), - ('daylight_bias', ctypes.c_long), - ] - - def fields(self): - return map(operator.itemgetter(0), self._fields_) - - def GetTimeZoneInformation(): - tzi = TIME_ZONE_INFORMATION() - code = ctypes.windll.kernel32.GetTimeZoneInformation(ctypes.byref(tzi)) - return code, tzi --- 782,783 ---- |
From: Jason R. C. <ja...@us...> - 2009-01-14 17:51:26
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25337 Modified Files: win32timezone.py Log Message: Reworked TimeZoneUTC to initialize with a TIME_ZONE_INFORMATION structure so it now is a subclass of TimeZoneInfo. Added now() and utcnow() for convenient access to timezone-aware times. Index: win32timezone.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32timezone.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** win32timezone.py 14 Jan 2009 04:06:02 -0000 1.18 --- win32timezone.py 14 Jan 2009 17:51:17 -0000 1.19 *************** *** 183,187 **** def _locate_day(year, cutoff): """ ! Takes a pywintypes.Time object, such as retrieved from a TIME_ZONE_INFORMATION structure or call to GetTimeZoneInformation and interprets it based on the given year to identify the actual day. --- 183,187 ---- def _locate_day(year, cutoff): """ ! Takes a pywintoypes.Time object, such as retrieved from a TIME_ZONE_INFORMATION structure or call to GetTimeZoneInformation and interprets it based on the given year to identify the actual day. *************** *** 484,495 **** # end backward compatibility # A timezone info for utc - pywintypes uses a single instance of this class # to return SYSTEMTIME instances. ! # Lifted from Gustavo Niemeyer's PSF-licensed dateutil package. ! class TimeZoneUTC(datetime.tzinfo): ! """A UTC Time Zone instance that is compatible with TimeZoneInfo, but ! avoids access to the registry. ! >>> TimeZoneUTC() == GetUTCTimeZone() ! True """ def __new__(cls): --- 484,510 ---- # end backward compatibility + def utcnow(): + """ + Return the UTC time now with timezone awareness as enabled + by this module + >>> now = utcnow() + """ + now = datetime.datetime.utcnow() + now = now.replace(tzinfo=TimeZoneUTC()) + return now + + def now(): + """ + Return the local time now with timezone awareness as enabled + by this module + >>> now_local = now() + """ + return datetime.datetime.now(GetLocalTimeZone()) + # A timezone info for utc - pywintypes uses a single instance of this class # to return SYSTEMTIME instances. ! class TimeZoneUTC(TimeZoneInfo): ! """A UTC Time Zone instance that initializes statically (without ! accessing the registry or apis. """ def __new__(cls): *************** *** 498,534 **** return cls._instance except AttributeError: ! cls._instance = datetime.tzinfo.__new__(cls) return cls._instance ! ZERO = datetime.timedelta(0) ! def utcoffset(self, dt): ! return self.ZERO ! ! def dst(self, dt): ! return self.ZERO ! ! def tzname(self, dt): ! return "UTC" ! ! def __eq__(self, other): ! # Instance of this exact class? ! if isinstance(other, TimeZoneUTC): ! return True ! # allow comparisons against the regular TimeZoneInfo object. ! if not isinstance(other, TimeZoneInfo): ! return False ! # The following uses the staticInfo directly (ignoring any ! # dynamic info). This should compare the time zones using ! # the most current info. The two are equal if there is ! # no bias, no standard time bias, and no bias during dst. ! si = other.staticInfo ! same_bias = si.bias==self.ZERO ! same_standard_bias = si.standard_bias==self.ZERO ! no_dst = other.fixedStandardTime == True ! same_daylight_bias = no_dst or si.daylight_bias==self.ZERO ! return same_bias and same_standard_bias and same_daylight_bias ! ! def __ne__(self, other): ! return not self.__eq__(other) def __repr__(self): --- 513,529 ---- return cls._instance except AttributeError: ! tzi = cls._get_tzi() ! cls._instance = TimeZoneInfo.__new__(cls, tzi) return cls._instance ! def __init__(self): ! pass ! ! @classmethod ! def _get_tzi(cls): ! # create a TZI that represents UTC ! tzi = TIME_ZONE_INFORMATION() ! tzi.standardname = 'Universal Coordinated Time' ! return tzi def __repr__(self): |
From: Mark H. <mha...@us...> - 2009-01-14 13:05:15
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/tools In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3058/Pythonwin/pywin/tools Modified Files: hierlist.py Log Message: fix embarrasing trivial errors in py3k comparisons Index: hierlist.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/tools/hierlist.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** hierlist.py 5 Jan 2009 11:06:00 -0000 1.11 --- hierlist.py 14 Jan 2009 12:10:06 -0000 1.12 *************** *** 314,323 **** return None # same as other # for py3k/rich-comp sorting compatibility. ! def __cmp__(self): # this is always overridden, but to be sure... return cmp(id(self), id(other)) def __lt__(self, other): try: ! return self.__cmp__(self, other) < 0 except TypeError: # we want unrelated items to be sortable... --- 314,323 ---- return None # same as other # for py3k/rich-comp sorting compatibility. ! def __cmp__(self, other): # this is always overridden, but to be sure... return cmp(id(self), id(other)) def __lt__(self, other): try: ! return self.__cmp__(other) < 0 except TypeError: # we want unrelated items to be sortable... *************** *** 326,330 **** def __eq__(self, other): try: ! return __cmp__(self, other) == 0 except TypeError: # unrelated items compare false --- 326,330 ---- def __eq__(self, other): try: ! return self.__cmp__(other) == 0 except TypeError: # unrelated items compare false |
From: Mark H. <mha...@us...> - 2009-01-14 13:05:07
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/tools In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3127/pywin/tools Modified Files: browser.py Log Message: work with py2.x and py3.x function attributes Index: browser.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/tools/browser.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** browser.py 5 Jan 2009 10:57:01 -0000 1.14 --- browser.py 14 Jan 2009 12:11:04 -0000 1.15 *************** *** 206,211 **** except AttributeError: pass ! ret.append( MakeHLI( self.myobject.func_code, "Code" )) ! ret.append( MakeHLI( self.myobject.func_globals, "Globals" )) self.InsertDocString(ret) return ret --- 206,218 ---- except AttributeError: pass ! try: ! code = self.myobject.__code__ ! globs = self.myobject.__globals__ ! except AttributeError: ! # must be py2.5 or earlier... ! code = self.myobject.func_code ! globs = self.myobject.func_globals ! ret.append(MakeHLI(code, "Code" )) ! ret.append(MakeHLI(globs, "Globals" )) self.InsertDocString(ret) return ret |
From: Mark H. <mha...@us...> - 2009-01-14 13:05:02
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/debugger In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3164/pywin/debugger Modified Files: debugger.py Log Message: expose if win32ui is build as unicode and hook the 'W' version of some messages accordingly Index: debugger.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/debugger/debugger.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** debugger.py 4 Jan 2009 01:53:29 -0000 1.23 --- debugger.py 14 Jan 2009 12:11:46 -0000 1.24 *************** *** 28,31 **** --- 28,35 ---- #import win32traceutil + if win32ui.UNICODE: + LVN_ENDLABELEDIT = commctrl.LVN_ENDLABELEDITW + else: + LVN_ENDLABELEDIT = commctrl.LVN_ENDLABELEDITA from dbgcon import * *************** *** 238,242 **** itemDetails = (commctrl.LVCFMT_LEFT, width, title, 0) list.InsertColumn(col, itemDetails) ! parent.HookNotify( self.OnListEndLabelEdit, commctrl.LVN_ENDLABELEDIT) parent.HookNotify(self.OnItemRightClick, commctrl.NM_RCLICK) parent.HookNotify(self.OnItemDoubleClick, commctrl.NM_DBLCLK) --- 242,246 ---- itemDetails = (commctrl.LVCFMT_LEFT, width, title, 0) list.InsertColumn(col, itemDetails) ! parent.HookNotify(self.OnListEndLabelEdit, LVN_ENDLABELEDIT) parent.HookNotify(self.OnItemRightClick, commctrl.NM_RCLICK) parent.HookNotify(self.OnItemDoubleClick, commctrl.NM_DBLCLK) *************** *** 249,254 **** def EditSelected(self): ! sel = self.GetNextItem(-1, commctrl.LVNI_SELECTED) ! if sel == -1: return self.EditLabel(sel) --- 253,259 ---- def EditSelected(self): ! try: ! sel = self.GetNextItem(-1, commctrl.LVNI_SELECTED) ! except win32ui.error: return self.EditLabel(sel) |
From: Mark H. <mha...@us...> - 2009-01-14 13:04:57
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3164 Modified Files: win32uimodule.cpp Log Message: expose if win32ui is build as unicode and hook the 'W' version of some messages accordingly Index: win32uimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uimodule.cpp,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** win32uimodule.cpp 8 Jan 2009 22:11:52 -0000 1.46 --- win32uimodule.cpp 14 Jan 2009 12:11:46 -0000 1.47 *************** *** 2024,2027 **** --- 2024,2034 ---- #endif ADD_CONSTANT(debug); // @const win32ui|debug|1 if we are current using a _DEBUG build of win32ui, else 0. + if (PyModule_AddIntConstant(module, "UNICODE", + #ifdef UNICODE + 1 + #else + 0 + #endif + ) == -1) return -1; ADD_CONSTANT(AFX_IDW_PANE_FIRST); // @const win32ui|AFX_IDW_PANE_FIRST|Id of the first splitter pane ADD_CONSTANT(AFX_IDW_PANE_LAST); // @const win32ui|AFX_IDW_PANE_LAST|Id of the last splitter pane |
From: Mark H. <mha...@us...> - 2009-01-14 13:04:47
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3164/pywin/framework Modified Files: toolmenu.py Log Message: expose if win32ui is build as unicode and hook the 'W' version of some messages accordingly Index: toolmenu.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/toolmenu.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** toolmenu.py 5 Jan 2009 11:03:05 -0000 1.4 --- toolmenu.py 14 Jan 2009 12:11:46 -0000 1.5 *************** *** 123,126 **** --- 123,131 ---- from pywin.mfc import dialog + if win32ui.UNICODE: + LVN_ENDLABELEDIT = commctrl.LVN_ENDLABELEDITW + else: + LVN_ENDLABELEDIT = commctrl.LVN_ENDLABELEDITA + class ToolMenuPropPage(dialog.PropertyPage): def __init__(self): |